Using ESP8266 Shield ESP-12E (elecshop.ml) by WangTongze with an Arduino Uno

The Problem

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):

AT+UART_DEF=9600,8,1,0,0

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/firmwarehttp://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

Serial1.begin(9600);

Enjoy your wireless Arduino!

60 thoughts to “Using ESP8266 Shield ESP-12E (elecshop.ml) by WangTongze with an Arduino Uno”

  1. Hey.. sir. Can you explain it more specific about how we connect it to the computer and how to code it.. please sir.. i am a beginner and trapped with this wifi sheild

  2. Using a USB cable plugged in to the aux port, I can talk to the shield just fine. Setting the baud to 9600 appears to work also. Sending commands to get info back also works. Plugging shield back in to a UNO Leonardo doesn’t seem to be doing much. A Leonardo does not use pins 0 and 1 for USB comms. Not sure where to go from here.

  3. Hey, super Job figuring it all out.

    I`m currently on the last step trying to get the WiFiEsp library to talk to the shield, but something is not working as it should, I uploaded the ConnectWPA sketch to the Arduino while the shield was unconnected ant then put it back on. I think maybe I got the RX/TX pins
    wrong.

    I did not upload lua code after the firmaware flash, I stoped at step 5 thinking I was done, is this maybe the reason?

    And should I wire the debug port on the shield or on the Arduino to new pins?

    1. You don’t have to upload any lua code. Maybe you switched RX and TX in you wiring?

      If found it most useful to use the ESPDebug example first, before getting the „heavy“ code on the Arduino. Just flash it (choosing the correct PINs first), open the serial console and hit reset on the WiFi board. This should give you some output from your WiFi board.

  4. Thanks for your quick replay.

    I managed to get the shield connected to my Wifi if I use wires from the arduino to the shield, but as soon as I mount it onto the arduino the serial monitor dont give any output.

  5. Yes the wires are connected as follow: TX shield – arduino pin 3, RX shield arduino pin 2, same as in the code. they are all in the down(off) position .

    1. Are you using the ESPDebug example? What happens if you press the reset on the shield? What baud rate did you choose in the serial monitor? Are you sure RX/TX are not mixed up?

  6. What is the ESPDebug example? I`m using 9600, I tried swapping them but no luck. the weird thing is that it works fine when I just use wires and dont mount it.

    1. Dear Klaus

      I did everything as you suggested and when using the ESPDebug example the output as the ESP RST button is pressed is some random characters !!! ( in this case with the UNO wired to the ESP ).
      When the ESP is pigged back on the UNO there are not outputs !!!

      Is the ESPDebug example without errors ??? I have changed as you suggested the RX/TX pins and the Serial1 also for 9600 !!

      Can you comment that please ??
      Thanks in advance
      regards
      Carlos

  7. It took me a long time to get this far (old guy learning new technology) so thought I would share what I was missing in case it helps somebody. After finally getting some communication following your advise to change the baud rate and use soft serial. I had no success using the Sparkfun ESP8266 AT Library – ESP8266_Shield_Demo, even after I did edit the sketch with my SSID and Password. Finally I opened the SparkfunESP8266WiFi.h file in notepad and found that pins 8 and 9 are being used for the serial communication.
    So the hardware set up I have now is:
    Bend the pins on 0 and 1 on the wifi shield to the side so they do not connect with the arduino and interfere with uploading sketches.
    Connect a wire from debug Tx on shield to pin 8. (pin 8 on hte shield but it is plugged into pin 8 on Arduino) and from debug Rx on shield to pin 9.
    Then the Sparkfun ESP8266_Shield_Demo works (after modifying with your SSID and Password)

    This may be all obvious to most of you, but I wish I had found some simple instructions sooner.

    The goal is a wifi AP I can connect to with the android phone and read the wood fired pizza oven temp with a MAX6675 & K type thermocouple.

  8. Don’t throw it out Greg! But I understand your frustration. It would be nice if these things had some documentation. If I just attach the shield to the arduino and power it up, the shield would provide a wireless AP. I turned on the wifi on my phone and it saw the Access Point at AI-Thinker-86927F. So I think unless you have fried the board somehow, if you just power up the arduino with the shield attached you should see a wireless access point. That is all I needed to know that the board was working.

    Then I experienced a lot of frustration until I found this blog from Claus and learned two important things. The baud rate must be changed to 9600 and software serial must be used rather than the Rx and Tx pins (pins 0 & 1).

    1. Well, just one note: If you don’t need the serial console in Arduino IDE, you don’t have to use the software serial and therefore don’t have to change the baud rate (just switch jumpers 1 and 2 to ON).
      Sucks for development, maybe that’s useful for someone.

  9. Carlos – I downloaded the Sparkfun demo from here: https://learn.sparkfun.com/tutorials/esp8266-wifi-shield-hookup-guide/installing-the-esp8266-at-library

    Once you install the library you should be able to open the Arduino IDE and click on File, Examples, Sparkfun ESP8266 Library and there should be 6 sketches there including the ESP8266_Shield_Demo. Have you been able to get to that point? All I changed in the code was line 36 and line 37 with my network SSID and Passowrd. Even that took a couple tries due to my lack of careful typing skills. Once I had those correct, the serial monitor showed that an IP address on my network had been assigned and I could open a web browser to that page and see the value of the 6 analog inputs. You also have to make sure pins 0 and 1 on the shield are not connected to arduino. First because it will interfere with uploading the sketch and second as you want to use software serial communication. Also as mentioned above Connect a wire from debug Tx on shield to pin 8. (pin 8 on the shield but it is plugged into pin 8 on Arduino) and from debug Rx on shield to pin 9.

    Let us know how it works. Thanks to Claus for starting this. Hopefully we can all get these shields working.

    1. „You also have to make sure pins 0 and 1 on the shield are not connected to arduino.“ = Set all 4 switches to „OFF“. No need to bend any PINs, in case someone is wondering 😉

    2. Thanks Don

      Yes I have used the same as you did … the problem is that I´m not able to compile ….. maybe I have the wrong libraries installed !!! … #include
      #include

      regards
      Carlos

    3. Hi Don,

      I made excatly same.Program compiled and uploaded, than..
      Press any key to begin.

      Error talking to ESP8266.
      Error: 0
      Looping forever.
      Any suggestion please?

      Thank you

      Jan

  10. Claus – thanks for your comment. To simplify it for me, are you saying that putting the DIP switches 1 and 2 in the ON position connects the RX and Tx pins and switching to off disconnects them? I am easily confused.

    1. yes, switches 1 and 2 „ON“ connects the ESP8266 RX to Arduino TX and ESP8266 TX to Arduino RX. The intended use of the shield seems to be 1 & 2 set to „ON“ and using the hardware serial on Arduino side.

  11. Claus,

    Help, I followed the early instructions and set the shield for 9600. that all seemed to work fine.i did not reload the firmware as blog indicated not necessary.

    I followed your blog , connected the shield to the arduino , bent pins 0/1 on the arduino, turned dip switches to off. connected debug TX/RX on shield to Arduino 8/9 , loaded the sparkfun demo , changed the code to my ssid/pwd and added the serial commands
    SoftwareSerial Serial1(9, 8);
    Serial1.begin(9600);
    serialTrigger(F(„Press any key to begin.“));

    I compile and download the code but the serial monitor no longer shows anything
    MY iphone shows a new network AI-THINKER10 and will connect with it.
    But I go to chrome and enter http://192.168.0.115 as I see on the spark demo and it times out
    when I look at my iphone the ip address 192.168.4.2 shows up , but I get the same result with timeout..

    Help…I think I am close…

  12. Hi,

    I have bee able to do almost all steps.
    Change baunds – ok
    flash chip – ok

    Unfortunately when shield is plugged on uno, I’m not able to upload any program.

    Error :avrdude: stk500_recv(): programmer is not responding

    Any idea?
    Thanks.

    Jan

      1. Hi Claus,
        Thank you for reply.
        All switch are set off. and rx/tx pins from shields are connected to 3/2 on Shield.(Just for sure 3/2 on digital io rr 3/2 on second side- that one close to switches ,also on shield.)
        (don’t use RX/TX on the arduino side!) what you mean?
        Should i bend 0,1on shield?

        Jan

        1. You should not have to bend anything. I’m meant you shouldn’t connect rx/tx to pins 0/1 on the arduino, so in your case it should be fine. Maybe try setting the switches to on and off again (mine done feel like they always get into the correct position well)? What happens if you remove your manual wirring from the shield to pin 2&3? What happens without the wirres, if you set the switches to on?

          1. If shield is not connected everything works as you described.
            But:
            No wiring at all and all switches on:
            Pwr and DFu glowing no information os serial port monitor.Unable to upload any.

            1and 2 button on:
            pwr glowing and STA AP a little glowing-Unable to upload any.
            no information os serial port monitor

            all buttons off:
            wiring TX debud to 3digital i/o shiel RX debug to 2 digital i/o shield
            pwr glowing and STA AP a little glowing-Unable to upload any.

            all buttons off and just for sure switch wirres 2/3
            pwr glowing and STA AP a little glowing-Unable to upload any.
            And no information at serial monitor.

            Im not sure if its about wiring when im not able to upload anything when shield is attached..only when i bend 0/1 on shield im able to upload scetch and han i see tinker as a wifi device.

            jan

    1. Out of curiosity, I ordered a second shield. It seems to be the same one, you got. I can confirm your problems, so it looks like you have to bend the pins. Maybe the switches are working differently on this board (I already have an idea, but I have to confirm it first)

      1. Unfortunately I was not able to make any sense out of this version of the shield. Set all switches to off and bend pins 0 and 1 should work, but I don’t get what the switches are doing …

        1. Hi Claus,

          Thank you for your effort.
          Have you been able to work with it even with bended pins?
          In my case , im able to upload but its not working anyway, (failed to initialize ESP)
          Do you have any recommendation for some other ‚China‘ WIFI shield which really works?

          Thnaks.

          Jan

          1. Have you seen my new post? https://claus.bloggt.es/2017/02/26/arduino-esp8266-wifi-shield-elecshop-ml-by-wangtongze-comparison/

            All switches off, PIN 0 and 1 bend and manual wiring of the debug ports RX/TX (don’t attach 5v/gnd if you attach the shield to the arduino) should work.

            My recommendation would be: If it needs to be cheap: Don’t use a shield (see my other post). Otherwise I guess the Sparkfun shield should do a much better job: https://www.sparkfun.com/products/13287

  13. I also just got the Shiald version.
    Just spent about 5 hours getting it to work (sort of)
    my findings:
    -uploading a sketch only works with both board separated and wired with the debug port.
    -then I switch 3/4 ON, start the upload in the IDE, HOLD the ESP-RST button, about 1-2 seconds after the upload starts release the switch and then it should start uploading.
    -when the shield is assembled on the Arduino there is no communication through the serial monitor, does not matter what the position on switch 1/2 is. But the shield works (webserver is reachable) but there does not seem to be any communication between the boards.

    1. Interesting – Sound exactly like what I experienced with the „shield V1“. I guess that means that the „shield“ vs. „shiald“ doesn’t tell anything. Can you maybe post a picture of you board?

          1. That fixed it thanks. But then another one popped up. „conflicting declaration ‚SoftwareSerial Serial1′“
            It compiles successful if I just rename them all Serial2.

            but then in the monitor I get:
            [WiFiEsp] >>> TIMEOUT >>>
            [WiFiEsp] Cannot initialize ESP module
            [WiFiEsp] >>> TIMEOUT >>>
            [WiFiEsp] No tag found
            WiFi shield not present
            ********************************************** Firmware version > FAILED (actual=““, expected=“1.5.2″)
            In all cases connected to debugport or combined as shield
            ————————-

            If I then upload the code from https://exploreembedded.com/wiki/Arduino_Support_for_ESP8266_with_simple_test_code directly to the board

            I get results:
            scan done
            3 networks found
            1: UPC6992507 (-78)*
            2: UPC Wi-Free (-80)
            3: UPC1381777 (-94)*
            When connected to the debug port.
            When connected as shield I get whatever is on the Arduino on 9600 (strange!) and nothing on 115200, not even gibberish
            SoftwareSerial Serial2(6, 7); // RX, TX
            Serial.begin(115200);
            Serial2.begin(9600);
            I did notice when switch 1/2 or ON I cannot program the Arduino below. So there is something going on there.

            Same issues with all the examples from the WifiESP library. Other online examples (Hello world server etc) work. Seems this different version has compatability issues with the library?

  14. Hi Claus
    I need your expertise as I am new here.

    I got the same (Shia1d Version 1.0) ESP8266 board and I got an Arduino MEGA 2560 R3 Board.

    I did connect the pins from ESP8266 to the corresponding MEGA (Analog In 1-5 to Analog in 1-5, Digital 0-13 to digital 13, etc.).
    Well, simply took the whole ESP2866 module and pushed it into MEGA. (I can send you a picture if helps.)

    Q1: Is this all I need to connect to Mega or do I have to use other connector pins ?

    With Arduino IDE I can address the MEGA (Upload,etc).
    On Wifi (ESP8266) I can connect to it’s WLAN but no ports are open, no communication

    Q2: How do I address ESP8266 -> MEGA

    Thanks for the help
    Laszlo

  15. Hey, thanks for the info, really helped me get my Sha1led working 😛

    Mine looks like your first one physically but the dip switch passthrough (1 and 2) doesn’t work for me at all… I have to have jumpers to get data…

    Also when I had it plugged in with the jumpers on the hardware serial on my Uno I could see data from the thing but I couldn’t send anything to it… When I pulled it off and ran 5v and GND as well I was able to flash it just fine…

    Then when I put the hat back on and used software serial on pins 2 and 3 with your linked library it worked great.

    Thanks!

  16. Hi, I managed to update the firmware with buttons 3 and 4 set up (ON) as described in the article from Instructables and http://www.xess.com/blog/esp8266-reflash.
    Now I have the ESP shield TX to Arduino TX (1) and RX to RX Arduino (0), 5V and GND accordingly and all the 4 buttons on lower position.
    The problem is when I try to communicate through serial from Arduino IDE on 9600 baud:
    AT returnsERROR,
    AT+RST returns error,
    others return error,
    but AT+CWMODE=3 returns OK and AT+CWJAP=“ssid“,“12345678″ returns OK.
    Why is this happening?

    Also when this is done, If I want to write some Arduino code in it what board should I select in the IDE ? Arduino UNO or Generic ESP8266?

  17. Dear Sir,
    I am using Arduino Mega 2560 for my school project.
    hardware serial is available on Mega and baud rate 115200 is acceptable.

    Can you please tell the procedure for using hardware serial on mega instead of software serial ?

    It would be really helpful as I can’t find any information elsewhere.
    Thank you.

  18. Hi Claus
    I have just bought the same board and also found a complete lack of information!
    Well done for putting this post together:)
    I am trying to pair it with a Mega 2560 R3. Sadly, as soon as I place the shield onto the mega I loose comms with the Mega.
    When I try to upload a sketch, I get the following:
    Sketch uses 5464 bytes (2%) of program storage space. Maximum is 253952 bytes.
    Global variables use 702 bytes (8%) of dynamic memory, leaving 7490 bytes for local variables. Maximum is 8192 bytes.
    avrdude: stk500v2_ReceiveMessage(): timeout
    avrdude: stk500v2_ReceiveMessage(): timeout
    avrdude: stk500v2_ReceiveMessage(): timeout
    avrdude: stk500v2_ReceiveMessage(): timeout
    avrdude: stk500v2_ReceiveMessage(): timeout
    avrdude: stk500v2_ReceiveMessage(): timeout
    avrdude: stk500v2_getsync(): timeout communicating with programmer
    An error occurred while uploading the sketch
    Would you have any idea whats happening ??

    1. Have you mounted ESP over Arduino Mega? Make sure your dip switches 1 and 2 are not in ON position. I was getting same error uploading sketch. So, correct process is to keep dip switches down while uploading the sketch and once upload completes remove USB cable and switch on dip switches 1 and 2 back to on. Hope it helps.

  19. Hello i try and the esp did not response
    When i do the reset i see characters but not ok or ready
    i dont understand what happen is possibly that was a power problem??

  20. I have the same shield, switched the baud-rate to 9600, everything fine till here. When i try to execute this code: https://github.com/bportaluri/WiFiEsp/blob/master/examples/WebClient/WebClient.ino , it gives me this response:
    [WiFiEsp] Initializing ESP module
    [WiFiEsp] >>> TIMEOUT >>>
    [WiFiEsp] >>> TIMEOUT >>>
    [WiFiEsp] >>> TIMEOUT >>>
    [WiFiEsp] >>> TIMEOUT >>>
    [WiFiEsp] >>> TIMEOUT >>>
    [WiFiEsp] Cannot initialize ESP module
    [WiFiEsp] >>> TIMEOUT >>>
    [WiFiEsp] No tag found
    WiFi shield not present
    I have connected tx and rx in 7 & 6 … Please Help Me!!

  21. Sir – you are a God. I would never have figured this out without the help of your article.

    I got one of the „shiald“ variants recently from gearbest – http://www.gearbest.com/other-accessories/pp_609045.html

    I changed the baud rate to 9600, didn’t bother with the firmware flash, attached it to my (cheap Chinese copy) uno and loaded the WPA example sketch. Away it went. No bent pins needed but you DO NEED to make the connection from the debug port to your soft serial pins (3,2) and change them in the sketch.

    What would have been endless hours of frustration (probably more like me giving up!) was half an hours tinkering with your help.

    Many Thanks! 🙂

    1. Hi Dylan Oil – I have the same shiald..:) A couple of questions: 1; WPA sketch….is that the „ConnectWithWPA“ example sketch? 2;….pins (3,2) and change them in the sketch.“ Where in the sketch do you make the change?

      Cheers,
      Peter

  22. Hi Claus,

    I have mounted the shield over arduino mega but the shield is not working. I have switch on button 1 and 2. but I am not getting on serial port. can you help get the mounting correct, tx rx wiring correct. here is my code:
    #include

    #include
    #include

    // LED
    int ledPin = 13;
    // LM35 analog input
    int lm35Pin = 0;
    dht DHT;
    #define DHT11_PIN 0

    // replace with your channel’s thingspeak API key
    String apiKey = „5Z5NRNUULGJT28SV“;

    // connect 10 to TX of Serial USB
    // connect 11 to RX of serial USB
    SoftwareSerial ser(16, 17); // RX, TX

    // this runs once
    void setup() {
    // initialize the digital pin as an output.
    pinMode(ledPin, OUTPUT);

    // enable debug serial
    Serial.begin(115200);
    // enable software serial
    ser.begin(9600);

    // reset ESP8266
    ser.println(„AT+RST“);
    }

    // the loop
    void loop() {

    // blink LED on board
    digitalWrite(ledPin, HIGH);
    delay(200);
    digitalWrite(ledPin, LOW);

    int humidity;
    int temp;
    Serial.print(„DHT11, \t“);
    DHT.read11(DHT11_PIN); // READ DATA

    // DISPLAT DATA
    Serial.print(DHT.humidity,1);
    humidity = DHT.humidity;
    Serial.print(„,\t“);
    Serial.println(DHT.temperature,1);
    temp = DHT.temperature;

    char buf[16];
    String strTemp = dtostrf(temp, 4, 1, buf);

    char buf1[16];
    String strHumd = dtostrf(humidity, 4, 1, buf1);
    //Serial.println(strTemp);

    // TCP connection
    String cmd = „AT+CIPSTART=\“TCP\“,\“184.106.153.149\“,80″;
    ser.println(cmd);
    delay(500);
    Serial.println(cmd);
    if(ser.find(„Error“)){
    Serial.println(„AT+CIPSTART error“);
    return;
    }
    if (ser.available()>0)
    {

    Serial.println(char(ser.read()));
    }
    // prepare GET string
    String getStr = „GET /update?api_key=“;
    getStr += apiKey;
    getStr +=“&field1=“;
    getStr += String(strTemp);
    getStr +=“&field2=“;
    getStr += String(strHumd);
    getStr += „\r\n\r\n“;

    // send data length
    cmd = „AT+CIPSEND=“;
    cmd += String(getStr.length());
    ser.println(cmd);
    Serial.println(cmd);
    delay(500);
    if (ser.available()>0)
    {
    Serial.println(char(ser.read()));
    }
    if(ser.find(„>“)){
    ser.print(getStr);
    Serial.println(getStr);
    }
    else{
    ser.println(„AT+CIPCLOSE“);
    // alert user
    Serial.println(„AT+CIPCLOSE“);
    }

    // thingspeak needs 15 sec delay between updates
    delay(16000);
    }

    It appears that AT commands are sent but I am not receiving any response over serial. Although, I have tested it using AT commands over serial monitor and it works fine. It’s just that when i mount it on arduino it stops working. Can you help me out here.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.