Wiki source for SonoffSetup2017
======Flashing and using a Sonoff with Tasmota firmware======
====Final Setup Test====
Once flashed, I set the 'startup mode' to be on, so it can be used as a normal switch. I didn't really have to worry about running buttons into its i/o.
Then, whenever mains is switched on, it turns on... and turn on time seems to be about half a second, so pretty much little difference noticeable between that and a normal switch. About 25 seconds later it will pick up the on/off value from mqtt server (if it is available)
**Advantages with this setup:**
I can just chuck in a sonoff in a light circuit anywhere, and set it up (eg pull out a downlight and install a sonoff in-line). I use the existing main switch - and it works normally without any mqtt server running. Later I put some buttons in another flush box beside the mains switch (ELV buttons, connected to the sonoff, or a sonoff dev or NodeMCU etc), and cover the mains switch with a flip pdl plates. The new buttons just change the values in MQTT server.
-
**I then get:**
- - local mains isolation with the pdl switch (but covered so it isn't bumped)
- - lights useable with no mqtt and/or wifi running... with the following disadvantages:
...... I'll be wasting power if power outage occurs and wifi/mqtt doesn't come back up
...... There will be some annoyance in a power outage, with possibly 30 seconds of lighting at night after a power cut until sonoff connects back to wifi/mqtt
- - ability to split lighting ccts in the ceiling space (no need to get into the mains flush box... just throw in more cable and another sonoff)
..... obviously this only works with wifi/mqtt running though
- - I can put a ceiling fan on the same isolation cct, but control it with sonoffs (using 4 channel)
====Bulk Sonoff Order, August 2017====
https://docs.google.com/spreadsheets/d/1eKHTiDvcRtCvblBAWTz8rt6XeRTrIfBDK974giLYWFE/edit?usp=drivesdk
==== Sonoff RF Bridge (2018 version)====
Ensure switch on Bridge is off in programming mode, Remember to switch it back on in use.
The button is onnected to D0... for programming/flashing hold in on power up.
Pins TDI: Blue GND, CTS (No connection) Orange VCC, Green (TXD), Yellow (RXD), DTR (No Connection)
Sonoff: Blue (GND), Yellow (TX), Green (RX), Orange (VCC 3.3v)
Pic of the correct FTDI connections.
https://photos.app.goo.gl/EAVtb427VNELB9a33
Note, I could not get programming work work on the headers in the middle... are they the same pins?? not sure - see photos (and links below) for the correct header location to use.
**Info on new RF Bridge Layout**
https://github.com/arendst/Sonoff-Tasmota/issues/1126
https://github.com/arendst/Sonoff-Tasmota/issues/1916
**Adding remotes and 433 devices to an RF Bridge**
https://github.com/arendst/Sonoff-Tasmota/issues/1181
Essentially you go to the console (via the web interface) and type RfKey1 2 . The sonoff will beep once, then you press a button on the remote. The Sonoff will beep a couple of times.
** 4 Channel Switch**
https://photos.app.goo.gl/VJg2FZHWuzAYtyGM6
====Devices====
https://www.itead.cc/sonoff-wifi-wireless-switch.html
====useful youtube tutorials====
https://www.youtube.com/watch?v=n4MDRm2yAJg
http://www.andremiller.net/content/programming-an-itead-sonoff-wireless-smart-switch-esp8266
====Tasmota====
Tasmota Firmware - clone as a zip
https://github.com/arendst/Sonoff-Tasmota
====Atom Text Editor with platform i/o====
- install Atom https://atom.io/
- install packages, "platform-ide" (from within the Atom menus - recent versions... it may already be installed))
- Atom complained clang wasn't installed, needed to install in ubuntu
%%sudo apt-get install clang
%%
- had issues with Clang in Ubuntu... Go to Atom's Preferences menu, click packages, autocomplete-clang, settings, and change 'Clang Command" from "clang" to clang-4.0 (or the version running on your linux)
- Open Project, click on the Sonoff-Tasmota-development folder
====Issues with USB serial====
- in Ubuntu, I needed to add my user to the dialout group
%%sudo adduser $USER dialout%%
- Probably need to logout and in again to make this work
Later I had more permissions on this TTY and had to change permissions on this port
%%sudo chmod a+rw /dev/ttyUSB0%%
- The UDev rules should be added to. Platform I/O suggests this (as root)
%%curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/scripts/99-platformio-udev.rules > /etc/udev/rules.d/99-platformio-udev.rules%%
http://docs.platformio.org/en/latest/faq.html#platformio-command-not-found-an-error-pkg-resources-distributionnotfound
====Setup the firmware before flashing====
- Update the user_config.h with wireless SSID, Password (as MINIMUM) and MQTT server details
- change the value of #define CFG_HOLDER - otherwise the values won't stick. Suggest incrementing by 1.
- save
====Connect Sonoff====
- https://github.com/arendst/Sonoff-Tasmota/wiki/Hardware-Preparation
- solder the board pins (see tutorials everywhere)
- Set up a usb ftdi/serial programmer (I got a ch340g for $8 from trademe)
- make sure you set it to 3.3V...
Pins TDI: Blue GND, Orange VCC, Green TXD, Yellow RXD
Sonoff: Tot to bottom: Blue (GND), Yellow, Green, Orange (VCC 3.3v)
- connect up the sonoff in programming mode (hold button and power up, release)
- in the Sonoff-Tasmota-development folder is a platformio.ini file. Click on it
- in Atom PlatformIO menu, click upload
====Monitor the serial happenings====
- Use Atoms inbuilt serial monitor 115200, /dev/ttyUSB0 (in my case)
- check serial data for IP of device and that it connects to wifi etc. This will help a lot if it isn't doing what you think it should.
====Configure it more on its web interface if you like====
- my device is at http://192.168.1.113/ - it runs a web server for config etc
- Can also add new firmware like this if needed
====MQTT====
- Get a MQTT client, I used MQTTlens for chrome, mqttfx was too flakey
- subscribe to stat/sonoff/POWER (seems to need caps?)
- publish cmnd/sonoff/power toggle (or on/off)
====MQTT Example for 4 Channel====
Publish cmnd/sonoff-mollie-fan/power4 with a message of 1
--
CategoryMicrocontrol
CategoryHomeAutomation
CategoryLinux
====Final Setup Test====
Once flashed, I set the 'startup mode' to be on, so it can be used as a normal switch. I didn't really have to worry about running buttons into its i/o.
Then, whenever mains is switched on, it turns on... and turn on time seems to be about half a second, so pretty much little difference noticeable between that and a normal switch. About 25 seconds later it will pick up the on/off value from mqtt server (if it is available)
**Advantages with this setup:**
I can just chuck in a sonoff in a light circuit anywhere, and set it up (eg pull out a downlight and install a sonoff in-line). I use the existing main switch - and it works normally without any mqtt server running. Later I put some buttons in another flush box beside the mains switch (ELV buttons, connected to the sonoff, or a sonoff dev or NodeMCU etc), and cover the mains switch with a flip pdl plates. The new buttons just change the values in MQTT server.
-
**I then get:**
- - local mains isolation with the pdl switch (but covered so it isn't bumped)
- - lights useable with no mqtt and/or wifi running... with the following disadvantages:
...... I'll be wasting power if power outage occurs and wifi/mqtt doesn't come back up
...... There will be some annoyance in a power outage, with possibly 30 seconds of lighting at night after a power cut until sonoff connects back to wifi/mqtt
- - ability to split lighting ccts in the ceiling space (no need to get into the mains flush box... just throw in more cable and another sonoff)
..... obviously this only works with wifi/mqtt running though
- - I can put a ceiling fan on the same isolation cct, but control it with sonoffs (using 4 channel)
====Bulk Sonoff Order, August 2017====
https://docs.google.com/spreadsheets/d/1eKHTiDvcRtCvblBAWTz8rt6XeRTrIfBDK974giLYWFE/edit?usp=drivesdk
==== Sonoff RF Bridge (2018 version)====
Ensure switch on Bridge is off in programming mode, Remember to switch it back on in use.
The button is onnected to D0... for programming/flashing hold in on power up.
Pins TDI: Blue GND, CTS (No connection) Orange VCC, Green (TXD), Yellow (RXD), DTR (No Connection)
Sonoff: Blue (GND), Yellow (TX), Green (RX), Orange (VCC 3.3v)
Pic of the correct FTDI connections.
https://photos.app.goo.gl/EAVtb427VNELB9a33
Note, I could not get programming work work on the headers in the middle... are they the same pins?? not sure - see photos (and links below) for the correct header location to use.
**Info on new RF Bridge Layout**
https://github.com/arendst/Sonoff-Tasmota/issues/1126
https://github.com/arendst/Sonoff-Tasmota/issues/1916
**Adding remotes and 433 devices to an RF Bridge**
https://github.com/arendst/Sonoff-Tasmota/issues/1181
Essentially you go to the console (via the web interface) and type RfKey1 2 . The sonoff will beep once, then you press a button on the remote. The Sonoff will beep a couple of times.
** 4 Channel Switch**
https://photos.app.goo.gl/VJg2FZHWuzAYtyGM6
====Devices====
https://www.itead.cc/sonoff-wifi-wireless-switch.html
====useful youtube tutorials====
https://www.youtube.com/watch?v=n4MDRm2yAJg
http://www.andremiller.net/content/programming-an-itead-sonoff-wireless-smart-switch-esp8266
====Tasmota====
Tasmota Firmware - clone as a zip
https://github.com/arendst/Sonoff-Tasmota
====Atom Text Editor with platform i/o====
- install Atom https://atom.io/
- install packages, "platform-ide" (from within the Atom menus - recent versions... it may already be installed))
- Atom complained clang wasn't installed, needed to install in ubuntu
%%sudo apt-get install clang
%%
- had issues with Clang in Ubuntu... Go to Atom's Preferences menu, click packages, autocomplete-clang, settings, and change 'Clang Command" from "clang" to clang-4.0 (or the version running on your linux)
- Open Project, click on the Sonoff-Tasmota-development folder
====Issues with USB serial====
- in Ubuntu, I needed to add my user to the dialout group
%%sudo adduser $USER dialout%%
- Probably need to logout and in again to make this work
Later I had more permissions on this TTY and had to change permissions on this port
%%sudo chmod a+rw /dev/ttyUSB0%%
- The UDev rules should be added to. Platform I/O suggests this (as root)
%%curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/scripts/99-platformio-udev.rules > /etc/udev/rules.d/99-platformio-udev.rules%%
http://docs.platformio.org/en/latest/faq.html#platformio-command-not-found-an-error-pkg-resources-distributionnotfound
====Setup the firmware before flashing====
- Update the user_config.h with wireless SSID, Password (as MINIMUM) and MQTT server details
- change the value of #define CFG_HOLDER - otherwise the values won't stick. Suggest incrementing by 1.
- save
====Connect Sonoff====
- https://github.com/arendst/Sonoff-Tasmota/wiki/Hardware-Preparation
- solder the board pins (see tutorials everywhere)
- Set up a usb ftdi/serial programmer (I got a ch340g for $8 from trademe)
- make sure you set it to 3.3V...
Pins TDI: Blue GND, Orange VCC, Green TXD, Yellow RXD
Sonoff: Tot to bottom: Blue (GND), Yellow, Green, Orange (VCC 3.3v)
- connect up the sonoff in programming mode (hold button and power up, release)
- in the Sonoff-Tasmota-development folder is a platformio.ini file. Click on it
- in Atom PlatformIO menu, click upload
====Monitor the serial happenings====
- Use Atoms inbuilt serial monitor 115200, /dev/ttyUSB0 (in my case)
- check serial data for IP of device and that it connects to wifi etc. This will help a lot if it isn't doing what you think it should.
====Configure it more on its web interface if you like====
- my device is at http://192.168.1.113/ - it runs a web server for config etc
- Can also add new firmware like this if needed
====MQTT====
- Get a MQTT client, I used MQTTlens for chrome, mqttfx was too flakey
- subscribe to stat/sonoff/POWER (seems to need caps?)
- publish cmnd/sonoff/power toggle (or on/off)
====MQTT Example for 4 Channel====
Publish cmnd/sonoff-mollie-fan/power4 with a message of 1
--
CategoryMicrocontrol
CategoryHomeAutomation
CategoryLinux