Software Serial Esp8266 At Commands

Posted on by admin
Software Serial Esp8266 At Commands 5,9/10 5924 reviews

We have recently started a new kickstarter for a Grove connector based Lightning Detector Board based on the AS3935 lightning detection chip. Download game offline gratis untuk pc. Since we have now finished the code getting our Mini Pro LP Arduino board to work with the Grove Serial ESP8266 WiFi, we felt we should explain how we got one of the hardest parts of the design to work.

GOAL From Arduino UNO, send AT commands to ESP8266 via a SoftwareSerial port and receive results. CURRENT STATUS I either send AT commands and get nothing back (wiring scheme 1) or I send AT com. Serial-to-WiFi Tutorial using ESP8266. The module accepts commands via a simple serial. This would help if the board is stuck on some command. Software and.

The Thunder Board Kickstarter

Go to Kickstarter

Checkout the ThunderBoard Kickstarter

AT commands go way back. The AT command set is a specific command language originally developed by Dennis Hayes for the Hayes Smartmodem (300 baud) in 1981! The command set consists of a series of short text strings which combine together to control complex behavior. The vast majority of dial up modems used this command set or similar extensions.

Forward to 2017. A version of the AT command set is used by the ESP8266 to control the WiFi functions on the chip.

Hint: One thing to remember is that the AT command set requires both a return and a ctrl-j (rn) to complete a command.

Here are two equally useful references to the AT command set used by the ESP8266: room 15 and pridopia.

Getting the ESP8266 WiFi to work with an Arduino

Esp8266

The Arduino ThunderBoard IOT project is lightning detector project designed to both provide a local display giving alerts about Lightning while also using MQTT to send data up to an Internet Dashboard at PubNub/Freeboard. More on how to do that in a later posting.

We are using an ESP8266 WiFi board with a Grove connector in the ThunderBoard IOT project.

The processor in the Arduino ThunderBoard IOT project is a Mini Pro LP Arduino which contains a 16MHz ATMega328p AVR processor (same processor as on the Arduino Uno R3 board, but with a low power mode and Grove connectors).

The ThunderBoard Lightning Detector came up pretty quickly, however connecting the WiFi to our local access point and sending the MQTT JSON data across the Internet was another story. The Software Serial connection to the ESP8266 at 115200 baud (the default for the Wifi unit) was very unreliable and just wouldn’t connect in any kind of a consistent fashion. After quite a bit of experimenting we determined the software serial port just wouldn’t connect well at any baud rate above about 34000. Looking at the problem, we realized that having a hardware serial port (the debug and programming port) running at 115200 baud and the software serial port running at 115200 baud was just to fast for the Arduino 328P to make a solid connection. The hardware serial port puts a minimal load on the CPU, but the software serial port uses a lot of CPU cycles because you are basically bit banging the bits in and out with timing loops.

We solved this after more experimenting by changing the baud rate into the ESP8266 to 19200 and then the connection was solid. We spent a lot of time looking at different ways of programming the baud rate (some that would brick the ESP8266) and finally settled upon the code “AT+UART_DEF=19200,8,1,0,0”. After resetting the Software Serial port to 19200, we were ready to go.

The Example Code

Here is the sample code from our Arduino ThunderBoard IOT project that shows how we do it.

The library we used for the main connection was WiFiEsp and can be found on GitHub.

ESP8266 WiFi module (or shield) with default AT firmware can be used to connect your hardware to Blynk.

ESP8266 Shields

These come in different shapes and colors, but basically you can use simple ESP01 module like this:

At Commands Esp8266

If you have an Arduino Shield with ESP8266 (like doit.com ESP13 Shield), you don't need to do this wiring - that is already done for you!

☝️ This connection type is very tricky to start with. As a MUCH easier option, we recommend to start with ESP8266 as a standalone platform (Blynk can run directly on ESP8266 chip).

☝️ This method does not work with this Arduino UNO WIFI board (at least until Arduino provides proper TCP libraries).

---

First of all, it is recommended to buy a USB-UART TTL converter, capable to supply 1A @ 3.3V. This will help you in lots of different cases, not only for ESP8266. For ESP8266, it will be needed for initial configuration and testing, AT firmware upgrade, etc.

☝️ If you run ESP8266-standalone example on your ESP8266 module, it overwrites AT firmware of the module, so it won't work as modem. Make sure your ESP is flashed with AT firmware (you can find stable firmware here, flash it to 0x00000 using this guide for example).

For this connection, Blynk uses ESP8266_Lib.h library, which you get automatically when you install Blynk libraries.

Getting Started

  1. Check that your ESP8266 module is powered correctly and turned on
  2. Ensure a stable serial connection to ESP8266
  3. Use your USB-UART TTL converter, or this sketch to access AT command console
  4. Update your ESP to the latest firmware, if needed (AT v1.1.0.0 is recommended)
  5. Remember which Software Serial pins (or Hardware Serial#) and baud rate work for your module.
  6. Use Blynk -> Boards_WiFi -> ESP8266_Shield example with the same Serial configuration.
  7. In Blynk App, select the Board type of your main board, to which ESP8266 is connected (Uno, Mega, etc)

Software Serial

When using Software Serial - you have to switch ESP8266 to baud rate 9600.
Send this AT command to ESP8266:

or, for some versions:

It should reply OK.

Troubleshooting

  • Failing to read the comments in the sketch and amending it accordingly for the specific hardware.
  • Powering ESP8266 from 3v3 pin on Arduino UNO/Nano/Mega most likely won't work.
  • Use a separate 3.3V source, that can provide up to 1A, like AMS1117.
  • Baud rate of ESP8266 should match with Arduino Serial baud rate. Or TX/RX pins could be swapped by mistake.
  • Ensure Arduino can communicate with ESP8266 with AT commands.
  • Using Software Serial is less stable than Hardware Serial.
  • Try using boards with a dedicated hardware Serial pins, like Leonardo, Mega, Teensy, etc.
  • Trying to run a sketch with Serial Monitor open in shield mode.
  • Weak WiFi signal.
  • Poor circuit construction.

If you constantly get 'ESP is not responding' - please be patient and try looking for available solutions on our community forum.

Some useful recommendations about writing Blynk sketches can be found here: http://community.blynk.cc/t/solved-disconnect-cmd-skipped-etc-issues-my-advice/5362

Blynk was tested with following AT firmware versions:

☝️ While it seems to work with all of these versions, we observed that the AT version 1.1.0.0 works best.