• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Fireplace Air Temperature

Q&A Forum › Category: Home Automation › Fireplace Air Temperature
0 Vote Up Vote Down
Larry asked 3 years ago

I found this on the web and it pretty much does what I need it to do, There are a few things I will add to this but for now all I want to know is how to get these darn readings from Celcius to F. I would also like to add a second reading so I could use it for comparison readings .I am able to change the text but not the conversion to F. I am using an ESP8266 Lolin D1 Mini and I know it only has 1 A0 ,that will be another issue later if this does what I want.

Start your code here

#include <ESP8266WiFi.h>
#include <math.h>

// http://arduino.esp8266.com/stable/package_esp8266com_index.json

unsigned int Rs = 150000;
double Vcc = 3.3;

// WiFi parameters
const char* ssid = “*****”;
const char* password = “************”

// Pin

WiFiServer server(80);

void setup() {
Serial.begin(115200);
delay(10);
Serial.println();

// Init DHT

// Connect to WiFi network
WiFi.mode(WIFI_STA);
Serial.println();
Serial.println();
Serial.print(“Connecting to “);
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.println(“WiFi connected”);

// Start the server
server.begin();
Serial.println(“Server started”);

// Print the IP address
Serial.println(WiFi.localIP());
}

void loop() {

delay(1000);

Serial.println(Thermister(AnalogRead()));
float temp = Thermister(AnalogRead());

WiFiClient client = server.available();
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“Connection: close”); // the connection will be closed after completion of the response
client.println(“Refresh: 3”); // refresh the page automatically every 5 sec
client.println();
client.println(“<!DOCTYPE html>”);
client.println(“<html xmlns=’http://www.w3.org/1999/xhtml’>&#8221;);
client.println(“<head>\n<meta charset=’UTF-8′>”);
client.println(“<title>Fireplaceh Wifi Temp Sensor</title>”);
client.println(“<link href=’https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css&#8217; rel=’stylesheet’>”);
client.println(“</head>\n<body>”);
client.println(“<div class=’container’>”);
client.println(“<div class=’panel panel-default’ margin:15px>”);
client.println(“<div class=’panel-heading’>”);
client.println(“<H2>Fireplace Wifi Temp Sensor</H2>”);
client.println(“<div class=’panel-body’ style=’background-color: powderblue’>”);
client.println(“<pre>”);
client.print(“Temperature (°F) : “);
client.println(temp, 2);
client.println(“</pre>”);
client.println(“</div>”);
client.println(“</div>”);
client.println(“</div>”);
client.print(“</body>\n</html>”);
}

int AnalogRead() {
int val = 0;
for(int i = 0; i < 20; i++) {
val += analogRead(A0);
delay(1);
}

val = val / 20;
return val;
}

double Thermister(int val) {
double V_NTC = (double)val / 1024;
double R_NTC = (Rs * V_NTC) / (Vcc – V_NTC);
R_NTC = log(R_NTC);
double Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * R_NTC * R_NTC ))* R_NTC );
//Temp = Temp – 273.15;
Temp = Temp – 303.01;
return Temp;

Serial.print (Temp);
}

Question Tags: ESP8266 wifi
4 Answers
0 Vote Up Vote Down
Larry answered 3 years ago

I believe I got it figured out now, thanks
Temp=(Temp*9.0)/ 5.0+32;
I will play around with this and see I get good results, so far it doesn’t look to be too stable 70.27- 70.9 bouncing around.Thanks

 

 

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
Yes, that’s it.
You just have to use that formula to convert it.
Regards,
Sara

0 Vote Up Vote Down
Larry answered 3 years ago

Thanks, how do I change the refresh rate, it is “refresh 3” currently for 5 sec. I searched and could not find readily available to explain how I would get say 10 or more sec?

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi again.
I’m not familiar with that notation of refreshing. Is it working?
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.