1)Flash the esp01
2)Solder a jumper
3)Some configuration on esp
1.Flashing the esp
I am not writing any code. I use firmware from espeasy. The version is R120 which is stable version. Direct flash using espeasy flashing software.
Connection for Uuart to USB (Im using CH340G)
ESP>CH340G
RX>TX
TX>RX
GND>GND
ESP>External Supply
GPIO 0 > 3.3V
GPIO 2 > 3.3V
CH_PD > 3.3V
RST > no connection
VCC > 3.3V
every pin that goes to 3.3v, u can put pull up 10k resistor ( up to u want to put or not.. in my case it works without pull up resistor)
2. Solder a jumper.
This part I choose to use GPIO 2 as switch. In this part we must aware that GPIO 0 and GPIO 2 must be high during boot to run the program from flash. So what I do is I solder a jumper from GPIO 2 to a switch and I solder another pin of the switch to the gate of the transistor.
3. Some configuration on espeasy
I enable Rules.
How to enable Rules. Go to Tools section > Advance > Tick Rules box > Submit
On Rules section. Please paste this rule.
On System#Boot do //When the ESP boots, do
gpio,2,0 //Set GPIO 2 to low
endon
Then Submit.
So now how its work??? I put the esp back to the relay module. The new switch state is "Off". I turned on the module by giving 5V input at IN+ and ground at IN- . After the boot is success I turn the switch to "On" state. Next I can control the esp using HTTP command.
http://YOURESPIPADDRESS/control?cmd=GPIO,2,1 for On
http://YOURESPIPADDRESS/control?cmd=GPIO,2,0 for Off
I fixed my esp ip address by setting in my router so that I can make a button on my phone with the command. You can do the same . If you re not doing so then the ip might change every time it reboot.
Please take note that on ESP configuration I skip the wifi setting part and so on. The esp and the device we use to send the command must be in same wireless network. Have fun~