Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Shadow351
#35823 Hello, I have been working on a WiFi garage door controller for a couple months now and I just can't get it to work reliably. I am trying to use the ESP8266-03 programmed via the Arduino IDE.

1:The first I created worked great on my bench supply but when I tried to power it from a USB charger (through a DC-DC converter) it was fried instantly. (the chip on the ESP emitted a loud buzz and no longer functioned)

2:I then tried a second one powered by a phone charger (through a LM317) and just got Fatal Exceptions and garbage through the Serial Port. Moved to my bench supply and same result.

3:I ordered more modules, then used a 4.5V DC transformer (from an old portable CD player, I took it apart and it was just a transformer, rectifier, and capacitor, which I then fed to the LM317) this one would seemingly operate for 2-3 days then disconnect from the WiFi and require resetting. I moved up to a similar 6V transformer to rule out a power issue (even though 4.5 is above the dropout voltage according to the LM317 datasheet) and the same issue occured (plus the LM317 was getting hot, which I didn't like) so I switched back to the 4.5V. I also added a couple lines of code to send a UDP packet to a VB program running on my server to log when the ESP stops responding. Same result. I added a line of code to send the millis to the serial terminal every 5 min (and send a udp packet to the server) I then left my computer attached and awake to log through the serial terminal. I checked it periodically throughout the next few days I discovered a pattern, The module connects to WiFi "Checks in" to the sever and serial terminal for somewhere between 40-45 min then throws:
Code: Select allException (3):
epc1=0x4000dfb4 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40232a10 depc=0x00000000

and reboots. It did this for about 3 days then after the last reboot it connected to the WiFi then stopped responding. I came home from work to find it hadn't checked in since 9:36 the previous night. I unplugged the power supply, and plugged it back in, nothing. I picked the module up and burned my finger on the chip, (I mean burned, my finger is still sore). I unplugged the power and tested the supply at 4.36V under load then I tried powering it with my bench supply and it was pulling about 490mA both feeding 5V to the LM317 and 3.3V directly to the module. Another one bites the dust.


Why would the module operate fine (power wise) for days then just suddenly burn up? Could I have an Issue with my schematic? I would think wiring issues would show up quickly, not after days of runtime. I don't know how the code could cause the module to burn up. Any help would be appreciated, I am about ready to scrap the project and just run an Ethernet cable out into the garage. Thanks
-Brad

Serial Terminal (only the last few resets):
Code: Select allConnecting to WiFi
.............
WiFi connected
Server started
192.168.1.8
Door Position Changing
Checking In 300000
Alert Sent to HAM.
Checking In 600000
Alert Sent to HAM.
Checking In 900000
Alert Sent to HAM.
Checking In 1200000
Alert Sent to HAM.
Checking In 1500000
Alert Sent to HAM.
Checking In 1800000
Alert Sent to HAM.
Checking In 2100000
Alert Sent to HAM.
Checking In 2400000

Exception (3):
epc1=0x4000dfb4 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40232a10 depc=0x00000000

ctx: cont
sp: 3ffea9b0 end: 3ffeac20 offset: 01a0

>>>stack>>>
3ffeab50:  00000001 00000001 3ffe9009 40205d08 
3ffeab60:  00000009 0000000b 3ffe8b67 3ffeac4c 
3ffeab70:  3fffdc20 00249f00 3ffe9700 40202519 
3ffeab80:  40232a10 00249f00 3ffeac78 3ffeac4c 
3ffeab90:  3fffdc20 00249f00 3ffe9700 4020222b 
3ffeaba0:  3ffe9048 0a01a8c0 3ffeac78 40205f99 
3ffeabb0:  3ffe9008 3ffeac78 00249f00 402022ec 
3ffeabc0:  3ffe8eb8 00000000 000003e8 40205ddc 
3ffeabd0:  00000000 00000000 0101a8c0 40205e95 
3ffeabe0:  00000000 00000000 00000016 40101c71 
3ffeabf0:  402017ed 0801a8c0 00000000 00000000 
3ffeac00:  3fffdc20 00000000 3ffeac44 4020184a 
3ffeac10:  00000000 00000000 3ffe9c00 40100378 
<<<stack<<<

 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld


Connecting to WiFi
.............
WiFi connected
Server started
192.168.1.8
Door Position Changing
Checking In 300000
Alert Sent to HAM.
Checking In 600000
Alert Sent to HAM.
Checking In 900000
Alert Sent to HAM.
Checking In 1200000
Alert Sent to HAM.
Checking In 1500000
Alert Sent to HAM.
Checking In 1800000
Alert Sent to HAM.
Checking In 2100000
Alert Sent to HAM.
Checking In 2400000

Exception (3):
epc1=0x4000dfb4 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40232a10 depc=0x00000000

ctx: cont
sp: 3ffea9b0 end: 3ffeac20 offset: 01a0

>>>stack>>>
3ffeab50:  00000001 00000001 3ffe9009 40205d08 
3ffeab60:  00000009 0000000b 3ffe8b67 3ffeac4c 
3ffeab70:  3fffdc20 00249f00 3ffe9700 40202519 
3ffeab80:  40232a10 00249f00 3ffeac78 3ffeac4c 
3ffeab90:  3fffdc20 00249f00 3ffe9700 4020222b 
3ffeaba0:  3ffe9048 0a01a8c0 3ffeac78 40205f99 
3ffeabb0:  3ffe9008 3ffeac78 00249f00 402022ec 
3ffeabc0:  3ffe8eb8 00000000 000003e8 40205ddc 
3ffeabd0:  00000000 00000000 0101a8c0 40205e95 
3ffeabe0:  00000000 00000000 00000016 40101c71 
3ffeabf0:  402017ed 0801a8c0 00000000 00000000 
3ffeac00:  3fffdc20 00000000 3ffeac44 4020184a 
3ffeac10:  00000000 00000000 3ffe9c00 40100378 
<<<stack<<<

 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld


Connecting to WiFi
.............
WiFi connected
Server started
192.168.1.8
Door Position Changing
Checking In 300000
Alert Sent to HAM.
Checking In 600000
Alert Sent to HAM.
Checking In 900000
Alert Sent to HAM.
Checking In 1200000
Alert Sent to HAM.
Checking In 1500000
Alert Sent to HAM.
Checking In 1800000
Alert Sent to HAM.
Checking In 2100000
Alert Sent to HAM.
Checking In 2400000

Exception (3):
epc1=0x4000dfb4 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40232a10 depc=0x00000000

ctx: cont
sp: 3ffea9b0 end: 3ffeac20 offset: 01a0

>>>stack>>>
3ffeab50:  00000001 00000001 3ffe9009 40205d08 
3ffeab60:  00000009 0000000b 3ffe8b67 3ffeac4c 
3ffeab70:  3fffdc20 00249f00 3ffe9700 40202519 
3ffeab80:  40232a10 00249f00 3ffeac78 3ffeac4c 
3ffeab90:  3fffdc20 00249f00 3ffe9700 4020222b 
3ffeaba0:  3ffe9048 0a01a8c0 3ffeac78 40205f99 
3ffeabb0:  3ffe9008 3ffeac78 00249f00 402022ec 
3ffeabc0:  3ffe8eb8 00000000 000003e8 40205ddc 
3ffeabd0:  00000000 00000000 0101a8c0 40205e95 
3ffeabe0:  00000000 00000000 00000016 40101c71 
3ffeabf0:  402017ed 0801a8c0 00000000 00000000 
3ffeac00:  3fffdc20 00000000 3ffeac44 4020184a 
3ffeac10:  00000000 00000000 3ffe9c00 40100378 
<<<stack<<<

 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld


Connecting to WiFi
.............
WiFi connected
Server started
192.168.1.8
Door Position Changing
Checking In 300000
Alert Sent to HAM.
Checking In 600000
Alert Sent to HAM.
Checking In 900000
Alert Sent to HAM.
Checking In 1200000
Alert Sent to HAM.
Checking In 1500000
Alert Sent to HAM.
Checking In 1800000
Alert Sent to HAM.
Checking In 2100000
Alert Sent to HAM.
Checking In 2400000

Exception (3):
epc1=0x4000dfb4 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40232a10 depc=0x00000000

ctx: cont
sp: 3ffea9b0 end: 3ffeac20 offset: 01a0

>>>stack>>>
3ffeab50:  00000001 00000001 3ffe9009 40205d08 
3ffeab60:  00000009 0000000b 3ffe8b67 3ffeac4c 
3ffeab70:  3fffdc20 00249f00 3ffe9700 40202519 
3ffeab80:  40232a10 00249f00 3ffeac78 3ffeac4c 
3ffeab90:  3fffdc20 00249f00 3ffe9700 4020222b 
3ffeaba0:  3ffe9048 0a01a8c0 3ffeac78 40205f99 
3ffeabb0:  3ffe9008 3ffeac78 00249f00 402022ec 
3ffeabc0:  3ffe8eb8 00000000 000003e8 40205ddc 
3ffeabd0:  00000000 00000000 0101a8c0 40205e95 
3ffeabe0:  00000000 00000000 00000016 40101c71 
3ffeabf0:  402017ed 0801a8c0 00000000 00000000 
3ffeac00:  3fffdc20 00000000 3ffeac44 4020184a 
3ffeac10:  00000000 00000000 3ffe9c00 40100378 
<<<stack<<<

 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld


Connecting to WiFi
.............
WiFi connected
Server started
192.168.1.8
Door Position Changing


ESP8266 Arduino Code (CAUTION: MESSY):
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiUDP.h>

const char* ssid = "<WiFi Name Removed>";
const char* password = "<WiFi Password Removed>";

// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);
int timeout = 0;
String statusStr = "Open";
int doorStat = 1;

byte packetBuffer[512]; //buffer to hold incoming and outgoing packets

// A UDP instance to let us send and receive packets over UDP
WiFiUDP Udp;
IPAddress ham = IPAddress(192,168,1,10);


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

  // prepare GPIO2
  pinMode(12, OUTPUT);
  digitalWrite(12, LOW);
  pinMode(13, INPUT);
  pinMode(14, INPUT);
 
  // 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.println(WiFi.localIP());
}

void loop() {
  int runTime = millis();
  if (runTime % 300000 < 300)
  {
    Serial.print("Checking In ");
    Serial.println(runTime,DEC);
    alertMonitor(runTime);
    delay(300);
  }
  if (!digitalRead(13) && !(doorStat == 1)){
    statusStr = "Open";
    doorStat = 1;
    alertMonitor(2);
    Serial.println("Door Opened");
    delay(500);
  }
  if (!digitalRead(14) && !(doorStat == 0)) {
    statusStr = "Closed";
    doorStat = 0;
    Serial.println("Door Closed");
    alertMonitor(3);
    delay(500);
  }
  if (digitalRead(13) && digitalRead(14) && !(doorStat == -1)) {
    statusStr = "UNKNOWN/MOVING/PARTIALLY OPEN(OR PARTIALLY CLOSED DEPENDING ON YOUR PHILOSOPHICAL VIEWS";
    doorStat = -1;
    Serial.println("Door Position Changing");
    delay(500);
  }
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }
 
  // Wait until the client sends some data
  Serial.println("new client");
  int watchdog = 0;
  while(!client.available()){
    delay(1);
    watchdog += 1;
    if (watchdog > 5000) {
        Serial.println("Client Timeout");
        return;
    }
  }
 
  // Read the first line of the request
  String req = client.readStringUntil('\r');
  String s="";
  Serial.println(req);
  client.flush();
 
  // Match the request
  int val;
  if (req.indexOf("/activate") != -1){
    val = 1;
  }
  else{
    s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html><TITLE>Garage Door Control</TITLE><HEAD><META HTTP-EQUIV=\"REFRESH\" CONTENT=\"5\"></HEAD>\r\nDoor Status is " + statusStr;
    s += "<IFRAME name=iframe style=\"display:none\"></IFRAME>";
    s += "<br><form method=\"get\" action=\"/activate\" target=\"iframe\"><button type=\"submit\">Activate Door</button></form></html>\n";
    val = 0;
  }

  // Activate Door if requested
  Serial.print("VAL = ");
  Serial.println(val,DEC);
  if ((val > 0) && (millis() > (timeout + 5000))) {
    timeout = millis();
    digitalWrite(12, HIGH);
    alertMonitor(1);
    delay(750);
    digitalWrite(12, LOW);
    delay(1000);
  }
 
  client.flush();

  // Send the response to the client
  client.print(s);
  delay(1);
  Serial.println("Client disonnected");

  // The client will actually be disconnected
  // when the function returns and 'client' object is detroyed
}

void alertMonitor(int msg) {
  Udp.beginPacket(ham,2001);
  if (msg == 1)
  {
    Udp.write("Garage door triggered remotely");
  }
  else if (msg == 2)
  {
    Udp.write("Garage door Opened");
  }
  else if (msg == 3)
  {
    Udp.write("Garage door Closed");
  }
  else
  {
    Udp.write("Garage door Controller Checking In" + msg);
  }
  int ret = Udp.endPacket();
  if (ret == 1) {
    Serial.println("Alert Sent to HAM.");
  } else {
    Serial.println("Error Alerting HAM!");
  }
}


Schematic:
Image
https://onedrive.live.com/redir?resid=7064904358374137!3156&authkey=!AMU5c2a2j21b_5w&v=3&ithint=photo%2cpng
Last edited by Shadow351 on Mon Dec 07, 2015 11:19 pm, edited 2 times in total.
User avatar
By lethe
#36254 There's no flyback diode on your relay. You should not switch inductive loads without a flyback diode, since the back-EMF when turning off the relay may kill the transistor and/or other components in your circuit.
User avatar
By Timpanogos Slim
#36450 Lack of flyback diode is quite likely a major issue here.

The DC-DC converter would have probably been a switch-mode supply which may, depending on the design, be noisy enough to induce oscillation in the esp8266. Which would cause it to draw power like mad until it blows up.

You would need an oscilloscope to verify this -- potentially an oscilloscope with a real bandwidth greater than 10mhz (my "12mhz" HP does not qualify because it's really 6mhz + wishes and dreams) . I once beta tested a project with a high voltage supply that was popping transistors until someone determined that one of the FETs in the supply was squegging at about 93mhz and causing downstream parts to oscillate. This looked like random noise on my scope. i believe it was a 200mhz DSO that produced a perfect image of the problem waveform.

We know that the esp chips are sensitive to power supply noise. It may be a good idea to bypass your power supply electrolytics with 0.01uf ceramics. You might also add the optional 10uf cap from adjust to ground on the lm317.

lm317 needs a minimum headroom of 1.25v so 4.5v is marginal for a nominal 3.3v output, even though an unregulated 4.5v supply like the sony discman supplies of yore are putting out closer to 4.7v (I was messing with one just yesterday).

I've heard some argue that the lm317 prefers more like 1.7v of headroom. YAMMV. You could consider picking up some lm1117T-ADJ (or the fixed 3.3v version) to see if that works better, but i don't think the 317 itself or the power supply voltage is the problem, since the higher voltage pre-regulator supply didn't help.

I wouldn't worry about a 317 running hot unless there was insufficient room for a heatsink but i can understand it being an annoying factor in the design.