Cyclic reboot ESP-01s with Blynk library

Hey.
Trying to use the ESP-01C relay.

  1. After a reboot, the relay constantly turns on. You have to press the button in the application on the phone a couple of times to turn it off. Tried to set a high level:
pinMode (0, OUTPUT);

Blynk.begin (auth, ssid, pass, IPAddress (192,168,3,10), 8080);

digitalWrite (0, HIGH);
  • received a cyclic reboot.
  1. Connected Si7021 sensor
void setup ()
{
   Serial.begin (9600);
Blynk.begin (auth, ssid, pass, IPAddress (192,168,3,10), 8080);

 Wire.begin (1, 3);
}

void loop ()
{
  Blynk.run ();
zaprosTempVlaga ();
sendTempVlagaToBlynk ();
}
void zaprosTempVlaga()
{
 unsigned int data[2];

  Wire.beginTransmission(si7021Addr);
  //Send humidity measurement command
 
  Wire.write(0xF5);
  Wire.endTransmission();
  delay(500);

  // Request 2 bytes of data
  Wire.requestFrom(si7021Addr, 2);
  // Read 2 bytes of data to get humidity
  if(Wire.available() == 2)
  {
    data[0] = Wire.read();
    data[1] = Wire.read();
  }

  // Convert the data
  humidity  = ((data[0] * 256.0) + data[1]);
  humidity = ((125 * humidity) / 65536.0) - 6;
 
  Wire.beginTransmission(si7021Addr);
  // Send temperature measurement command
  Wire.write(0xF3);
  Wire.endTransmission();
  delay(200);

  // Request 2 bytes of data
  Wire.requestFrom(si7021Addr, 2);

  // Read 2 bytes of data for temperature
  if(Wire.available() == 2)
  {
    data[0] = Wire.read();
    data[1] = Wire.read();
  }

  // Convert the data
  float temp  = ((data[0] * 256.0) + data[1]);
  celsTemp = ((175.72 * temp) / 65536.0) - 46.85;
 }
void sendTempVlagaToBlynk()
{
  Blynk.virtualWrite(V0, celsTemp);
  Blynk.virtualWrite(V1, humidity);
}
  • received a cyclic reboot.

If I make a comment

//Blynk.begin(auth, ssid, pass, IPAddress (192,168,3,10), 8080);

then everything works fine.

The local server has been working for a long time without problems with NodeMCU.
Any ideas?

You shouldn’t be calling these functions from your void loop, and you shouldn’t have the delays within the functions…

Resd this to understand why, and what to do about it…
http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/keep-your-void-loop-clean

Are you controlling your relay with a widget connected to pin D0?
If so then I’d suggest you use a virtual pin, and change your code accordingly.

Also, it seems that you are utilising pins 0 & 3 (Tx & Rx) for your I2C and serial data, which won’t work. I’d remove the…

Iine, and any references to Serial in the code that you’ve not included.

Pete.

Hey.
Thanks for the answer.

I followed your recommendations, but nothing worked.

If the code is simple:

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth [] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxHhL";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid [] = "KAN";
char pass [] = "xxxxxxxxx";




void setup ()
{
  // Debug console
  Serial.begin (9600);


  Blynk.begin (auth, ssid, pass, IPAddress (192,168,3,10), 8080);
 
}

void loop ()
{
  Blynk.run ();
}

then everything works:

Serial:
11: 59: 47.195 → [3565] Connected to WiFi
11: 59: 47.195 → [3565] IP: 192.168.2.31
11: 59: 47.229 → [3565]
11: 59: 47.229 → ___ __ __
11: 59: 47.263 → / ) / / _ _____ / / __
11: 59: 47.297 → / _ / / // / _ \ / ’
/
11: 59: 47.331 → / ____ / _ / \ _, / _ // _ / _ / \ _
11: 59: 47.365 → / ___ / v0.6.1 on ESP8266
11: 59: 47.399 →
11: 59: 47.399 → [3641] Connecting to 192.168.3.10
11: 59: 47.433 → [3708] Ready (ping: 18ms).

But after a reboot, the relay goes into an on state.

If I add the code:

BLYNK_WRITE (V3)
{
  bool buttonBlynk = param.asInt ();
  
  if (buttonBlynk == HIGH)
{
 digitalWrite (0, LOW); // low level reley
 }
 else
{
 digitalWrite (0, HIGH);

}
  
}

then cyclic reboot:

Serial:
12:12:36.637 → epc1=0x4010083⸮Ȥl⸮⸮⸮l$⸮lb8I⸮⸮[61] Connecting to KAN
12:12:36.807 →
12:12:36.807 → Exception (3):
12:12:36.841 → epc1=0x40100830 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4006f179 depc=0x00000000
12:12:36.909 →
12:12:36.909 → >>>stack>>>
12:12:36.943 →
12:12:36.943 → ctx: cont
12:12:36.943 → sp: 3ffffb50 end: 3fffffc0 offset: 01a0
12:12:36.977 → 3ffffcf0: 3ffe8fe0 40104baf 3ffef724 feefeffe
12:12:37.044 → 3ffffd00: 00000001 40103d8a 3ffed160 3ffffeb0
12:12:37.078 → 3ffffd10: 0000049c 0000049c 00000020 40100a20
12:12:37.146 → 3ffffd20: feefeffe feefeffe feefeffe feefeffe
12:12:37.214 → 3ffffd30: 00000000 400042db 000000fd 40100c78
12:12:37.248 → 3ffffd40: 40004b31 00001000 000000fd 40100394
12:12:37.316 → 3ffffd50: 4010602c 00080000 feefeffe 40230049
12:12:37.350 → 3ffffd60: 401001cd 40230133 3ffef914 0000049c
12:12:37.419 → 3ffffd70: 000000fd 3ffffeb0 3ffef914 40230116
12:12:37.453 → 3ffffd80: ffffff00 55aa55aa 00000010 00000020
12:12:37.521 → 3ffffd90: 00000020 00000061 00000061 aa55aa55
12:12:37.555 → 3ffffda0: 000000ff 40230616 3ffef914 3ffef914
12:12:37.623 → 3ffffdb0: 000000ff 000000f2 000000f2 40100760
12:12:37.623 → 3ffffdc0: 401001cd 00000001 3ffef924 40230836
12:12:37.691 → 3ffffdd0: 00000005 3ffef914 000000ff 3ffffeb0
12:12:37.725 → 3ffffde0: 3ffffed0 3ffef94b 00000010 00000020
12:12:37.797 → 3ffffdf0: 3ffef9d4 3fffff11 00000001 402308e6
12:12:37.831 → 3ffffe00: 3ffffeb0 4023bea0 00000000 00000008
12:12:37.902 → 3ffffe10: 3ffefd14 3ffffed0 3fff5c4c 402308b5
12:12:37.936 → 3ffffe20: 3ffef914 4023091c 3ffe84fa 3ffe84d5
12:12:38.004 → 3ffffe30: 40202926 3ffe84d5 3ffe84cc 4020287b
12:12:38.072 → 3ffffe40: 004e414b 000000f2 000000f2 40100760
12:12:38.106 → 3ffffe50: 00000000 4bc6a7f0 3ffef914 3ffe84cc
12:12:38.174 → 3ffffe60: 37303431 34373931 00000000 401009eb
12:12:38.208 → 3ffffe70: 00000020 00000061 00000061 aa55aa55
12:12:38.276 → 3ffffe80: 000000fd 4022fcc3 00000000 401003a4
12:12:38.310 → 3ffffe90: 3ffe84fa 3ffee960 3ffe87a0 4022fcde
12:12:38.378 → 3ffffea0: 84e9c400 3f2ce396 3ffffede 4020395d
12:12:38.412 → 3ffffeb0: 004e414b 000000f2 000000f2 40100760
12:12:38.483 → 3ffffec0: 00000000 4bc6a7f0 3ffef914 3ffe84cc
12:12:38.517 → 3ffffed0: 37303431 34373931 00000000 401009eb
12:12:38.558 → 3ffffee0: 00000020 00000061 00000061 aa55aa55
12:12:38.592 → 3ffffef0: 000000fd 4022fcfb 00000000 401003a4
12:12:38.660 → 3fffff00: 3ffe84fa 3ffee960 3ffe87a0 4022fd16
12:12:38.694 → 3fffff10: 4022fd00 3ffee960 3ffee981 00000002
12:12:38.766 → 3fffff20: 00000004 00000000 3ffee928 00000001
12:12:38.834 → 3fffff30: 3ffef2bc 40202790 3ffee960 3ffe84cc
12:12:38.868 → 3fffff40: 3ffe84d5 3ffee928 3ffee960 402011a4
12:12:38.936 → 3fffff50: 00000000 feefeffe feefeffe feefeffe
12:12:38.970 → 3fffff60: 00002580 0000001c 00000000 3ffeea8c
12:12:39.038 → 3fffff70: 3fffdad0 3ffee960 3ffee8d8 40201ee4
12:12:39.072 → 3fffff80: feefeffe feefeffe feefeffe feefeffe
12:12:39.141 → 3fffff90: 40205f80 0a03a8c0 feefeffe feefeffe
12:12:39.175 → 3fffffa0: 3fffdad0 00000000 3ffeea4c 40204250
12:12:39.251 → 3fffffb0: feefeffe feefeffe 3ffe851c 40100cad
12:12:39.287 → <<<stack<<<
12:12:39.287 → H!⸮⸮L⸮⸮D⸮⸮⸮[61] Connecting to KAN
12:12:39.398 →
12:12:39.398 → Exception (3):
12:12:39.438 → epc1=0x40100830 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4006f179 depc=0x00000000
12:12:39.506 →
12:12:39.506 → >>>stac

server-0.41.12-java8.jar
Raspberry PI B
Blynk library versions 0.6.1

What’s my mistake?

BLYNK_CONNECTED() {
  if (isFirstConnect) {
Blynk.virtualWrite(V3, HIGH); // change this according to your need Active low or Active high relay
//Blynk.syncVirtual(V3); // or use this to retrieve the last state of the relay.
    isFirstConnect = false;
  } else {
    Blynk.virtualWrite(V3, HIGH);
    Serial.println("updated relayState");
  }
  Serial.println("Connected");
  ReCnctCount = 0;
  Blynk.syncVirtual(V3);
//OR
// Blynk.virtualWrite(V3, HIGH); // change this according to your need Active low or Active high relay
}

As I’ve previously said, I don’t understand how you can use pin 0 for Serial Tx and I2C communication.
Also, as your relay isn’t connected directly to GPIO0, but instead sits on the I2C bus, I don’t understand what you expect to achieve using digitalWrite (0, LOW);

I’m also don’t understand how our device on 192.168.2.31 can see your Blynk server on 192.168.3.10 as they are on different subnets.

Popping your code into the Arduino IDE and compiling it, then putting your stack dump into the Exception Decoder produces a number of references to system_overclock. This might be normal, but may also be caused by you choosing CPU and Chrystal frequencies that are too high…

system_overclock at ?? line ?
system_restoreclock at ?? line ?
system_overclock at ?? line ?

Pete.

2 Likes

GPIO0 must be grounded to get into programming mode, so maybe it is the cause of the exception 3 issue whan you write 0 to GPIO :thinking:

I replied for this problem. To sync the relay state.
But as you said GPIO0 is for entering programming mode. Playing with that will result in crashes.

But once the board is booted it should not affect right ? Pulling down GPIO0 at startup will enter programming mode, else later on that should not matter i guess. Correct me if i am wrong.

I don’t know, I never used esp-01.
Maybe you are right.
I use esp8266 nodemcu , but nothing is connected to gpio 0 to avoid issue when MCU reset for unknown reason.

1 Like