Unstable ESP8266 randomly and constantly resetting - FIXED
Posted:
Sat Feb 06, 2016 11:00 am
by viscomjim
Working on a project using ESP8266Basic and a nodeMCU board. Running about 200 line program thats reading thingspeak every 8 seconds and doing stuff based on data received. When working at home with the project, it worked just fine. I brought it to work and connected to my work wifi and the unit would constantly reset just wasn't stable. I used a 5 volt wall wart and added a 1000uf cap near the nodeMCU, which again, worked well at home.
I added a .1uf cap to the 1000uf cap and, lo and behold, ALL issues are gone. So I can not stress enough, when you have issues with the ESP, always check your power supply first! Make sure firstly that you have the current you need (actually, more than enough is ALWAYS better) then add a larger filter cap and a .1uf cap for noise.
Most of my problems with the ESP wound up being power related.
Thanks for listening!!!
Re: Unstable ESP8266 randomly and constantly resetting - FIX
Posted:
Thu Oct 27, 2016 9:19 am
by neevarphr
Where to connect that Capacitor? can you send me the connection diagram?
Actually i am facing a problem with ESP8266, i am using it to blink a LED from a browser, i type the IP address of the ESP8266 and it'll load an html page written in that ESP, but it works for few trials, but after that it'll stop responding, in the sense it won't load the html page, but if we rest the ESP, then it'll start responding but problem remains unsolved, Please help me with this,, I'm Waiting..
i'm using this code for esp8266.
LOW logic to switch ON and HIGH logic to switch OFF
#include <ESP8266WiFi.h>
int a=0;
const char* ssid = "Automate";
const char* password = "qwerty123";
int ledPin1 = 5;
int ledPin2 = 4;
int ledPin3 = 13;
int ledPin4 = 12;
int ledPin5 = 14;
int ledPin6 = 16;
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
//Assigning the pins to particular lights and setting them as OUTPUTs
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
// initializing it to OFF condition
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
digitalWrite(ledPin6, HIGH);
// Connect to WiFi network
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.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Match the request
static int value1 = HIGH;
static int value2 = HIGH;
static int value3 = HIGH;
static int value4 = HIGH;
static int value5 = HIGH;
static int value6 = HIGH;
// Set ledPin according to the request
//digitalWrite(ledPin, value);
//configuring fan number 1
if ((request.indexOf("LED1=ON") != -1)||(request.indexOf("LED7=ON") != -1)) {
digitalWrite(ledPin1, HIGH);
delay(250);
value1 = HIGH;
a=2;
}
if ((request.indexOf("LED1=OFF") != -1)||(request.indexOf("LED7=OFF") != -1)) {
digitalWrite(ledPin1, LOW);
value1 = LOW;
delay(250);
a=1;
}
//configuring fan number 2
if ((request.indexOf("LED2=OFF") != -1)||(request.indexOf("LED7=OFF") != -1)) {
digitalWrite(ledPin2, LOW);
value2 = LOW;
delay(250);
a=3;
}
if ((request.indexOf("LED2=ON") != -1)||(request.indexOf("LED7=ON") != -1)) {
digitalWrite(ledPin2, HIGH);
value2 = HIGH;
delay(250);
a=4;
}
//configuring fan number 3
if ((request.indexOf("LED3=OFF") != -1)||(request.indexOf("LED7=OFF") != -1)) {
digitalWrite(ledPin3, LOW);
value3 = LOW;
delay(250);
a=5;
}
if ((request.indexOf("LED3=ON") != -1)||(request.indexOf("LED7=ON") != -1)) {
digitalWrite(ledPin3, HIGH);
value3 = HIGH;
delay(250);
a=6;
}
//configuring fan number 4
if ((request.indexOf("LED4=OFF") != -1)||(request.indexOf("LED7=OFF") != -1)) {
digitalWrite(ledPin4, LOW);
value4 = LOW;
delay(250);
a=7;
}
if ((request.indexOf("LED4=ON") != -1)||(request.indexOf("LED7=ON") != -1)) {
digitalWrite(ledPin4, HIGH);
value4 = HIGH;
delay(250);
a=8;
}
//configuring fan number 5
if ((request.indexOf("LED5=OFF") != -1)||(request.indexOf("LED7=OFF") != -1)) {
digitalWrite(ledPin5, LOW);
value5 = LOW;
delay(250);
a=9;
}
if ((request.indexOf("LED5=ON") != -1)||(request.indexOf("LED7=ON") != -1)) {
digitalWrite(ledPin5, HIGH);
value5 = HIGH;
delay(250);
a=10;
}
//configuring fan number 6
if ((request.indexOf("LED6=OFF") != -1)||(request.indexOf("LED7=OFF") != -1)) {
digitalWrite(ledPin6, LOW);
value6 = LOW;
delay(250);
a=11;
}
if ((request.indexOf("LED6=ON") != -1)||(request.indexOf("LED7=ON") != -1)) {
digitalWrite(ledPin6, HIGH);
value6 = HIGH;
delay(250);
a=12;
}
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<head><title>light controller</title></head>");
client.println("<body bgcolor=#ad2b10><center>");
client.println("<font color=#FFFFFF size=5>");
switch(a){
case 1: client.println("Fan 1 is ON now <br>");
break;
case 2: client.println("Fan 1 OFF now <br>");
break;
case 3: client.println("Fan 2 is ON now <br>");
break;
case 4: client.println("Fan 2 OFF now <br>");
break;
case 5: client.println("Fan 3 is ON now <br>");
break;
case 6: client.println("Fan 3 is OFF now <br>");
break;
case 7: client.println("Fan 4 is ON now <br>");
break;
case 8: client.println("Fan 4 is OFF now <br>");
break;
case 9: client.println("Fan 5 is ON now <br>");
break;
case 10: client.println("Fan 5 is OFF now <br>");
break;
case 11: if(request.indexOf("LED7=OFF") != -1) client.println("All Fans are ON now <br>");
else client.println("Fan 6 is ON now <br>");
break;
case 12: if(request.indexOf("LED7=ON") != -1) client.println("All Fans are OFF now <br>");
else client.println("Fan 6 is OFF now <br>");
break;
default : break;
}
client.println("</font></center>");
client.println("<br><br><br>");
client.println("<a href=\"http://192.168.0.110:8082/app/server_fan.html\" ><font size=4 color=#FFFFFF>Back</font></a><br />");
client.println("</html>");
client.stop();
delay(1);
Serial.println("Client disonnected");
Serial.println("");
}
Re: Unstable ESP8266 randomly and constantly resetting - FIX
Posted:
Wed Nov 09, 2016 2:53 am
by Oldbod
These sorts of problems where it breaks after a bit are always the tricky ones. I guess you may have some sort of memory leak but if you repost in the main forum section for c you'll have more people who are c programmers reading your issue. This forum section is espbasic users, some will know c but most won't... if your code doesn't require high speed execution, you'd probably find rewriting it in espbasic simplified it. (Plug)
Re: Unstable ESP8266 randomly and constantly resetting - FIX
Posted:
Wed Nov 09, 2016 8:18 am
by Electroguard
As a general rule neevarphr, all chips should have a 0.1uF 'bypass cap' connected as close as practical to their pos and neg supply pins.
This shorts to ground any supply-rail noise generated by the chips varying current consumption, which would otherwise escape out as noise on the supply rails to affect everything else. For your purposes you can consider the ESP module as being a chip.
Exactly 'where' is not important, just as close as is practically possible to the supply pins.
The same applies to all chips and modules whose internal current 'draw' can change, they should all have a 0.1uF bypass cap added across their supply pins to reduce power-rail noise.
The different current drain between LEDs being ON or OFF is quite significant, and if the supply rail feeding them has much resistance, or the power supply output voltage varies under load, this change of supply rail voltage may be seen be the ESP as a kick in the goolies.
So pay attention to things like having the ESP as close as possible to the power supply source and having the LEDs at the far end of the rail. You may also be able to benefit from having a large (1000uF) reservoir cap at both ends of the supply rail to smooth out the changing voltage and maintain a more stable supply throughout its length.