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’>”);
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’ 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);
}
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
Hi.
Yes, that’s it.
You just have to use that formula to convert it.
Regards,
Sara
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?