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.