Lots of different cheap plugs can be modified like this.
The plugs we are using (ebay link – Lingan SWA1) were chosen because they are easy to disassemble and solder, and they’re cheap. Nearly all smartplugs use esp8266 and can be modified in similar way. I’ve probably hacked up a dozen or so different models.
The files and firmware used for this workshop are HERE.
The programmers we used at Kernelcon ended up being trash, i’m going to get them refunded. A standard FTDI programmer is what’s needed to flash and interact with an esp8266. THIS looks to be a good one. I’m going to order several and will report back.
the configuration, notes, files, and writeup details for getting snips.ai to work will be posted here in the next few days
Why do this?
Local control — ALL! stock firmware beacons to 3rd-party servers (many in China), and some beaconing/leakage includes wifi ssid and password in cleartext.
First, we will replace the stock device firmware with Tasmota, which is open-source and auditable. Tasmota is very well documented (https://github.com/arendst/Sonoff-Tasmota).
We will connect to a local MQTT instance for control and device state tracking (http://www.mqtt.org/)
We will use home-assistant to interact with our MQTT instance for graphical control and other functionality.
We will use the SNIPS voice platform to enable voice controlled devices using 100% local/on-device voice processing (#nocloud) A core value of home assistant (and me, personally) is to rely on cloud services as little as possible. I want my stuff to work irrespective of internet status or cloud provider status.
We will be primarily focusing on the smartplug modification itself — not on installing home-assistant or the mosquitto MQTT broker software. We have limited time in this workshop, and there are many other excellent tutorials for home-assistant on the home-assistant forums.
Open, separate — remove 2 small screws
solder on header —
With the shiny chip part facing up, insert the SHORT end of the header pins into the holes, flip the board over so the newly-installed header pins point down at the table, we will solder them from the backside. It’s usually easiest to hold the soldering iron in your dominant hand, and the other hand holds the chip down against the table with some force to keep the header pins in the holes while also holding the solder.
Touch the hot soldering iron to the metal ring around the hole and the pin at the same time, heat the metal up and touch the solder, the solder will liquify and flow into the hole.
Plug programmer into USB…wait a few seconds…then move finger and let screw drop (carefully, don’t lose it)
Open “Kernelcon” folder on desktop – double-click “MV Flash”, specify COM4, and watch the magic happen….
if you see an error about connection failure, you didn’t have the screw shorting GPIO-0 and GROUND solid enough. try the process again (we can help!)
After the flash completes, leave the programmer connected.
in the Kernelcon folder, open the Termite – Client application
Configure to proper COM port (probably com4)
unplug/replug the VCC (5 volt) wire from your smartplug header
In Termite, in the bottom text input area — type “RESET 1” and press enter
note the SSID shown. It will be sonoff-XXXX
Connect to SSID with laptop…browser should open automatically to wifi configuration page
click “scan for wifi networks”
enter password: hackspaceio
apply –> module will reset
Note the new IP address in the Termite console application (192.168.128.XXX) , note this down..
Unplug programmer from USB port, disconnect from smartplug
re-assemble smartplug (small board first)
Plug into outlet — use browser to access HTTP interface via IP written down above
click ‘configuration‘ then click ‘configure module‘ — use below settings. This makes the buttons and indicator lights work properly by mapping them to the correct control pins
Click SAVE. Module will restart.
click ‘configuration‘ then click ‘configure MQTT‘
the topic needs to be something unique….perhaps your name.
the mqtt server for our workshop is 192.168.128.15, it runs on port 1883
with respect to MQTT Topic — for the smartplugs that i use, i name them by the plug name/style and the last 4 of the MAC address, so… northplug_bac3. For this workshop, you can use whatever you want , you’ll just have to share it with me to get it entered into the home-assistant config for testing.
Click SAVE. Module will reboot.
Click CONSOLE — you should see “connected”
you should be able to toggle the relay from the main page of the smartplug interface.
at this point, you can share your MQTT topic with me and I can add it to home assistant for the final demonstrations.
when you take your cool new locally-controlled plug home, it will revert to soft-AP mode since the kernelcon-iot network doesn’t exist at your home. Connect with phone/laptop and properly configure your home SSID and password…and MQTT server info 🙂
final notes— if you do NOT have home assistant and don’t want to run it at your house, but you have an amazon alexa/google home — you can enable “wimos emulation” on your newly modified smartplug for voice control without a hub. Configuration — Configure Other — Wemos Emulation.
If you have wifi configuration issues, please see here for information on using the physical button to reset wifi settings to default and enable the built-in AP. https://github.com/arendst/Sonoff-Tasmota/wiki/Button-usage