- ESP01/01S RELAY MODULE TUTORIAL
- Step 1: Material Preparation
- Step 2: Hardware Installation
- Step 3: Uploading the Code
- Attachments
- Step 4: Results
- 8 People Made This Project!
- Recommendations
- Metal Contest
- Make It Bridge
- Project-Based Learning Contest
- 89 Comments
- ESP-01S, ESP-07S, ESP-12F. The many Ai-Thinker modules with ESP8266 inside compared
- About Ai-Thinker, the maker of ESP-XX modules
- Why not use an ESP8266 board?
ESP01/01S RELAY MODULE TUTORIAL
Description
This WiFi relay based on AI-Thinker ESP-01/ 01S WiFi module, we use the GPIO0 of ESP-01/ 01S to control the relay by low level. It’s easy to DIY your smart switch to any device by your phone anywhere with this smart relay.
Specifications
- Working voltage: DC 5V-12V
- Working current: ≥250mA
- Communication: ESP01 or ESP 01S
- WiFi module Transmission distance: the maximum transmission distance is 400m (open environment, mobile phone equipped with WiFi module)
- Load: 10A/ 250VAC, 10A/ 30VDC, 10A/ 30VDC, 10A/ 28VDC
- Size: 37 x 25mm
Step 1: Material Preparation
In this tutorial, we only used the following materials:
and last but not least, ESP01/01S Relay Module.
We connect ESP8266 WiFi Serial Transceiver Module to ESP01/01S Relay Module so that we can control the relay via WiFi. To program ESP8266, FTDI Converter is required to be connected with ESP8266.
Step 2: Hardware Installation
As for the connection between ESP8266 and FTDI Converter, it is shown as diagram above or listed as below:
- RX -> TX
- TX -> RX
- VCC -> VCC
- CH_EN -> VCC
- GPIO-0 -> GND
- GND -> GND
The pins for ESP8266 is also labeled as diagram 2.
After done uploading the code to ESP8266, simply connect it to ESP01/01S Relay Module.
Step 3: Uploading the Code
For coding part, change the SSID and PASSWORD to your WiFi SSID and Password respectively. In the code, it is mentioned that serial begin is 115200, so make sure that the serial monitor is 115200 otherwise it will not display anything. We set the URL to https://192.168.0.178/ and it will be used later on.
Attachments
Step 4: Results
When we access the URL, it will show as diagram 1 above. Make sure that you have been activated the ESP8266 along with ESP01/01S Relay Module with a range of 5V to 12V so that you can access the URL. The results for the module is shown as diagram 2 which LED lighted up indicated that the relay is ON.
Once we pressed the OFF in URL, the relay will be turned OFF simultaneously and vice versa for ON option.
8 People Made This Project!
Did you make this project? Share it with us!
Recommendations
Metal Contest
Make It Bridge
Project-Based Learning Contest
89 Comments
Can you guide me to use all 4 pins of esp01 to control 4 relays?
how I connect to my WIFI, and I can’t connect with the address given
I don’t have the USB to UART FTDI Converter
please add firebase cloud control
Hello,
Unable to send *.ino program with Arduino IDE to ESP01 via UART FTDI Converter
Error message
«esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header»
ThankYOU
Hello, how can I convert this source code from client to access point?
Did anyone faced any problem. such as relay getting on/off continuously as soon as the relay board is powered on. I am facing this irritating problem, any help?
I use timer (ne555) to power up 4 relay module after 7sec after power on esp8266
i assume you’re using v4 module. just add a 470uf/16v elec. capacitor direcly on optocoupler pin 1 (+) and 2 (-)
I got the HW-655 with the ESP8266 and when I power it up (before even programming the ESP8266) I got the relay on the HW-655 operating and releasing about every second, haven’t worked out why yet, if anyone knows why, I’d love to hear, cheers
If having problems uploading the code try this. It worked for me. Anyhow webserver «drops» all the time. It works for about 5 minutes then it freezes. Any idea what to do.
mine not working
the error message is below
Arduino: 1.8.12 (Windows 10), Board: «Generic ESP8266 Module, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Serial, None, Only Sketch, 115200»
Executable segment sizes:
IROM : 246344 — code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 28148 / 32768 — code in IRAM (ICACHE_RAM_ATTR, ISRs. )
DATA : 1260 ) — initialized variables (global, static) in RAM/HEAP
RODATA : 1264 ) / 81920 — constants (global, static) in RAM/HEAP
BSS : 25208 ) — zeroed variables (global, static) in RAM/HEAP
Sketch uses 277016 bytes (28%) of program storage space. Maximum is 958448 bytes.
Global variables use 27732 bytes (33%) of dynamic memory, leaving 54188 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM4
Connecting. _____. _____. _____. _____. _____. _____. _____
Traceback (most recent call last):
File «C:\Users\Dr. Chandan Parashar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1/tools/upload.py», line 65, in
esptool.main(cmdline)
File «C:/Users/Dr. Chandan Parashar/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py», line 2890, in main
esp.connect(args.before)
File «C:/Users/Dr. Chandan Parashar/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool\esptool.py», line 483, in connect
raise FatalError(‘Failed to connect to %s: %s’ % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
This report would have more information with
«Show verbose output during compilation»
option enabled in File -> Preferences.
can you tell what is the mistake I am committing
ESP-01S, ESP-07S, ESP-12F. The many Ai-Thinker modules with ESP8266 inside compared
If you have spent any time creating custom firmware with either ESPHome or Tasmota, you will have undoubtedly come across one of the many Ai-Thinker modules featuring the ESP8266 microchip. At this point, Ai-Thinker’s ESP-XX modules are so ubiquitous with Espressif’s ESP8266 that many believe them to be a competitor. In reality, these ESP-XX modules all feature ESP8266 (or ESP8285) microchips and Ai-Thinker is everything but a competitor to Espressif: it is a customer.
The following analogy might help you understand how the ESP8266 and ESP-01S/ESP-07S/ESP-12S etc. relate to one another. Just as two computers might have the same Intel Core i5 CPU’s, the rest of the hardware can greatly vary. One computer might use a Mini-ITX motherboard, which makes it much smaller but restricts it to only two USB ports and is more difficult to work with. The other computer might have an ATX motherboard that has 4 USB ports and many more PCIe slots.
In this analogy the ESP8266 would be the CPU. It remains the same, whether it is on a Mini-ITX or ATX motherboard. Each system has its pros and cons. The ATX motherboard has more ports and slots, but is much larger than the Mini-ITX motherboard and thus needs a larger chassis. The same goes for these ESP-XX modules: The ESP-01S might be small but only has two usable GPIO pins. In contrast, the ESP-07S has a larger flash storage and more available GPIO pins, but the downside is that it is larger.
You will usually find these modules under the moniker ESP-XX, with XX representing two numbers. Revisions and variants will usually receive a suffix in the form of an S, F, E, or M. Currently, there are at least 22 modules, which come in various shapes and sizes, but with one thing in common: the ESP8266. Many of these modules have been discontinued, and you will also find variants going by the same name. For example, there is an ESP-01 with a blue PCB and a flash size of 512 KiB and another with a black PCB and double the flash storage. I am continually baffled by how Chinese manufacturers name their products.
The ESP-XX modules deserve their place in maker-history, as it was the thumb-sized ESP-01 which first made the ESP8266 popular in the West and not a board such as the . Still today, the ESP-01 remains popular and is found at the heart of many projects, as are the ESP-07S and ESP-12F/S. In this article I will be explaining what exactly differentiates not just these three, but all of the ESP-XX models.
- About Ai-Thinker, the maker of ESP-XX modules
- Why not use an ESP8266 board?
- The many Ai-Thinker ESP-XX modules compared
- Size comparison of Ai-Thinker ESP-XX modules
- Shielded or unshielded?
- External, PCB, or ceramic antenna, which is best?
- What is the ESP8285?
- ESP-01S
- ESP-01M
- ESP-01F
- ESP-07S
- ESP-12F
- ESP-12S
- Beware of flash sizes
- The on-board USB-to-UART bridge allows you to connect the ESP8266 board directly to a computer without having to use any extra board.
- The same bridge can be used to power the ESP8266 board using an old phone charger. ESP-XX modules do not have a micro-USB port for easy powering.
- The on-board 3.3V regulator means you can power the ESP8266 board using 5V.
About Ai-Thinker, the maker of ESP-XX modules
There is little to nothing about Ai-Thinker, the company that manufactures the ESP-XX modules with the ESP8266 from Espressif. They describe their corporate culture as: Building consensus, hold dreams, and move forward together!, and most of their website is badly translated Chinese, making them even more mysterious.
What I have been able to find out from the Ai-Thinker page on Alibaba is that it was established in 2012 and that it merged with Shenzhen B&T Technology Co., Ltd. in 2016. Their customers include Tuya, Yeelight, DeLonghi, and TCL. Ai-Thinker is based in Shenzhen, which is fitting, as it has been dubbed China’s Silicon Valley by the media.
While we enthusiasts might know Ai-Thinker just for their Wi-Fi products, they do also produce LoRa, GPS/GPRS, and 2.4G modules. Their main clients appear to be other manufacturers who use Ai-Thinker modules in their consumer products or for prototyping.
Why not use an ESP8266 board?
In my ESPHome beginner’s guide, I recommend that beginners start off their journey with an ESP8266 board, such as the popular . This type of ESP8266 board is far easier to work with than any of the ESP-XX modules. The LOLIN D1 mini and other boards have the following features which you won’t be able to find on any module in this article:
To be able to flash the ESP-XX modules, you will need to purchase an external USB-to-UART as there is no Micro-USB port to be found on any of them. You also won’t be able to power such a module using 5V as they have no voltage regulator meaning that you will either need to work with 3.3V or add a buck converter.