"Blynk.begin(auth, ssid, pass);" does not work and the device keep rebooting

Hi everyone for this community.

I’m trying to develop an IoT device that using Atom Lite from M5stack.
I want to control servo by wifi.

I use windows 10 and arduino IDE for developing.

The following is my sketch code.

#include "M5Atom.h"
#include "WiFi.h"
#include "BlynkSimpleEsp32.h"

const uint8_t Srv0 = 25;//GPIO No.
const uint8_t srv_CH0 = 0; //channel
const double PWM_Hz = 50;  
const uint8_t PWM_level = 16;

bool IMU6886Flag = false;

char auth[] = "***";
char ssid[] = "***";
char pass[] = "***";

void setup(){
    M5.begin(true, false, true); 
    delay(50);   //delay 50ms.
    M5.dis.drawpix(0, 0x00ff00); 

    pinMode(Srv0, OUTPUT);
    ledcSetup(srv_CH0, PWM_Hz, PWM_level);
    ledcAttachPin(Srv0, srv_CH0);

    //connectWiFi();
    Blynk.begin(auth, ssid, pass);
}

/*
void connectWiFi(){
  WiFi.disconnect(); // reset
  for (int i = 0; WiFi.status() != WL_CONNECTED; i++)
  {
    if (i % 10 == 0) {
      WiFi.begin(ssid, pass);
    }
    delay(1000); // wait a second for connection
  }
  M5.dis.drawpix(0, 0x0000f0);  //BLUE
}*/

BLYNK_WRITE(V0){
  int val = param[0].asInt();
  if(val == 0){
    M5.dis.drawpix(0, 0x00ff00);  //GREEN
    for (int i = 4900; i <= 8190; i=i+50) {  //500μsec -> 2500μsec 0deg -> 90deg
      ledcWrite(srv_CH0, i);
      delay(10);
    }
  }
  if(val == 1){
    M5.dis.drawpix(0, 0xff0000);  //RED
    for (int i = 8190; i > 4900; i=i-50) {   //2500μsec -> 500μsec 90deg -> -90deg
      ledcWrite(srv_CH0, i);
      delay(10);
    }
  }
}

uint8_t FSM = 0;     //Store the number of key presses.

void loop(){
  if (M5.Btn.wasPressed()){   //Check if the key is pressed.
    switch (FSM){
    case 0:
        M5.dis.drawpix(0, 0x00ff00);  //GREEN
        for (int i = 4900; i <= 8190; i=i+50) {  //500μsec -> 2500μsec 0deg -> 90deg
          ledcWrite(srv_CH0, i);
          delay(10);
        }
        break;
    case 1:
        M5.dis.drawpix(0, 0xff0000);  //RED
        for (int i = 8190; i > 4900; i=i-50) {   //2500μsec -> 500μsec 90deg -> -90deg
          ledcWrite(srv_CH0, i);
          delay(10);
        }
        break;
    default:
        break;
    }
    FSM++;
    if (FSM >= 2){
        FSM = 0;
    }
  }
  delay(50);
  M5.update();    //Read the press state of the key.
  Blynk.run();
}

I checked the device can connect to my wifi by “connectWiFi();”.
Also, when I commented out “Blynk.begin(auth, ssid, pass);” and “Blynk.run();” it work correctly, with pushing the physical buttun on the device.
However, when I add “Blynk.begin(auth, ssid, pass);” the device will not be online and keep rebooting with the error message below.

0:59:57.793 -> M5Atom initializing...OK
00:59:57.840 -> 
00:59:57.840 -> assert failed: xQueueSemaphoreTake queue.c:1545 (( pxQueue ))
00:59:57.840 -> 
00:59:57.840 -> 
00:59:57.840 -> Backtrace:0x4008385d:0x3ffb26100x4008bbf1:0x3ffb2630 0x40091095:0x3ffb2650 0x4008cba5:0x3ffb2780 0x400d3aac:0x3ffb27c0 0x400d3233:0x3ffb27f0 0x400d6c86:0x3ffb2820 
00:59:57.840 -> 
00:59:57.840 -> 
00:59:57.840 -> 
00:59:57.840 -> 
00:59:57.840 -> ELF file SHA256: 0000000000000000
00:59:57.886 -> 
00:59:57.886 -> Rebooting...
00:59:57.886 -> ets Jun  8 2016 00:22:57
00:59:57.886 -> 
00:59:57.886 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
00:59:57.886 -> configsip: 188777542, SPIWP:0xee
00:59:57.886 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
00:59:57.886 -> mode:DIO, clock div:1
00:59:57.886 -> load:0x3fff0030,len:1184
00:59:57.886 -> load:0x40078000,len:12804
00:59:57.886 -> ho 0 tail 12 room 4
00:59:57.886 -> load:0x40080400,len:3032
00:59:57.886 -> entry 0x400805e4

I tried both Blynk IoT and the Legacy, but the results was same.
I use 1.1.0 version Blynk Library.

I appreciate any advices, comments and helps. Thank you.

You should read this
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

1 Like

John,
Thanks for the advice.
I tried comment out in the void loop and changed like below, but the result didn’t change. (keep rebooting)

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

For additional explanation, I tried to controll the device on BLE with Blynk legacy, it worked properly.
It start reboot when I try “Blynk.begin(auth, ssid, pass);”

The ideal blynk void loop should look like this

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

and like this

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

When you use a timer.

Have you tried a different example ?

Legacy and Blynk iot don’t have the same library.
So if you are using Blynk iot library, you can’t connect to legacy server.

John,

thank you, I changed void loop only Blynk.run(); and timer.run();

also, I tried example code only and the device became online.

I tried to check which code is making crash and I found when I comment out the following code, It work well.
M5.dis.drawpix()

This code work for LED on the device.
Do you have any idea to use LED with blynk?
I have no idea why LED and blynk making conflict.

Blynk_Coeur,

Thank you, I didn’t know those are using different library.
Now I trying Blynk Iot and it worked well, but now I have another problem.

I tried to check which code is making crash and I found when I comment out the following code, It work well.
M5.dis.drawpix()

This code work for LED on the device.
Do you have any idea to use LED with blynk?
I have no idea why LED and blynk making conflict.

Would you like to control RGB led ?

John,

Yes sir, I want to check the servo state by LED color.

Regular RGB led ? like this

Ahh, I see. I didn’t have that idea. Thank you, Maybe it can be the solution.
However, I prefer not to use that yet. Because Atom Lite already have LED and I want make the architecture simple.

I’ve never used the Atom lite, but I guess you should use this library

Thank you John,

I didn’t change any codes, but after I installed the library, everything work perfectly!!!

Thank you very much, I really appreciate!!

1 Like