Introduction: Cheap Arduino WiFi Shield With ESP8266

Picture of Cheap Arduino WiFi Shield With ESP8266

In my previous Instructable I have described how to plug the ESP-01 module into a breadboard.

This is just the first step to make a cheap Arduino WiFi shield using the ESP8266 module. With few more electronic components and the WiFiEsp library you can build it for less that 10 USD.

Step 1: Components

Here are the components you need

  • Arduino board - In this example I'm using an Arduino Uno board but I personally uprefer using an Arduino Mega because it has more memory and has a second serial port to communicate with the ESP module.
  • ESP-01 - This is the smallest and cheaper type of ESP8266.
  • AMS1117 5V to 3.3V Power Supply - Arduino boards are typically powered at 5V while ESP8266 needs a 3.3V power source. The Arduino 3.3V output pin cannot provide the power needed by the ESP (up to 250mA). This can be solved using a 3.3V voltage regulator like the LM1117/LD1117 or AMS1117.
  • Breadboard - A 170 holes mini breadboard is enough but you can use a bigger one if you need.
  • 10 uF Capacitor - A small electrolytic capacitor is needed to stabilize the voltage regulator. Any 10-100 uF should be ok.

  • 2 resistors (1K and 2.2K) - A simple voltage divider is needed to shift down the 5V output of the Arduino TX pin. You can use other resistors as long as they are in a 1/2 ratio approximately.
  • Jumper wires

Step 2: Wiring It Up

Picture of Wiring It Up

In the schematic I have described how to connect all the components using an Arduino Uno board and a mini breadboard.

  • The ESP's VCC pin is powered by the 3.3V output pin of the voltage regulator (AMS1117 in my example). The 10uF capacitor is connected to the output pins to stabilize the regulator. The CH_PD pin must also be connected to 3.3V. The GND pin is obviously connected to ground.
  • The ESP's TXD pin can be connected directly to the RX pin of Arduino (emulated on pin 6).
  • The ESP's RXD pin is connected to the TX pin of Arduino (emulated on pin 7) through the level shifter.

If you are using an Arduino Mega you need to change the wiring schema an connect the ESP TX/RX pins to the Arduino Serial1 pins. This allows to have a more fast and reliable communication link between the Arduino board and the ESP-01 module.

Step 3: Testing

Picture of Testing

To test the shield you can use the following Arduino sketch. Note that the sketch is emulating the Serial1 interface if it is not available.


// EspDebug - Test sketch for ESP8266 module
// emulate Serial1 if not present #ifndef HAVE_HWSERIAL1 #include "SoftwareSerial.h" SoftwareSerial Serial1(6, 7); // RX, TX #endif void setup() { Serial.begin(115200); // serial port used for debugging Serial1.begin(9600); // your ESP's baud rate might be different } void loop() { if(Serial1.available()) // check if the ESP is sending a message { while(Serial1.available()) { int c = Serial1.read(); // read the next character Serial.write((char)c); // writes data to the serial monitor } } if(Serial.available()) { // wait to let all the input command in the serial buffer delay(10); // read the input command in a string String cmd = ""; while(Serial.available()) { cmd += (char)Serial.read(); } // print the command and send it to the ESP Serial.println(); Serial.print(">>>> "); Serial.println(cmd); // send the read character to the ESP Serial1.print(cmd); } }

Now you can open the Arduino serial monitor (see the screenshot) and type few basic AT commands.

  • AT
  • AT+GMR

If you do not get any output you can try the following.

  • The serial monitor baud rate must match the one specified on line 7 of the sketch so it must be set to 115200.
  • Try different settings for the 'Line ending' option of the serial monitor. For my ESP module I have to set it to 'Both NL & CR' as you can see in the screenshot.
  • Adjust the serial baud rate of the ESP-01 module at line 8 of the above sketch. Typical baud rates are 9600 or 115200.

Try different combinations until you are able to correctly interact with the ESP module using the serial monitor.

Unfortunately if the ESP module is set to work at 115200 or higher baud rates you may not be able to make it work with an emulated serial interface. In such case you need to use an Arduino Mega board with a secondary hardware serial interface.

Step 4: Moving Forward

Picture of Moving Forward

Implementing few enhancements will allow to have a pluggable and reliable WiFi shield for you Arduino to connect it to the Internet.

  • The ESP-01 can be hoked up directly into the breadboard using the technique described in this Instructable.
  • The wiring can be compacted to leave space for other components.
  • A ProtoShield can be used to have a reliable and pluggable WiFi shield.

The picture is quite clear about what I have achieved.

Now look at my blog about how to use the WiFiEsp library for Arduino to see how to use this cheap WiFi shield for your connected projects!

Comments

Wikibear (author)2016-12-30

Hello together!

For all people out there i have some news. I get my ESP01 with baudrate 115200. Arduino don't like this baudrate and you will get not supported firmware. You must change in debug script serial1 and serial. Then you can speak with your ESP01.

If you typ AT you get some error and firmware read out is totally bad. Now send your ESP01 this command: AT+UART_DEF=9600,8,1,0,0

Thereafter change serial and serial1 again and voilat your ESP01 work as aspected.

It's totally recommand that you change the boudrate down to 9600 via AT Command. And then your ESP01 will work fine. :)

CRAK (author)Wikibear2017-05-05

Hi Wikibear,

You seem to have the solution... what it is exactly that we should change?

Wikibear (author)CRAK2017-05-16

Look to my last entry. :) This will help you to solve this issue.

Wikibear (author)CRAK2017-05-05

Arduino Uno and all versions below can't handle high baut rates. The EPS01 must get an AT command to change this down to 9600 with an AT command i post this in my comment. There after communication with the chip and scripts are working. Only Arduino Mega work with 115000.

ropotis. (author)Wikibear2017-01-02

I confirm this, tried yesterday with 9600 and it works like a charm. Thank you Wikibear for the clarification and Twim for the excellent work!

Wikibear (author)ropotis.2017-01-03

In the meanwhile i have found why 115200 doesn't work, cause arduino can't simulate 115200 well. That's all.

ropotis. (author)Wikibear2017-01-03

That's true! Software serial library supports speeds up to 115200 but for the UNO the maximum Rx speed is 57600. So, I suggest starting with 9600 and going up one step at a time to find the maximum working serial speed.

Wikibear (author)2017-05-16

Connect your WLAN ESP01 like to following points:

3,3V -> 3,3V

GND->GND

RX->D0/RX

TX->D1/TX

ENT->3,3V

You
don't need electrical parts if you use uno. If you use mini 3,3V are
not stable on current and will stop working. Then you need electrical
parts with separate 5V to 3,3V step down. Please don't use 5V you can
brick your ESP01 for ever.

Load BareMinimum and save into arduino

Open Serial Monitor and set down below right corner dropdown to Both NL & CR 115200 baud.

Now
type in command line AT you will get response OK. If you get OK your
ESP01 is well and waits for next command. Now type AT+GMR you will get
the software version and much more. If this is fine type

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

This
will set your ESP01 to 9600 baud. You will get OK. Thereafter you get
no response. Set baudrate from serial monitor to 9600 now.

Type AT. If you get OK its all fine and you can use ESP01 on 9600 software serial now.

More information i use WiFiesp lib. Via examples->WiFiesp->test->espdebug you can load a test script into your arduino for testing software AT commands. If this will work you have done the job!

Kreativesinness (author)2017-05-15

Hello all :) regarding the baudrate change , for esp-05 is the same command to be used? Also what should be the initial serial rate in the code section . your help will be appreciated . TIA :)

hemanth kumar reddy (author)2017-03-14

​Can plz look at this
https://www.instructables.com/community/security-s...
small help thanks

taifur (author)2016-12-10

Nice and useful.

Johnson Selva (author)2016-10-01

your tutorials are awesome dude, will you help me to work with ESP8266 i cant able to run a simple code as i have library errors...

MichaelO165 (author)2016-09-05

Hello The Twim

Thank you so much for the upload, I've ordered the components so I can build one myself.

One thing I am confused about, and please forgive me - I'm a bit of a newbie, is the use of the voltage divider between Tx (pin 7 on the Arduino) and Rx (on the ESP). I thought Rx was a data receive pin and as such wouldn't need to be voltage regulated at all. But actually, from what you are telling me, 5V is sent out from the Arduino on the Tx output, is that right?

Any help on the subject is greatly appreciated so thank you in advance.

:)

TheTwim (author)MichaelO1652016-09-05

You are right. The Arduino TX pin will output a 5V signal that could damage the ESP RX input.

On the other side, the Arduino RX input pin reads the 3.3V output from the ESP without problems so you don't need to shift up this signal.

MichaelO165 (author)TheTwim2016-09-06

Thank you so much for your speedy reply.

Is this true to all pins on the arduino or only the Tx?

alok014 (author)2016-08-07

WHAT IS THE DIFFERENCE BT IN SERIAL PRINT AND SERIAL PRINTLN

BarryK14 (author)alok0142016-08-26

Serial.print outputs to the serial port without any end of line characters. println does the same but adds a new line (the ln indicates this). Depending on your system that may be carriage return or with the new line character as well.

benjgorman (author)2016-03-23

[WiFiEsp] Initializing ESP module

[WiFiEsp] >>> TIMEOUT >>>

[WiFiEsp] Cannot initialize ESP module

[WiFiEsp] >>> TIMEOUT >>>

[WiFiEsp] No tag found

Any ideas?

PradheepK1 (author)benjgorman2016-05-26

Did You solve this problem?

johnc495 (author)benjgorman2016-03-29

Same problem here!

I set the ESP8266-01 to 9600 Baud and worked fine :)

PS. It was previously on 112K Baud which can be a problem for SOFTWARESERIAL

billybot (author)2015-12-22

Nice little project. I don't usually like using shields but since you are making this one I find it much more acceptable. nice work.

l19bal (author)2015-12-22

Cool idea. I've recently started using the ESP8266 and this will certainly be helpful!

About This Instructable

65,337views

227favorites

License:

More by TheTwim:Cheap Arduino WiFi shield with ESP8266Making ESP8266-01 module breadboard friendlyKnight Rider animation with Arduino and TLC5940
Add instructable to: