Make a DIY Sonoff Smart Switch Use Android App

About: I am an electronic-enthusiast, maker, developer Android app, hobbyist and an owner of Bluino Electronics.

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 infrastructure 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.

This tutorial will tell you how to make a DIY Sonoff smart switch using several different hardware models.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Make a DIY Sonoff Smart Switch Use ESP-01

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.

Step 2: Make a DIY Sonoff Smart Switch Use Wemos and Relay, Button Shield

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.

Use an OTG and micro USB cable to connect between Wemos and an Android smartphone.

Step 3: Make a DIY Sonoff Smart Switch Use NodeMCU and Relay Module

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.

Step 4: Make a DIY Sonoff Smart Switch Use Bluino IoT Starter Kit

The Bluino IoT Starter Kit already has Wemos board, relay, LED and button. You will use a relay connected to pin D6, LEDs connected to pin D0 and a button connected to pin D1. Use an OTG and micro USB cable to connect between Wemos and an Android smartphone

Step 5: Flash Sonoff Basic R1/R2/R3/mini With SwitchIoT Firmware

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 <==========> TX

TX <==========> RX

GND <==========> GND

To able flash sonoff first you must enter to flash mode, do it by holdding and pressing button when you insert OTG to smartphone to power up.

Step 6: Uploading Firmware From Android to ESP8266/ESP8285 Use SwitchIoT App

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.

SwitchIoT App

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 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.

Step 7: Connect SwitchIoT Device to a Network

After uploading is done, turn on the hardware and see what happens. The first time the status LED will blink rapidly, it means the device is not connected to any network (or in AP mode with hostname siot-xxxx), you need to add the network that will be used by the device.

Open App go to setting and choose menu "Connect device to network", confirm status LED of SwitchIoT device is blinks rapidly, connect your smartphone to a network with hostname siot-xxxx after that fill in the SSID and password a network that will be used by the SwitchIoT device. Then press "CONNECT", wait until it's done.

Step 8: Knowing Status LED Indicator

There are several conditions when the SwitchIoT device operates, it visible with changing of status LED.

1. The LED blinks rapidly, it means failed to connect with your router, it could be caused by:

  • The WiFi strength is weak. Your router is too far away from your device, and there may be some interference in the environment. To solve it, please take your SwitchIoT device close to the router. If the problem still exists, please reset SwitchIoT device, reconnect to a network by add a network setting use App follow previous step.
  • WiFi SSID and password stored in the SwitchIoT device has been forgotten, this can happen by pressing the button on SwitchIoT device for 5 seconds. you need reconnect to a network by add a network setting use App previous step.

2. The LED blinks once every 4s, it means fail to connect to the server, it could be caused by the network unable to access the Internet. Please check your network service connections and reset SwitchIoT device.

3. The LED steady on, it means SwitchIoT device works and connected to the server.

Step 9: Share SwitchIoT Token With Other User

SwitchIoT device owner can share fully control of the devices to others, and thus others can turn on/off, change schedule, timer, looptimer and name the device on SwitchIoT app. This functionality is great for the family as it will be allow them to control together.

The way to share SwitchIoT device tokens is very easy, you only need to share the unique tokens to others, and they just paste it into the SwitchIoT app.

The token of each SwitchIoT device is unique and is generated from your Android smartphone, therefore this token is permanent, you must handle it with care to share it with others.

Step 10: Control Multipile the Same SwitchIot Device

The unique tokens can be allowed to be accessed by more than one app and more than one SwitchIoT device. With this feature you can create schemes such as two switchiot devices and SwitchIoT app that can be controlled together. If one SwitchIoT device is ON then the other SwitchIoT device also follows the same conditions ON, as well as the app.

Step 11: Enjoy

Hopefully you enjoy your SwitchIoT. If you do and done, please share "I Made it!" to let me know how much is worked. Share the link, like and subscribe. As always, if you have any questions please let me know!

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    Discussions