Make a DIY Sonoff Smart Switch Use Android App
What’s Sonoff?
Sonoff is a smart switch device line for Smart Home developed by ITEAD. One of the most flexible and inexpensive devices from that line are Sonoff Basic and Sonoff mini. These are Wi-Fi enabled switches based on a great chip, ESP8266/ESP8285.
While the Sonoff may work quite well for basic users, others may want to hack to make own with their hardware. The hardware to build DIY Sonoff smart switches its low price: ESP8266 with 1MB flash, Relay LED, Button and power.
Next, to load the firmware to esp8266 you don't need a computer or laptop, just need an Android smartphone with an awesome app that is SwitchIoT, with this app makes an IoT device is as easy as uploading firmware without the need for registers/login and server configurations.
Which requires the lowest cost is using ESP-01 and the relay module.
Need an additional module USB to TTL converter for ESP-01 used when flashing the firmware only. You need to modify it by adding a button to connect the GPIO0 to GND so that when ESP-01 is turned on while the button is pressed and held it can enter flash mode.
Use an OTG to connect between USB TTL converter with Android smartphone.
Here you only need the Wemos board, relay, button and dual base shield with the header pins soldered.
You will easy to assemble it because it only stacked several shields together as in the picture, check the orientation of the pin not to reverse.
If you use a NodeMCU you need a breadboard to place it and to place the relay module. Need at least 3 pieces of jumper cable to connect as follows:
NodeMCU <===> Relay module
VIN <===========> VCC
GND <===========> GND
D0 <===========> IN
Use an OTG and micro USB cable to connect between NodeMCU and an Android smartphone.
NodeMCU <===> Relay module
VIN <===========> VCC
GND <===========> GND
D0 <===========> IN
Use an OTG and micro USB cable to connect between NodeMCU and an Android smartphone.
ESP8266/ESP8285 is programmed via the serial port. To flash Sonoff hardware you need an USB to TTL converter level 3.3V (PL2303) and dupont cable to connect it. You may need to solder a pin header on the PCB to easily connect a USB to TTL converter. Sonoff Basic R1/R2/R3/mini each pcb has different points of RX, TX, 3V3 & GND, you can see the mark according to the picture.
Basically you have to connect the PCB Sonoff with the USB to TTL converter as follows:
PCB Sonoff <==> USB to TTL
3V3 <==========> 3V3
RX <==========> TXTX <==========> RX
GND <==========> GND
After you finish setting up hardware with a smartphone, it's time you start upload the firmware into the ESP8266/ESP8285 chip. Wait before that make sure DO NOT CONNECT AC POWER during the flash cable connection.
Install SwitchIoT app from Google Playstore.
Open the SwitchIoT app, enter to widget settings menu, select the option "Upload firmware via USB", then specify the preset options according to the hardware that you will flash. Finally press the "UPLOAD" button and wait until this is done it will take a little time.
If you don't have an USB OTGIf you don't have an USB OTG or you are still at risk with your phone when uploading firmware from the phone, you can generate a firmware file in binnary format (eg. 0x00000_32e5_NodeMCU.bin) by tap "GENERATE .BIN" button on App then send it to email or online storage, next open it on your computer then uploaded firmware using software NodeMCU Flasher.