Page 1 of 3
esp8226 webserver reset on power restart
Posted:
Sat Jan 07, 2023 2:57 am
by harrisonselectricals
hi all
im new to this site so bear with me
i have a 8226 acting as a webserver displaying the temp and humidity readings from dht11 module
its located in an outbuilding and if it has a power down i have to press the reset button
is there a solution to this?
thanks in advance Steve
Re: esp8226 webserver reset on power restart
Posted:
Sun Jan 08, 2023 6:30 am
by btidey
You will have to give more details to get a decent answer; board type, powering arrangements, software used.
Normally, powering up a esp8266 should be the same as performing a reset but if the voltage rises slowly then it might prevent the power up circuitry from performing correctly.
Re: esp8226 webserver reset on power restart
Posted:
Mon Jan 09, 2023 3:19 am
by harrisonselectricals
hi thanks for replying
its an HALJIA ESP8266 ESP-01S from amazon
im using a spare uno as a voltage regulator the uno is usb powered and the 8266 is just using 3.3v and gnd
as for the software ill paste it below its just std sketch for dht 11
#include <ESP8266WiFi.h>
#include "DHT.h"
#define DHTPIN 2 // what digital pin we're connected to
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
const char* ssid = "PLUSNET-P6****"; // Your ssid
const char* password = "***"; // Your Password
WiFiServer server(80);
void setup() {
// Start DHT11
dht.begin();
Serial.begin(115200);
delay(10);
Serial.println();
// 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() {
float h = dht.readHumidity();
float t = dht.readTemperature(); // Read temperature as Celsius (the default)
float f = dht.readTemperature(true); // Read temperature as Fahrenheit (isFahrenheit = true)
t=t -10;
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity % : ");
Serial.println(h);
Serial.print("Temperature *C: ");
Serial.println(t);
Serial.print("Temperature *F: ");
Serial.println(f);
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: 5"); // 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("<c><title>Steves Mancave Temperature</title>");
client.println("</head>\n<body>");
client.println("<c><H1>Steves Mancave Temperature</H1>");
client.println("<H1>Humidity / Temperature</H1>");
client.println("<pre>");
client.print("<H1>Humidity (%) : <H1>");
client.println((float)h, 2);
client.print("Temperature (°C) : ");
client.println((float)t, 2);
client.print("Temperature (°F) : ");
client.println((float)f, 2);
//client.print("Temperature (°K) : ");
//client.println(Kelvin(temp), 2);
client.println("</pre>");
//client.println("<H3>www.Circuits-DIY.com</H3>");
client.print("</body>\n</html>");
delay(2000);
}
any help would be great
cheers steve
Re: esp8226 webserver reset on power restart
Posted:
Tue Jan 10, 2023 4:06 am
by harrisonselectricals
hi ive powered it with the 3.3v output from an uno the software is the standard dht 11 sketch i hope this is enough info ?