Recently I became quite addicted to my new Arduino Uno. To maximize the fun, I ordered a variety of shields. Today I received my ESP8266 Shield ESP-12E, which turned out to be quite a hassle.
I ordered this:
an received this:
But apart from this the “Shiald” seemed to be fine, but the problem was: There was absolutely no documentation available and searching for tutorials revealed a lot of people having problems, but most of them being unresolved and no consistent tutorial. Combining the information they gathered (and adding some trial & error), I was able to get my shield working.
Disclaimer: All this comes without any warranty. Although I got it working now, I think I damaged the RX/TX pins on my shield in the process!
Preparing the shield
By default the shields UART is set to 115200 baud. Since the Arduino Uno doesn’t have a hardware serial (except the one for the USB connection), we have to use a software serial connection, that cannot handle this speed. Therefore we have to set the ESP8266 to 9600 baud, which can be done sending the following command through the serial connection (NOTE: this will survive reboots, so we have to do this only once):
Problem is: We need a serial connection to get the serial connection working! If you have the equipment, you can connect the “Debug Port” directly to your computer and use this serial port. Since I don’t own the necessary cable, I had to do it differently. I detached the shield from the Uno and did some manual wiring:
Debug Port TX => Uno Pin 1 (TX) Debug Port RX => Uno Pin 0 (RX) Debug Port 5V => Uno 5V Debug Port GND => Uno GND
Warning the Esp8266 is running on 3.3V, while the Uno uses 5V. I’m not sure this is handled on the debug port, so a direct connection (without level conversion) might damage your WiFi shield! Do so at your own risk!
(Note: No need to do anything to the 3.3V Port). The shields COM Port is now connected the same one the Uno is using for USB communication. To make sure they are not interfering, additionally we have to connect the Unos Reset pin to the Unos GND. Also make sure to set all 4 dip switches on the shield to off (down).
If you open the serial monitor now, set it to 115200 baud and reset the shield, you should see some gibberish follow by “ready”. Once you select “Both NL & CL” in the lower right corner of the serial monitor, you should be able to send the send the AT command to switch the baud rate (result should be “OK”). Once you do another shield reset, you should see gibberish only, until you switch the serial monitor to 9600 baud.
The same hardware setup can also used to flash new firmware to the ESP8266, if you set the switches 3 and 4 to “ON” (disconnect power before doing so!). You can follow the instruction at http://www.instructables.com/id/Intro-Esp-8266-firmware-update/?ALLSTEPS then, using the COM port you usually use to flash your Arduino. Firmware can be found at https://github.com/sleemanj/ESP8266_Simple/tree/master/firmware, http://bbs.espressif.com/viewforum.php?f=61 or various other sides. For use with the Arduino, the Firmware doesn’t seem to matter to much, since ESP8266 is controlled via AT commands, which seem to be part of most of the available firmwares. (Note: You might need to set the baud rate again after updating the firmware).
In theory (I haven’t tested it yet) you should also be able to install your own sketches directly on the shield (instead of the uno), using this board configuration.
Making it work
Once the firmware is up to date and the baud rate is set, we are good to go: Make sure the dip switches are off again, remove the all the wiring and reattach the shield to the uno.
Since the shield uses PIN 0 and 1 by default, which sucks, because those are the Unos RX/TX pins, we have to wire them to new pins of our choice. E.g.:
Debug Port RX => Uno pin 2 Debug Port TX => Uno pin 3
Now you are able to use the WiFiEsp library to talk to your shield. Just make sure to use the correct pins for the software serial port
SoftwareSerial Serial1(3, 2)
and use the correct baud rate
Enjoy your wireless Arduino!