I bought me some Sonoff ip switches on Ebay. I wanted to hack the devices to put my own software on them.
The Sonoff has an ESP8266 onboard and by soldering a header i could establish an uart serial connection and reflash the ESP.
The software has to be plug and play so that it can easely be installed in any network by anyone.
I already developped software for other ESP8266 projects so i could port this to the Sonoff.
The Sonoff has a button on pin gpio0 and an LED on gpio13. So the challenge was to make it possible to switch the Sonoff on and off
by using the pushbutton and also control it via its website.
So how does it work:
When the device is powered on, it tries to connect to a network. When this doesn't succeed, it starts an accesspoint. The led flashes contineously now. You can connect your PC or Phone wifi to this AP and then open a website with http://192.168.4.1. The ESP serves a webpage that allowes us to configure the network credentials, a fixed ip address, port name and optional a password. When this is done, the Sonoff restarts, checks if there's a network connection and than starts in Station mode. The led flashes 3 times. Now we can switch it via its webpage and by using the button.
After soldering the header the first thing was to flash nodeMCU firmware to the device. Connect the device to an usb-serial convertor (3,3v!!!)
and plug this in the pc while holding the button down. The device is in flashmode now. Open ESP8266flasher.exe, alter the configuration to
baudrate 230400, flash size 1 MByte, Flash speed 40MHz an SPI mode DIO. Check the com port and click "flash(F)"
Next I downloaded and installed LuaLoader on my PC. This programm alowes me to speek with the ESP, upload LUA scripts and pass commands. I started LuaLoader.exe and opened the COMport on which the USB-Serial is plugged in. I restarted the board and now I can see something in the terminal hapening, proving that there is communication.
You can download the files via "privat" "cloud" on this server. Login with "iedereen" and "welkom". Under "programma's you will find
esp-sdk.zip, this contains ESP8266flasher.exe and lualoader. There is a version of the software that works with a password and one without password. "ip_lamp_sonoff_rev-bla.zip" The lua scripts have to be compiled
after uploading and then removed (except for init.lua). This to avoid out of memory problems. Sometimes when "not enough memory" it helps to restart and immediately press tmr(stop)
It's a real ip-swith for a little more than 5 euro...
connections for flashing
For questions you can mail to email@example.com