My newest purchase is the so called Sonoff mini, a very small device that can build in a wall mounting box. The excisting sonoff software had to be adapted because this thing has no possibilities to connect a sensor and one can't see the leds on the board. Moreover this thing is equipped with an ESP8285.
The promising "diy mode" realy sucks. I had to connect the device and a laptop through an accespoint (mobile hotspot) that i had set on my smartphone. I could'nt use my normal windows 10 pc to establish the connection. This only worked on a laptop. Anyway, after some hours i saw the device in my diy tools app. Next i spent a half day to find out that it is impossible to flash software on it over the air. Nobody knows why. So i soldered 4 wires on the very tiny solder pads on the board and flashed them at the old way. This worked fine within 15 minutes!.
working
improvements
While adapting the software to work on the mini i introduced some interesting novelties. A.o. i made it possible to have 2 users, one (administrator) with privileges to edit the configurations and the other (user) can only operate the switch.
Furthermore we can only connect a switch or a pushbutton to the mini. This forced me to find an other way to reboot and reset the device with the help of the switch/button.
The security of the switch is beter organized.
The administrator password can only be changed in the AP mode.
The administrator can grant a user with limited privileges.
The informationpage is more comprehensive with extra status information.
The administator now can reboot the device or start an AP.
We can choose whether daylightsavings applies in your country or not.
For the rest the Sonoff mini works as it used to, the button and the bleu led on the device works the same as the sonoff basic. We can control it completely via its webinterface as an internet controlled switch with timers to automate switching. Also the sonoff can send messages to domoticz regarding the state when switched manually.
Because it is so small it can be build build into a wall switch box or a wall socket. When you have an obsolete wall socket laying around...
There are only a few components involved. The total costs are about 5 Euro.
1 x Sonoff
1 x 5 pins header)
1 x usb to serial converter 3.3v
1 x 4 dupont wires
Building it:
The Sonoff-mini has an ESP8285 onboard and by soldering 4 wires to the board i could establish an uart serial connection and reflash the ESP.
The Sonoff can be booted in flashmode by pushing the button while putting the USB plug into the PC.
I used the arduino IDE to program the software and to upload it to the Sonoff-mini. The next softwareflashes can be done "over the air".
After soldering the wires the first thing was to flash the software 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 Arduino IDE, set the configuration to
flash size 1 MByte 64k SPIFFS, flash mode DOUT. Check the com port and click the upload button.
In the arduino IDE you can open a monitor on the serial port where you can see some debug information that the Sonoff-mini spits out.
After flashing the sonoff will boot in the new software, which you could observe on the monitor. Next software updates can be OTA so flashing it this way is one-off.
For questions you can mail to [email protected] style="color:red;"
The software:
The software has to be plug and play so that the Sonoff-mini can easely be installed in any network by anyone.
I used the library 'wifimanager' to develop my own configuration manager that allows to connect to the wifi network and configure some basic properties for the time, password and optional static IP.
working
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 is on contineously now. You cannot observe this when is is build in.
You can connect your PC or Phone wifi to this AP and your browser will open the config portal automatically. Or you can open a website with http://192.168.4.1. The ESP serves a webpage that allowes us to configure the network
credentials and more.
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 or switch.