Revision [3010]
This is an old revision of SonoffSetup2017 made by ZorrUno on 2017-11-23 20:37:58.
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.
- - 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:
...... 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)
- - 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=drivesdkDevices
https://www.itead.cc/sonoff-wifi-wireless-switch.htmluseful youtube tutorials
https://www.youtube.com/watch?v=n4MDRm2yAJghttp://www.andremiller.net/content/programming-an-itead-sonoff-wireless-smart-switch-esp8266
Tasmota
Tasmota Firmware - clone as a ziphttps://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
Isues with USB serial
- in Ubuntu, I needed to add my user to the dialout groupsudo 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
Setup the firmware & flash
- Update the user_config.h with wireless SSID, Password and MQTT server details- 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
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