Pages

April 1, 2015

ESP8266 wiring schemas

In this page I want to collect some examples (of increasing complexity) to connect the ESP8266 to Arduino boards.
All the wiring schemes and examples are based on an Arduino One and an 8-pins ESP8266 module also know as ESP-01. Arduino pins 6 and 7 will be used as a second serial port using SoftwareSerial library as described here.



Schema Power RX TX
1) Basic N N N
2) Powering with diodes Y N N
3) Powering with Zener diode Y N N
4) Powering with voltage regulator Y N N
5) RX level shifter with resistors N Y N
6) RX level shifter with diode N Y N



1) Basic

Here are the ESP-01 pins.


The most basic connection scheme is this.


Wiring
  • Arduino 3.3v power > breadboard red power rail
  • Arduino GND > breadboard black ground rail
  • ESP8266 GND > ground rail
  • ESP8266 VCC > power rail
  • ESP8266 CH_PD > power rail
  • ESP8266 TXD > Arduino Digital Pin #6 (RX pin using software serial)
  • ESP8266 RXD > Arduino Digital Pin #7 (TX pin using software serial)
  • A 100uF (or larger) capacitor helps to absorb current spikes


This schema has three main problems:
  • Power source: Arduino boards are typically powered at 5V while ESP8266 needs a 3.3V power source. The ESP can draw up to 250mA while the Arduino Uno 3.3V output pin can provide only 50mA. A capacitor can help but it's not enough.
  • RX: The 5V Arduino TX serial output needs to be shifted to the 3.3V ESP RX input. However, simple prototypes can be built without this because the ESP has a built in protection.
  • TX: The 3.3V ESP TX output should be enough for the 5V Arduino digital input. A reliable project may need a level shifter.


The next wiring schemes will show different approaches to provide a reliable 3.3V power source to the ESP.

2) Powering with diodes

Since the Arduino 5V pin can provide 200mA we can use this to power the ESP. This schema is very cheap and simple allowing to use simple and cheap diodes to convert the 5V to 3.6V. Suitable diodes are the 1N4148 (300 mA) or the 1N4007 (1 A).



3) Powering with Zener diode

An alternative cheap approach is to use a 1N5226 3.3V Zener diode to power the ESP as described here.




4) Powering with voltage regulator (LM1117/LD1117)

Several cheap 3.3V regulators are available on the market. A very common and cheap one is the LM1117 (or LD1117). With such regulator you can convert the 5V power used for Arduino to the 3.3V needed by the ESP.


An AMS1117 module is also a great choice.
A generic voltage regulator like the LM317T can be used as described in this post.


5) RX level shifter with resistors

 The 5V output from the Arduino TX pin can be shifted to 3.3V using a resistor voltage divider.
 In this schema I have used three 220 Ohm resistors for an output current of 7.5 mA.



6) RX level shifter with Diode


You can use a 1N4148 diode on the Arduino TX pin as well to lower the voltage of the signal.





Putting all together


Now pick your preferred schemes to build your perfect Arduino/ESP wiring.


References


5V to 3.3V Logic Level Shifting


13 comments:

  1. Great post.
    Regarding solution 5): not sure to understand your voltage divider. Should'nt the Arduino TX pin be connected to the 5V level of the voltage divider?

    ReplyDelete
    Replies
    1. I have corrected the diagram.
      Thank you for the feedback.

      Delete
  2. 5) RX level shifter with resistors
    where is the connection with RX pin and the arduino? (pin 7)

    ReplyDelete
    Replies
    1. I have corrected the diagram.
      Thank you for the feedback.

      Delete
  3. PS : sorry, thx for this post!!!! ;-)

    ReplyDelete
  4. Hi mate,

    what volt of 100uF (or larger) capacitor which u use in wiring??
    100uF 10V (http://www.ebay.com.au/itm/20-x-100uF-10V-105C-Radial-Electrolytic-Capacitor-5x11mm-WS-/221706086778?hash=item339eb6697a)
    or
    100uF 16V (http://www.ebay.com.au/itm/10-x-100uF-16V-105C-Radial-Electrolytic-Capacitor-5x11mm-WS-/221840694115?hash=item33a6bc5b63) ??

    Thanks

    ReplyDelete
  5. Hi Bruno

    I would hesitate driving the ESP straight from the Arduino voltage pins as they can sometimes go over 200mA and this might damage the Arduino(option 2 in the list). While a cheap way of getting things done maybe just make a note so that some of the newer electronic users dont swear at you when they get visited by the blue smoke monster.

    For logic level conversion between the RX and TX ports one can also use BSS138 mosfet n-channel transistors. These do the job pretty well and is another viable option.



    ReplyDelete
  6. 1N4148 only has a 0.7V voltage drop, would you not need several to convert 5V > 3.3v

    ReplyDelete
  7. Hey there!

    I hardly ever leave comments on anything. I peruse SO and various RPI and Arduino forums like it's going out of style, and I just wanted you to know that old post or not, this kicked ass.

    I have been scratching my head for 48 hours straight trying to connect my ESP8266 through my arduino. I had purchased an FTDI232RL and couldn't get the IDE to recognize the connection. That being said, for whomever reads this (and reads the comments like I do):

    Suggestion #2 worked like a GEM! An absolute gem. Bruno - I owe you a beer.

    ReplyDelete
  8. Zener diode is nice idea to put here, try to make bigger content about zener diode definition

    ReplyDelete
  9. I am working on the same platform so what you said is extremely agreed and would help for more folks to learn good information from this blog

    iot training in hyderabed

    ReplyDelete

Note: Only a member of this blog may post a comment.