Everything is connected right.
I turned it on and i could detect ESP-01s on mylist of wifi networks “AI THINKER…”
ESP01S TX to Arduino Nano D2 (software RX)
ESP01S RX to Arduino Nano D3 (software DX)
i use following code on arduino and ESP-01S responded AT=OK…
and so on… Everything seems ok…
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
void setup()
{
Serial.begin(9600); // communication with the host computer
//Serial.begin(115200);
//while (!Serial) { ; }
// Start the software serial for communication with the ESP8266
//ESPserial.begin(9600);
ESPserial.begin(115200);
Serial.println("");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("Ready");
Serial.println("");
}
void loop()
{
// listen for communication from the ESP8266 and then write it to the serial monitor
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
// listen for user input and send it to the ESP8266
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}
Further more i create new project on blynk app on my phone,
Put button on it, select output D8, make mode Switch.
Atach led on Arduino Nano D8 and compile and run following code on arduino Nano.
#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[] = "my auth";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "my name of my wifi network";
char pass[] = "my wifi network password";
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
//SoftwareSerial ESPserial(2, 3); // RX | TX
SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
void setup()
{
// Debug console
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
}
void loop()
{
Blynk.run();
}
On serial monitor i get message that is connected to internet.
but in blynk app i get message: “device is offline”
So what am I doing wrong?
And one more thing after, compiling and running this blynk code on my Arduino Nano
I can not see anymore ESP-01S in my wifi network list…but ESP-01S still responds to AT comands
using first program…This happened to two different ESP-01S boards with 2 different adapters.
Whats going on,please help, i am confused and frustrated…
You will be, using a Nano and an ESP-01, nightmare connection method. Could have saved yourself a lot of hassle and money too with a plug and play ESP board like the “WeMos”.
An ESP8266 can have at least two WiFi modes… wherein it either broadcasts as an AP that you connect to, or connects as a client to a router. Some tend to start in AP mode so you can connect and setup your routers credentials, then reboot as a standalone dev board.
Or, as is most common for the the ESP-01, you reflash it with AT firmware and then in AT mode it acts as a simple WiFi to Serial adapter for use on the Arduinos, and only connects to the router (thus no broadcast).
Costas thank you for your very Helpful answer, can you offer some concrete answer how to get things running?
Yes i know i can use plentifull ESP8266 stand alone boards,but the thing is that i invest money and time to develop project - shield,where Arduino Nano is main CPU and controlling lots of electronic.
So i want to add wifi controlling feauture over the mobile phone, so Blynk solution seems like natural one… ofcourse if i use standalone ESP8266 boards i need to reconstruct shield pcb, and reconstruct lots of code from Nano to work on ESP8266 standalone board.
So now you understand why i chose ESP01…
So Gunner if I understood you, you suggest to flash ESP01s and see what happens?
Do you know where i can find latest working AT firmware for ESP-01S?
And is it the same for ESP-01 and ESP-01S?
No not really, sorry. Wouldn’t it be great to remotely update your project as you add new features with ESP OTA?
Don’t go flashing your ESP as the AT firmware that’s already on most of them should be tried first for the shield connection method. Just watch the default baud speeds though, set as 9600 crawler speed.
I use some ESP-01 with NANO, to speak with ESP over ARDUINO, i use this sketch :
/*Sketch to communicate With ESP-01*/
/*Pensez a changer @IP du Module dans le Sketch*/
//LIBRARIES
#include <SoftwareSerial.h> //WARNING : Support is not garuanted over 9600Bps
//DEFINE PIN
#define ESPSerialTx 5
#define ESPSerialRx 6
//OBJECTS
SoftwareSerial ESPSerial(ESPSerialTx, ESPSerialRx); // RX, TX of ARDUINO
void setup()
{
Serial.begin(9600);
while (!Serial);
ESPSerial.begin(115200);
while (!ESPSerial);
Serial.println("CHANGE BAUDRATE 9600, NO PARITY, NO FLUX CONTROL");
ESPSerial.println("AT+UART_DEF=9600,8,1,0,0"); // Change the baudrate to 9600, no parity, no flux control
delay(250);
ESPSerial.begin(9600);
while (!ESPSerial);
/*AUTOCONNECT*/
//Serial.println("AUTO CONNECT OFF");
//ESPSerial.println("AT+CWAUTOCONN=0");
//delay(250);
/*SET STATION MODE*/
//Serial.println("SET STATION MODE");
//ESPSerial.println("AT+CWMODE_DEF=1");
//delay(250);
/*DISCONNECT*/
//Serial.println("IF CONNECTED ----> DISCONNECT");
//ESPSerial.println("AT+CWQAP");
//delay(250);
/*SET IP, GATEWAY and MASK*/
//Serial.println("SET IP, GATEWAY AND MASK");
//ESPSerial.println("AT+CIPSTA_DEF=\"000.000.000.000\",\"000.000.000.000\",\"000.000.000.000\"");
//delay(250);*/
}
void loop()
{
if(ESPSerial.available()) // If the ESP sent any characters
{
// Send any characters the ESP prints to the serial monitor
Serial.print((char)ESPSerial.read());
}
if(Serial.available()) // If stuff was typed in the serial monitor
{
// Send any characters the Serial monitor prints to the ESP
ESPSerial.print((char)Serial.read());
}
// and loop forever and ever!
}
For your Blynk sketch, i think ESPSerial speed is set too high. For SofwareSerial librarie the max without errors is 9600bps
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
//LIBRARIES
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "*****************************************************";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "************";
char pass[] = "**************";
//ESP8266 WiFi OBJECTS
SoftwareSerial ESPSerial (5, 6); //RX, TX
ESP8266 wifi(&ESPSerial); //Use EspSerial to communicate with ESP8266
void setup() {
Serial.begin(9600); // Init Debug console
while (!Serial); //Wait for Serial ready
ESPSerial.begin(9600); // Init Serial with Wifi Shield
while (!ESPSerial); //Wait for EspSerial ready
/*BEGIN Blynk*/
Blynk.begin(auth, wifi, ssid, pass); //Connect to blynk server
}
/*MAIN LOOP*/
void loop() {
/*RUN BLYNK*/
Blynk.run();
}
So i did some experiments…
I change code and i Can definitely confirm that AT commands works.
For AT i got OK
For AT+CWMODE=1 i lose ESP from wifi list
For AT+CWMODE=2 i get ESP on wifi list
For AT+CWMODE? i get righ mode
and so on…
Interesting when i change CWMODE-s ESP remember it after cuting of power and starting again.
I did not change firmware yet.
I set CWMODE=1 and when i start serial monitor i get following:
Two people have told you that this is too high and that you should be using 9600.
The ESP also needs to be told to receive/send data at 9600, via an AT command. This should only need to be done once, the ESP baud rate change will persist after a reboot.
Ok. I done following:
1.I change Baud rate to 9600 with AT+UART_DEF=9600,8,1,0,0
2.In code I change software serial baud rate to 9600 and test with AT commands, it worked perfectly and more stable.
3. I change software serial baud rate to 9600 in blynk sketch and test it.
And now i only get followingafter reseting Arduino or power off/on:
[19]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
///_, /////_
/__/ v0.4.10 on Arduino Nano
[605] Connecting to MyNetwork
[3814] AT version:1.2.0.0(Jul 1 2016 20:04:45)
SDK version:1.5.4.1(39cb9a32)
Ai-Thinker Technology Co. Ltd.
Dec 2 2016 14:21:16
OK
[14008] Failed to connect WiFi
----------
[14014] Failed to connect WiFi
[14008] Failed to connect WiFi
[14015] Failed to connect WiFi
[14008] Failed to connect WiFi
[14009] Failed to connect WiFi
[14009] Failed to connect WiFi
[14014] Failed to connect WiFi
[14007] Failed to connect WiFi
[14008] Failed to connect WiFi
[] are those numbers in brackets some kind of error codes?
Any ideas how to get this running?
Verify your SSID and password, if it’s ok you can :
1-Try to reset your ESP : AT+RESTORE,
2-After fix speed : AT+UART_DEF=9600,8,1,0,0
3-You can fix ESP in station mode : AT+CWMODE_DEF=1
4-And try to fix IP, GATEWAY and MASK : AT+CIPSTA_DEF=“192.168.6.100”,“192.168.6.1”,“255.255.255.0”
When your use AT+CIPSTA_DEF you need to enter an IP, GATEWAY and MASK. Verify with “AT+CIPSTA_DEF?” there are all ok. Disable DHCP is not useful when you set an address with AT+CIPSTA_DEF.
This configuration will store in Flash user parameter area.
This configuration interacts with DHCP related AT commands (AT+CWDHCP related):
•If enable static IP, DHCP will be disabled;
•If enable DHCP, static IP will be disabled;
•This will depend on the last configuration.
[19]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
///_, /////_
/__/ v0.4.10 on Arduino Nano
[605] Connecting to MyNetwork
[3815] AT version:1.2.0.0(Jul 1 2016 20:04:45)
SDK version:1.5.4.1(39cb9a32)
Ai-Thinker Technology Co. Ltd.
Dec 2 2016 14:21:16
OK
[4915] Failed to enable MUX
[8111] +CIFSR:STAIP,“192.168.1.100”
+CIFSR:STAMAC,“dc:4f:22:0a:0b:23”
[8119] Connected to WiFi
[18550] Ready (ping: 38ms).
And example with turning led on/of works…nice
But what this mean “[4915] Failed to enable MUX” ?
Is there any waythat IP,Gateway and Mask can be obtained automatically?
For example i make some project but my “Default Gateway” is not the same every time,
or i want to connect my project to another WiFi network(assuming same nameand password) with another Gateway…
Generally the gateway of your local network should not move. Often this is the IP address used to access the administration of your router, which often acts as a DHCP server. In your case certainly 192.168.1.1 or 192.168.1.254
The error “Failed to enable MUX” can happen at the start.