Using the Sonoff 4 Channel with Tasmota Firmware

Last time we looked at using Amazon Alexa to control our smart home lights, with a Sonoff basic and the Tasmota firmware. Sonoff also make other devices, and in this post we’ll be looking at the 4 channel “smart switch” to switch 4 separate mains devices.

You will need

Firmware Update

As we did with the basic the 1st step is to flash our devise with the Tasmota firmware.4ch open.JPG

  1. Step 1 is to remove the 4 screws holding the cover on.
  2. Fortunately the manufacturer has done us a favour here and already soldered header pins on the programming interface. Note the TX and RX labels are the wrong way round.4ch header.JPG
  3. Our programming cable, we made earlier should work fine to connect up the programmer.4ch programmer.JPG
  4. If you remember from last time, you will know that we need to put the Sonoff into program mode. Hold down the button marked FW/IO0 whilst we plug the programmer into the USB port on our PC.4ch buttons.JPG
  5. Next open Tools > Board: and select Generic ESP8285 Module.
  6. Then check the other tools options are set correctly:
    • Upload Using: Serial
    • CPU Frequency: 80MHz
    • Flash Size: 1M (no SPIFFS)
    • Upload Speed: 115200
    • Port: the COM port your programmer is connected to.
      esp8285 tools menu
  7. Finally click upload, to verify and load the new firmware.

Final Configuration

  1. Check your router to identify the IP address it has given the Sonoff.
  2. Open the webpage at this address.
  3. First thing we need to change is the module type. Open Configuration > Configure Module and change Module Type to 07 Sonoff 4CH.sonoff 4chan
  4. Next open Configuration > Configure MQTT and change Topic to identify your device.
  5. Lastly if you didn’t enter the details of your MQTT broker in the config file, now is the time.

Feel free to try accessing your device over MQTT. The commands are the same as the Sonoff Basic, but with the addition of a number to identify the channel e.g. cmnd/sonoff-myswitch/POWER1.

Finally we add the device to openHAB

  1. Open the sonoff items file: \\OPENHABIANPI\openHAB-share\openhab2-conf\items\sonoff.items, and add the following lines:
    //My Switch
    Switch My_Switch_1 "Some Lights"  (Lights) ["Lighting"]
     { mqtt=">[mybroker:cmnd/sonoff-myswitch/power1:command:*:default],
     <[mybroker:stat/sonoff-myswitch/POWER1:state:default]" } 
    Switch My_Switch_2 "Some Things" ["Switchable"] 
     { mqtt=">[mybroker:cmnd/sonoff-myswitch/power2:command:*:default],
     <[mybroker:stat/sonoff-myswitch/POWER2:state:default]" } 
    Switch My_Switch_3 "Some Other Lights"  (Lights) ["Lighting"] 
     { mqtt=">[mybroker:cmnd/sonoff-myswitch/power3:command:*:default],
     <[mybroker:stat/sonoff-myswitch/POWER3:state:default]" } 
    Switch My_Switch_4 "Not Used"  
    { mqtt=">[mybroker:cmnd/sonoff-myswitch/power4:command:*:default],
     <[mybroker:stat/sonoff-myswitch/POWER4:state:default]" }
  2. Open your sitemap file: \\OPENHABIANPI\openHAB-share\openhab2-conf\sitemaps\default.sitemap, and add the following lines:
    Switch item=My_Switch_1
    Switch item=My_Switch_2
    Switch item=My_Switch_3

That’s it. We’re done.

Don’t forget to use meaningful descriptions for your devices, so you can control it with your Echo.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s