[SOLVED] Arduino + ESP8266 ESP-01(AI-Cloud, Black Version)

Hi All

I’ve been with Blynk from the kickstarter stage and it look great. Also I’ve been looking through the site for a solution but haven’t been able to find a solution to my problem.

I’ve flashed the firmware of the ESP-01 to one that is compatible with the Arduino and it looks like it makes it part of the way to connecting. (I have attached the output from 2 different firmware’s I have tried one early one one newer, I’ve flashed almost all the firmware’s i could find to see if anything will work)

I keep getting the following errors.

[14635] Failed to enable MUX
[15646] Failed to set STA mode

I’ve done a search and i didn’t come across these errors is anyone able to tell me whats going on.

---- Additional information
Serial Type from Arduino to ESP-01: Software
Firmware type Flashed: BOOT MODE, Flash size 8Mbit: 512KB+512KB

----- Error log 1


/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.4 on Arduino Uno

[591] Connecting to pkgspt
[13612] AT vession:0.25.0/0(Jun 5 2005 16:27:16(
SDK version:1.1.1
Ai,
[14635] Failed to enable MUX
[15646] Failed to set STA mode

---- Error Log 2
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.4 on Arduino Uno

[591] Connecting to pkgspt
[13612] AT vession:1.1.0.0(May 11 2017 18:09:56)
SDK versioo:1.5.4(baae`i

[14635] Failed to enable MUX
[14649] Failed to set STA mode

@dwadia I didn’t know that there was an SDK dating back to 2005! I wouldn’t bother with that one.
Are you able to successfully send AT commands to the ESP?

I’m not a fan of that device but the following commands might help:

AT+CWMODE=3      // sets the ESP01 to have both AP and Station mode
AT+CIPMUX=1        // sets the ESP01 to have up to 4 simultaneous connections
1 Like

Thanks for the help @Costas

I connected to the esp-01 via serial and was able to connect. to my wifi network.

This being the case i’m still getting the following error message on the arduino project serial output
[14648] Failed to set STA mode

This being the case this may be something on the Blynk or arduino libraries for the TA commands to the ESP-01
(I’m just using the BlynkBlynk arduino code example from the blynk example builder )

Any ideas whats going on?

-------Serial log
ready
AT+CWMODE=3

OK
AT+CIPMUX=1

OK
AT+GMR
AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
compile time:May 20 2016 15:06:44
OK
AT+CWLAP
+CWLAP:(3,"ssid info)
+CWLAP:(4,ssid info)
+CWLAP:(4,ssid info)
+CWLAP:(3,ssid info)

OK
AT+CWJAP=“SSID”,“PWD”
WIFI CONNECTED
WIFI GOT IP

–Arduino error log

___  __          __

/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.4 on Arduino Uno

[591] Connecting to pkgspt
[13612] AT vdrsion:1.1.0.0(May 11 2016 18:09:56(
SDK version:1.5.4(baada2
[14646] Failed to set STA mode
[37916] Login timeout
[47313] Invalid auth token
[53327] Invalid auth token
[70744] Invalid auth token
[96850] Invalid auth token
[128614] Invalid auth token
[134641] Invalid auth token
[146309] Invalid auth token
[203083] Login timeout

That looks VERY promising. You only get that error message when you have accessed the Blynk server.

Somewhere you have messed up the tokens. What I would do is grab another token from the app and reflash your hardware with it. See how that goes.

Thanks, I fixed that problem i’m running a local Blynk server so i just needed to point it to the server.

However i noticed that the hardware will connect and then it will drop off.

---- Arduino Serial log


/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.4 on Arduino Uno

[591] Connecting to W_NETWORK
[13612] AT wersion:1.1.0.0(May 11 2016 18:09:56(
SDK vershon:1.5.4(ba`eaa¢
[19696] +CIFSR:ST@IP,“192.168/1.240”
+CHFSR:STAMAC,#5c:cf:7f:82;b5:73"

[19707] Connected to WiFi
[29828] Ready (ping: 12ms).
[39851] Login timeout
[54950] Ready (ping: 13ms).
[64972] Login timeout
[80073] Ready (ping: 12ms).
[90095] Login timeout

— Blynk server log

2017-02-03 23:52:53.701 INFO  - xxxxx  hardware joined.
2017-02-03 23:53:09.857 INFO  - xxxxx  Blynk-app joined.
2017-02-03 23:53:18.795 INFO  - xxxxx  hardware joined.
2017-02-03 23:53:28.848 INFO  - xxxxx  hardware joined.
2017-02-03 23:53:38.904 INFO  - xxxxx  hardware joined.

I’m using the latest blynk server as well.

@dwadia can I see your sketch?

How are you powering the ESP?
The Uno doesn’t give enough power to run an ESP.

Hi

ESP is powered through a 3.3v Regulator(2 x 220uF filters caps in parallel on the 3.3v power line) connected to a 5V power supply that is used for the Aurduio. %v power supply is from a battery pack that has a step down and power cleaning voltage regulator.

I’m also thinking that i may try setting up the wireless on raspberry Pi 3 as an adhoc network and connect directly to the Raspberry Pi that is running the Blynk server.

----Arduino code

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>


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

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

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(6, 5); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

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

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  //Blynk.begin(auth, wifi, ssid, pass);
  Blynk.begin(auth, wifi, ssid, pass,"192.168.001.190");
  
}

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

Hi @Costas

I set up the ad-hock connection between the PI(blynk server) and the hardware and there was no change to the disconnection / re-connection error.

Ran the full project of battery power and still didn’t change the problem.

As you can see in the loop is only have the Blynk.run() command so i don’t know whats going on.

Should be no power problem the 5v step down is rated at 3Amps & the 3.3v regulator is rated at 800mA (i’m thinking this should be more than enough to run the WiFi peek power consumption is 300mA as per the data sheet).

Any help would be greatly appreciated.

Try 192.168.1.190. If that fails cut and paste your Serial Monitor.

Hi @Costas

Unfortunately no luck, I also changed the ip address to connect to my ad-hock wifi but this didn’t work either.

---- Server Log
2017-02-05 23:18:10.317 INFO - HTTPS Admin UI server listening at 7444 port.
2017-02-05 23:18:10.318 INFO - Web Sockets server listening at 8082 port.
2017-02-05 23:18:10.320 INFO - Web SSL Sockets server listening at 8081 port.
2017-02-05 23:18:10.321 INFO - Mqtt hardware server listening at 8440 port.
2017-02-05 23:26:57.412 INFO - XXXXXX hardware joined.
2017-02-05 23:27:12.330 INFO - XXXXXX hardware joined.
2017-02-05 23:27:37.434 INFO - XXXXXX hardware joined.
2017-02-05 23:28:02.533 INFO - XXXXXX hardware joined.
2017-02-05 23:28:12.595 INFO - XXXXXX hardware joined.
2017-02-05 23:28:22.650 INFO - XXXXXX hardware joined.
2017-02-05 23:28:32.736 INFO - XXXXXX hardware joined.

–Serial Output
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.4 on Arduino Uno

[591] Connecting to RPIBy
[13612] AT wersion:1.1.0.0(May 11 2016 18:09:57)
SDK vershon:1.5.4(ba`ea0
[18709] +CIFSR:ST@IP,"10.0.0.4"
+CIFSR:STAMAC,"5c:cg:7f:82:b5:73"
[18713] Connected to WiFi
[38961] Ready (ping: 44ms).
[48983] Login timeout
[64093] Ready (ping: 20ms).
[74115] Login timeout
[184901] Ready (ping: 15ms).
[194923] Login timeout
[210029] Ready (ping: 16ms).
[220051] Login timeout
[235174] Ready (ping: 12ms).
[245196] Login timeout
[271314] Ready (ping: 15ms).
[281336] Login timeout
[296442] Ready (ping: 15ms).
[306464] Login timeout
[368871] Login timeout
[528011] Ready (ping: 16ms).
[538033] Login timeout

-----Updated code.

#define BLYNK_PRINT Serial


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

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

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

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(6, 5); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

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

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  //Blynk.begin(auth, wifi, ssid, pass);
  // You can also specify server:
  Blynk.begin(auth, wifi, ssid, pass,"10.0.0.5");
  
}

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

@dwadia did you create a new account on your local server and include the NEW token in your sketch?

I didn’t create a new user after i upgraded version’s will try that an see what happens.

Thanks for all the help with this, it’s much appreciated.

Hi @Costas

I created a new user account and a new token. But no luck with the issue.

Also enable debug output, output below.

[9] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.4 on Arduino Uno

[93] Free RAM: 1217
[613] Connecting to RPIBy
[13636] AT vdrsion:1.1.0.0(May 11 2016 18:09:56(
SDK version:1.5.4(baada 1,CLOSDD

[18745] +CIFSR:ST@IP,"10.0.0.4"
+CIFSR:STAMAC,"5c:cg:7f:82:b5:73"
[18749] Connected to WiFi
[28825] <[02|00|01|00] 1a79fdbf7dc649eba1794e26a356738b
[38852] Cmd error
[53910] <[02|00|01|00] 1a79fdbf7dc649eba1794e26a356738b
[58923] Cmd error
[73980] <[02|00|01|00] 1a79fdbf7dc649eba1794e26a356738b
[84007] Cmd error
[94067] <[02|00|01|00] 1a79fdbf7dc649eba1794e26a356738b
[104095] Cmd error
[114157] <[02|00|01|00] 1a79fdbf7dc649eba1794e26a356738b
[119169] Cmd error
[134226] <[02|00|01|00] 1a79fdbf7dc649eba1794e26a356738b
[139238] Cmd error
[154296] <[02|00|01|00] 1a79fdbf7dc649eba1794e26a356738b
[159308] Cmd error
[174365] <[02|00|01|00] 1a79fdbf7dc649eba1794e26a356738b
[174414] >[00|00|01|00|C8]
[174414] Ready (ping: 14ms).
[174419] <[11|00|01|00]fver[00]0.4.4[00]h-beat[00]10[00]buff-in[00]256[00]dev
[174571] <[00]Arduino Uno[00]cpu[00]ATmega328P[00]con[00]ESP8266[00]
[179587] Cmd error
[184598] Login timeout

@dwadia “Cmd error” is right up there with the “Failed to disable Echo” error messages.

I would drop the 115200 baud rate right down to 9600 for the “Shield” connection method.
115200 is fine for “Standalone” but not shield.

Do you know what baud rate your ESP is set at in the firmware (not in the sketch)? You can find out by sending AT commands to the ESP.

Take a look at this cmd error thread Repeatedly receiving "Cmd error" even with simplest examples

For that Blynker it was a bad router and his system worked fine at a friends house.

I think you might have tried with the Pi as an AP but you could also try your Smartphone AP to see if it helps.

You can also search for all the other “cmd error” threads to see if any of them help.

Please keep us updated with your progress.

1 Like

The esp is set to 115200 in the firmware i’ll drop the baud rate tonight and see what happens. I can also try a few other AP solutions and see what happens.

Thanks for all the help. I’ll keep you update as to what happens.

99% sure it’s the baudrate. It’s just too fast to handle for the SoftwareSerial library :slight_smile:

2 Likes

@dwadia the standard shield sketch shows a rate of 115200 but if you study the sketch including the notes then you will work out that this is just for Hardware Serial (Mega, Leonardo etc).

Following the url link in the sketch takes you to this excellent page for AT set up https://github.com/blynkkk/blynk-library/wiki/ESP8266-with-AT-firmware

It is quite clear that the baud for Software Serial (Nano and Uno’s etc) must be 9600. Well worth looking through Blynk’s AT set up guide and the page they link to by fellow Blynker @Rom3oDelta7 at Solved disconnect/cmd skipped etc issues. My advice

ESP’s come preconfigured to various baud rates and it’s quite common for them to be 115200 but you can’t use this as a shield for Nano’s and Uno’s. Blynk’s AT page gives details of how you make the change.

1 Like

Hi All.

Ok It looks like it reliably works when you set the baud rate to 19200 for the esp.

The steps i did to get everything work are ass follows.
1.) Flash AT Firmware to esp-01 (Flash Profile i used marked as : Flash size 16Mbit: 512KB+512KB)
2.) Start serial interface on relevant com port at 115200, 8,1,N,N
3.) issue AT command “AT+CWMODE=3” (in putty yo have to press enter then CTRL+J"
4.) Issue AT command “AT+CIPMUX=1”
5.) restart ESP-01
6.) change baud rate with either command “AT+UART_DEF=19200,8,1,0,0” or “AT+IPR=19200”, Only one of them will work.
7.)Make sure that Arduino has the correct baud rate for the ESP-01.

Also to help others out in the future i’ve created the following repository with the firmware, programming tool, instructions, and settings to get the ESP-01 working.
Firmware ESP-01 ESP8266 AI-Cloud Black

3 Likes

Thank you @Costas & @Lichtsignaal for all the help. :+1: