Supercharge your Sonoff SNZB-02 Zigbee Temperature and Humidity Sensor with custom EFEKTA firmware from smartboxchannel.
Links in this article marked with a * are affiliate links. By purchasing through them I get a small commission that funds future projects!
I’ve reviewed Sonoff’s sensor in Battle of the Zigbees and I wasn’t impressed despite the low price. Neither was smartboxchannel of EfektaLab, a developer of DIY Zigbee devices, who made custom firmware for it.
This firmware supercharges the mediocre SNZB-02 wit new features. First and best improvement is a customisable report interval, default being 5 minutes and available range from 1 minute to 1 hour.
You (削除) get thresholds for too high or too low temperature and humidity alerts (削除ここまで) can make your own thermostat by binding to another Zigbee device. Finally you can set offsets to calibrate the readings.
smartboxchannel project GitHub has instructions for flashing using a TI CCDebugger (Amazon* or AliExpress*) but there’s a cheaper solution with a NodeMCU or D1 mini and a little program called CCLoader.
Lift the back plate, remove the battery then pull out the plastic battery holder to extract the PCB.
Put some solder on those pins and solder in the wires. When soldering take extra precaution to avoid solder bridging and shorts between wires. It doesn’t have to be pretty, you’ll remove the wires after it’s all done.
Connect the board to your computer with a data USB cable and make sure it is recognised by the system. If not install the required drivers for your board.
Download the CCLoader fork by Jason2866 by clicking on Download ZIP and unpack to a folder.
Flash the ESP8266 (NodeMCU) with the precompiled CCLoader_Arduino.bin from Bin folder of the downloaded zip file using your favorite ESP8266 flashing tool such as: ESP Flasher, NodeMCU-pyflasher, esptool.py, etc
Using the pinout image connect the ESP8266 pins to Sonoff sensor pins according to the table.
| Sonoff | ESP8266 | GPIO# |
|---|---|---|
| P2.1 | D5 | GPIO14 |
| P2.2 | D2 | GPIO4 |
| RST | D1 | GPIO5 |
| 3.3V | 3.3V | 3.3V |
| GND | GND | GND |
Download custom EFEKTA firmware from GitHub. If the file opens as text, right click, Save as... and save as sonoff.hex.
Download objcopy.exe from SourceForge and extract. (If objcopy.exe fails to run you need to download libiconv and extract to same folder.)
Copy the firmware .hex file to the same folder and convert it to .bin with:
objcopy.exe --gap-fill 0xFF --pad-to 0x040000 -I ihex sonoff.hex -O binary sonoff.bin
Move the converted .bin to your CCLoader folder.
Install the binutils package using your package manager (Debian based: sudo apt install binutils)
Copy the firmware .hex file to the same folder and convert it to .bin with:
objcopy --gap-fill 0xFF --pad-to 0x040000 -I ihex sonoff.hex -O binary sonoff.bin
CCLoader will use the NodeMCU with the flashed CCLoader binary as a bridge to upload the firmware to the Sonoff sensor.
Use CCLoader_x86_64.exe or CCloader.exe from \Windows folder. Place the prepared .bin in the same folder as CCLoader executable.
Command to start the flashing process. Change COM# to the COM port number only to which your ESP8266 is connected.
CCLoader_x86_64.exe [COM#] sonoff.bin 0
Example: with NodeMCU on COM6
CCLoader_x86_64.exe 6 sonoff.bin 0
First you have to compile CCLoader:
cd to CCLoader/SourceCode/Linuxrun
gcc main.c -o CCLoader
Place the prepared .bin in the same folder as the compiled CCLoader executable.
Command to start the flashing process
./CCLoader [port path] sonoff.bin 0
Example: with NodeMCU on /dev/ttyACM0
./CCLoader /dev/ttyACM0 sonoff.bin 0
CCloader will start to count up, wait until the command prompt reappears. Firmware flash was successful if you see this:
Upload successfully!
File closed!
Comport closed!
If flashing fails or gets stuck at Request sent already! Waiting for respond...:
1 instead of 0 in the last parameterAfter a completed flash you can leave the sensor PCB powered by the NodeMCU and check whether it pairs. Hold the pairing button for 2 to 3 seconds until the red light starts flashing to put the custom firmware in pairing mode.
Holding the reset button for 10 seconds will reset device to custom firmware defaults.
It successfully paired with Zigbee2MQTT and ZHA but ZHA didn’t have all the features available in the device card.
2022年09月23日 addendum by the firmware author
In my firmware, the sensor, in fact, turns into a thermostat and a hydrostat. I will describe how it works. After adding the sensor to the Zigbee network, it can be linked, for example, to a relay. After connecting to the relay on the settings page, you need to set the temperature and / or humidity thresholds and activate the control. The sensor will then send on and off commands directly to the appropriate relay. Since almost all relays are routers, in fact, this tandem can work even if the network is lost, even if you turn off the network coordinator or your HA goes down.
And since everything is now working on the correct clusters, now this sensor can be tied to other devices using temperature and humidity clusters.
Link to author’s guide.
That is very impressive!
This is Zigbee2MQTT with default Sonoff firmware.
There’s a cornucopia of new features when using Zigbee2MQTT.
More settings can be found in Zigbee2MQTT frontend where you can set offsets for temperature and humidity readings and adjust reported value decimal point precision.
Z2M Frontend has even more features
The "Opening" entity is out of place and it definitely needs a quirk to add all the new features.
Comments