ESP8266 is a family of inexpensive full TCP/IP stack Wi-Fi chips and microcontrollers that can be programmed using Arduino IDE. It can work as a standalone microcontroller or interfaced with an Arduino microcontroller via AT commands. I decided to try it out by itself on a simple relay project with an ESP-01 module. The program is a simple web server that can be used by a client to turn a power socket on and off using a 5V relay module.
1 x ESP8266 (ESP-01) Serial WIFI Wireless Transceiver Module
1 x 220V AC to 5V DC (700mA) Converter
1 x AMS1117 5V to 3.3V (800mA) Converter
1 x 2N2222A TO-92 NPN Transistor
1 x 5V 1 Channel Relay Module
1 x FT232RL 3.3V 5V FTDI USB to TTL Serial Adapter + USB cable
2 x 470uF Capacitors
1 x 100uF Capacitor
1 x 10nF Capacitor
1 x 10k Resistor
1 x 47k Resistor
To program the ESP module it is very important to use a 3.3V adapter, if you have a 5V adapter you need to use logic level shifting. The one I used has a convenient jumper to switch between 3.3V and 5V operation. I used the 220V AC to 5V DC converter for relay operation and AMS1117 to convert 5V to 3.3V for ESP-01 operation. The 2N2222A NPN transistor is used to ground the input pin of the relay to turn it on or off. The GPIO 2 pin of ESP-01 is connected to the transistor base via a 47k resistor. The CH_PD and RST pins of the ESP-01 are connected to VCC via 10k resistor.
ESP modules use a lot of power so you need to make sure you have a proper power supply. Peeks are also an issue and it can be difficult to make the circuit stable. Relay, wiring and connections emit a lot of noise into the system and ESP-01 is very prone to resets. To make the system more stable I used the 2 x 470uF capacitors (on 5V and 3.3V rails not visible in the image below because they are located below the board) and 100uF and 10nF between the VCC and GND pins very close to the ESP module. I actually soldered the 100uF capacitor on top of the ESP pins and the 10nF is also not visible in the image because it is below the board.
iOS Remote Control App
iOS Remote Control App on GitHub: https://github.com/lukagabric/ESP8266Light_iOS
ESP-01 Arduino Sketch on GitHub: https://github.com/lukagabric/ESP8266Light_Arduino
References for wiring and Arduino tutorial:
If you liked this blog post I’d appreciate if you followed me on Twitter