Skip to content

jungervin/homebridge-sonoff-basic-espeasy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

homebridge-sonoff-basic-espeasy

This is Sonoff basic plugin for Homebridge. You will need some soldering works to gain access to flash ESPEasy firmware.

Sonoff Basic

Features

  • Switch on / off.

    You can now ask Siri to turn on / off any device!

Preparation

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

Instructions
  1. Open the case of Sonoff and take out the board.

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

  3. Plug in the four dupoint wires.

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

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

  6. Unzip the downloaded package.

  7. Press and hold the button on Sonoff basic, plug the TTL to USB adaptor to PC. Release the button once plugged.

  8. Press WIN + R on keyboard and type devmgmt.msc to open device manager. Check under Ports (COM & LPT) section to find out the COM port used by the adaptor.

  9. Press WIN + R on keyboard and type cmd to open command line.

  10. Go the folder where ESPEasy located.

  11. Execute the flash to start flashing the firmware into Sonoff.

  12. Enter following details when prompted.

    **Notes: ** Comport is the port you got from Step 8.

  13. Wait around 3~5 minutes. You should see following output when firmware is successfully flashed.

  14. Unplug the USB and plug in again to let Sonoff reboot.

  15. Wait about 3~5 minutes and Sonoff will creates a new Wi-Fi access point called ESP_0.

  16. Connect your PC to the network with password configesp.

  17. Open web browser and go to http://192.168.4.1.

  18. Go through the setup to connect Sonoff to your Wi-Fi network.

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

  20. Now, go to HARDWARE section, select GPIO-13 (D7) for Wifi Status Led to enable the green LED light on Sonoff. Submit the changes.

  21. Go to DEVICES section, edit Task #1. Insert the values as the picture below and submit.

  22. Edit Task #2, insert values as picture below and submit.

  23. We have enabled the hardware GPIO to work, now we need to configure the rules for HTTP request.

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

  25. Finally, the Sonoff basic switch is fully customized. Connect it to a live socket.

Installation

  1. Install required packages.

    npm install -g homebridge-sonoff-basic-espeasy request
    

  2. Add following lines to config.json.

      "accessories": [
        {
          "accessory": "SonoffBasicESPEasy",
          "name": "Living Room Switch",
          "ip": "IP_ADDRESS_OF_THE_SONOFF_BASIC"
        }
      ]
    

  3. Restart Homebridge, and your Sonoff basic a will be added to Home app.

License

See the LICENSE file for license rights and limitations (MIT).

About

A Sonoff basic plugin for Homebridge. Based on ESPEasy firmware.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 54.1%
  • CSS 45.9%