This is Sonoff basic plugin for Homebridge. You will need some soldering works to gain access to flash ESPEasy firmware.
-
Switch on / off.
You can now ask Siri to turn on / off any device!
-
Pulse to on / off the device after X seconds.
Sonoff Basic | Soldering Iron Pen | Header Pins |
Tin Lead Rosin Core (<0.5mm) | Female-to-female Dupont Wire Cables | TTL to USB Adaptor |
Notes: You can easily get these hardware from eBay at cheap price.
-
Open the case of Sonoff and take out the board.
-
Lay it on the table and solder 5 header pins as show in the picture below. WARNING: Please make sure the switch is not connected to live socket.
-
Plug in the four dupoint wires.
-
Connect the wires to TTL to USB adaptor.
The correct position is as following:
- Red: 3v3
- Green: TXD
- Yellow: RXD
- Blue: GND
**Notes: ** Some TTL to USB adaptor may not working in this way. If the device is not connected correctly, swap the position of Green (TXD) and Yellow (RXD) wire.
-
Download ESPEasy R148 firmware from here. This is the version that works perfectly with Sonoff basic. I was facing serious connection issue when I flashed with R120 firmware as recommended in the official website.
-
Unzip the downloaded package.
-
Press and hold the button on Sonoff basic, plug the TTL to USB adaptor to PC. Release the button once plugged.
-
Press
WIN
+R
on keyboard and typedevmgmt.msc
to open device manager. Check under Ports (COM & LPT) section to find out the COM port used by the adaptor.
-
Press
WIN
+R
on keyboard and typecmd
to open command line. -
Go the folder where ESPEasy located.
-
Execute the
flash
to start flashing the firmware into Sonoff. -
Enter following details when prompted.
**Notes: ** Comport is the port you got from Step 8.
-
Wait around 3~5 minutes. You should see following output when firmware is successfully flashed.
-
Unplug the USB and plug in again to let Sonoff reboot.
-
Wait about 3~5 minutes and Sonoff will creates a new Wi-Fi access point called ESP_0.
-
Connect your PC to the network with password
configesp
. -
Open web browser and go to
http://192.168.4.1
. -
Go through the setup to connect Sonoff to your Wi-Fi network.
-
[Optional] The design of ESPEasy web interface is really hurting my eyes. I have customized a style sheet here. Go to
Tools
>Settings
>Load
, upload the esp.css to change the interface. -
Now, go to
HARDWARE
section, select GPIO-13 (D7) for Wifi Status Led to enable the green LED light on Sonoff. Submit the changes. -
Go to
DEVICES
section, editTask #1
. Insert the values as the picture below and submit.
-
Edit
Task #2
, insert values as picture below and submit.
-
We have enabled the hardware GPIO to work, now we need to configure the rules for HTTP request.
-
Go to
RULES
section, insert the following codes and submit.On PowerOn Do gpio,12,1 EndOn On PowerOff Do gpio,12,0 EndOn On Button#State Do If [Button#State] = 0 gpio,12,0 gpio,13,1 Else gpio,12,1 gpio,13,0 EndIf EndOn
The codes above contains 3 sections. The
PowerOn
part is to turn on the switch,PowerOff
part is to turn of the switch.Button#State
is the part to handle the physical button on Sonoff, so you can toogle the button to turn on/off the switch. -
Finally, the Sonoff basic switch is fully customized. Connect it to a live socket.
-
Install required packages.
npm install -g homebridge-sonoff-basic-espeasy request
-
Add following lines to
config.json
."accessories": [ { "accessory": "SonoffBasicESPEasy", "name": "Living Room Switch", "type": "switch", "ip": "IP_ADDRESS_OF_THE_SONOFF_BASIC" }, { "accessory": "SonoffBasicESPEasy", "name": "Living Room Switch Pulse Off", "type": "switch", "ip": "IP_ADDRESS_OF_THE_SONOFF_BASIC", "pulse" true, "action": "off", "duration": 60 } ]
Type supported:
- switch
- outlet
Pulse is false by default . Set it true to use pulse, then set the action to on or off. Duration is counted in seconds.
-
Restart Homebridge, and your Sonoff basic a will be added to Home app.
See the LICENSE file for license rights and limitations (MIT).