I got Sonoff Basic and first thing after unpacking was flashing to Tasmota and integrate it with my OpenHAB. Further step is replace switch in my stand lamp over table and use 3rd gang in Sonoff T0 Wall switch to control it.
I made video how to prepare hardware and flash with Tasmota firmware:
There are also OpenHAB files required for MQTT communication between modules. Everything you find also here step by step.
Hardware preparing
Before you flash Sonoff Basic you have to go inside and identify pins for soldering in order to connect your FTDI USB flasher.
See photo above.There are pins marked: 3V3/RX/TX/GND. I soldered female pins to get easier to flash later.
For flashing we do not need I02. Basically 4 pins should be fine. Hardware prepared.
Software flashing
Flashing Sonoff Basic is pretty simple. There is not much difference between flashing Sonoff RF Bridge and any other ESP8266. I covered flashing in more details in THIS post. Please with it familiar first.
I downloaded the most recent version of Tasmota v6.6.0 . Just sonoff normal version. I assume that you have esptool, sonoff firmware. Before you connect flasher you have to keep button pushed. Then press enter and flashing process should begin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
greg-lap /home/greg/sonoff # ./esptool-2.7/esptool.py --port /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x0 sonoff.bin esptool.py v2.7 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8285 Features: WiFi, Embedded Flash Crystal is 26MHz MAC: 2c:f4:32:be:b4:ab Uploading stub... Running stub... Stub running... Configuring flash size... Compressed 515872 bytes to 355877... Wrote 515872 bytes (355877 compressed) at 0x00000000 in 32.0 seconds (effective 129.0 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin... |
done.
Initial configuration
First steps after flashing are very similar to EspEasy firmware. Also as there we get additional AP in our WiFi networks.
Connect your Sonoff Basic to a power source and grab your smartphone (or tablet or laptop or any other web and Wi-Fi capable device). Search for a Wi-Fi AP named sonoff-xxxx (where x is a number) and connect to it. In this example the Wi-Fi AP is named sonoff-5291 When it connects to the network, you may get a warning that there is no Internet connection and be prompted to connect to a different network.
After you have connected to the Tasmota Wi-Fi AP, open http://192.168.4.1 in a web browser on the smartphone (or whatever device you used). Some devices might prompt you to sign in to Wi-Fi network which should also open the above address. In configuration UI follow steps to add your home AP. After applying settings Sonoff Basic will be trying to connect there. From now you may access it from your network.
If you don’t have access to your router you can find your newly flashed device with an IP scanner:
- Fing – for Android or iOS
- Angry IP Scanner – open source for Linux, Windows and Mac.
- Super Scan – Windows only too (free)
- Tasmota Device Locator – Browser-based
As the sonoff.bin is general solution for various supported hardware you have to configure it to support Sonoff Basic. Please find screenshots with ready to use settings.
First configure module and select Sonoff Basic unless is not automatically detected.
Let’s adjust also logging:
Enable MQTT and define topics/hostname
Finally after few restarts you should get default view of Sonoff Basic with button state.
OpenHAB Configuration
As usual I put OpenHAB configuration snippets. I put also for context previously configured here and here items. For you relevant entries for Sonoff Basic were added as last ones in the bottom.
.things
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Bridge mqtt:broker:localbroker [ host="MQTT-Broker-IP", secure=false, clientID="OpenHABv2" ] { Thing mqtt:topic:sonoffbridge { Channels: Type string : reachable "Reachable" [ stateTopic="tele/sonoff-bridge/LWT" ] Type string : receiveddata "Received Data" [ stateTopic="tele/sonoff-bridge/RESULT", transformationPattern="JSONPATH:$.RfReceived.Data"] Type string : receivedsync "Received Sync" [ stateTopic="tele/sonoff-bridge/RESULT", transformationPattern="JSONPATH:$.RfReceived.Sync"] Type string : receivedlow "Received Low" [ stateTopic="tele/sonoff-bridge/RESULT", transformationPattern="JSONPATH:$.RfReceived.Low"] Type string : receivedhigh "Received High" [ stateTopic="tele/sonoff-bridge/RESULT", transformationPattern="JSONPATH:$.RfReceived.High"] Type string : receivedrfkey "Received RfKey" [ stateTopic="tele/sonoff-bridge/RESULT", transformationPattern="JSONPATH:$.RfReceived.RfKey"] Type number : rssi "WiFi Signal Strength" [ stateTopic="tele/sonoff-bridge/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"] Type contact : door1 "Door 1" [ stateTopic="tele/sonoff-bridge/RESULT", transformationPattern="JSONPATH:$.RfReceived.Data" ,allowedStates="082439,082433", off="082439", on="082433"] //basic switch: Type switch : basic1 "Sonoff Basic 1" [ stateTopic="stat/sonoff-basic1/Power", commandTopic="cmnd/sonoff-basic1/Power", transformationPattern="JSONPATH:$.POWER" ] } } |
.items
1 |
Switch sonoffbasic1 "Table Light" <light> (GF_Living) ["Lighting"] {channel="mqtt:topic:sonoffbridge:basic1" } |
.sitemap
1 2 3 4 5 6 7 8 9 10 11 12 |
Group item=GF_Sonoff_RF { Text item=GF_Sonoff_RF_Reachable label="Status [%s]" Text item=GF_Sonoff_RF_Received_Data label="Data [%s]" Text item=GF_Sonoff_RF_Received_Sync label="Sync [%s]" Text item=GF_Sonoff_RF_Received_Low label="Low [%s]" Text item=GF_Sonoff_RF_Received_High label="High [%s]" Text item=GF_Sonoff_RF_Received_RfKey label="RfKey [%s]" Text item=GF_Sonoff_RF_RSSI label="WiFi Signal Strength [%d %%]" Text item=GF_Sonoff_RF_Door_1 label="Door [%s]" // sonoff basic switch: Switch item=sonoffbasic1 } |
hopefully works.