ITEAD Sonoff switches and sockets - cheap ESP8266 Wifi+MQTT hardware

This YouTube video posted a few days ago might be useful for many.

I’m looking forward to finally using my three sonoff basics I bought almost two years ago. This thread and OTA firmware will hopefully be just what I needed to push me over the edge. I just ordered two 4ch pros (one with RF) and the new s31 (U.S.). The 4ch pro with RF I hope to use for my 3 garage doors. The s31 I plan to use to monitor washing machine.

Can anyone comment on my two concerns:
Am I taking much of a risk with fixed 433 RF for garage doors? What is the likelihood that someone can open my garage doors?
How safe is it connecting these devices to main (120v U.S.)? I may be paranoid but I don’t want to risk any fires.

Thank you,
B34N

Why not order directly from https://www.itead.cc it is much cheaper, but it takes a while to deliver.

have problem to switch my sonoff. via console its ok, can switch with:

[17:43:34] openhabian@openHABianPi:~$ mosquitto_pub -h localhost -t "cmnd/sonoff/POWER" -m ON
[17:44:46] openhabian@openHABianPi:~$ mosquitto_pub -h localhost -t "cmnd/sonoff/POWER" -m OFF

works.
but not in openHAB, try diffent items, but no will run, e.g.

Switch Sonoff_CH1 "Innenlicht" <light> (WZ,gLight) ["Lighting"] { mqtt=">[mosquitto:cmnd/sonoff/POWER:command:*:default], <[mosquitto:stat/sonoff/POWER:state:default]" }

mosquitto run:

2017-12-29 16:00:56.474 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.

2017-12-29 16:00:56.481 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'

any idea whats wrong here?

Can someone recommend a good case for the Sonoffs? I’m looking at these right now: https://www.banggood.com/SONOFF-IP66-Waterproof-Junction-Box-Waterproof-Case-Water-resistant-Shell-p-1223669.html?rmmds=buy&cur_warehouse=CN

That is up to you to decide how much risk you are willing to take on. Using wifi you can certainly make it much more secure using things like MQTT with client certs and the like, but do you need to? How paranoid are you? If I were in a high crime area I would probably want to use something a little harder to spoof. But in a low crime area I wouldn’t see it as too much of a problem. But I have insurance and no known motivated enemies. My rick profile could be very different.

If they are motivated and have the time and hardware (e.g. SDR) 100% guarantee that they can open your garage. Even a brute force device might work. But you would have to be a target of sufficient worth to spend the time and money on the devices. I would do some research though to see how generic garage door remotes work and make sure your’s works differently somehow or else you become vulnerable to any garage door opener hack.

The thing you have to pay attention to is the AMPs. For example, does your washing machine draw more than 16 amps? Because that is the max that the S31 can support and you will start fires if you try to run more amps through it than it supports. There used to be some problems with Sonoffs overheating but I think the new ones have made improvements to the manufacturing process and they now have UL certification so should be reasonably safe, as long as you don’t try to overload them.

Today we flashed 3 x 4ch and a sonoff touch with sonOTA and i have asked myself why the hell i didn’t try this before.
We could flash 4 devices faster than soldering Pins on them would have taken.

It is really worth a try, if you didn’t try it yet. :slight_smile:
And as @rlkoshak already mentioned somewhere, we should point that out explicitly here.

Hey @ThomDietrich (and all interested in updating your tasmota flashed sonoff devices out of openHAB)

I had some spare time and have configured fw upgrades according to https://github.com/arendst/Sonoff-Tasmota/wiki/openHAB#maintenance-actions

But i thought it would also be nice to have not only the installed firmware per device,
but also the current available online release as an direct indicator.

Fortunately GitHub offers a great API for stuff like this and i have expanded the wiki solution in the following way:

http.cfg

# Tasmota Release Status (cached twice a day)
tasmotaRelease.url=https://api.github.com/repos/arendst/Sonoff-Tasmota/tags
tasmotaRelease.updateInterval=43200000

sonoff.items

String Sonoff_Action "Sonoff Action" <sonoff_basic> (Sonoff_Maintenance)
String Sonoff_Current_FW_Available "Current Release [%s]" <sonoff_basic> (Sonoff_Maintenance) { http="<[tasmotaRelease:10000:JSONPATH($[0].name)]"}

Switch  Sonoff_Wohnzimmertisch_LWT "Status Wohnzimmertisch" <sonoff_basic> (Sonoff_Maintenance) { mqtt="<[ohBroker:tele/sonoff_wohnzimmertisch/LWT:state:MAP(reachable.map)]" }
String Sonoff_Wohnzimmertisch_FW "Firmware Wohnzimmertisch [%s]" <sonoff_basic> (Sonoff_Maintenance) { mqtt="<[ohBroker:stat/sonoff_wohnzimmertisch/STATUS2:state:JSONPATH($.StatusFWR.Version)"}

Switch  Sonoff_Subwoofer_LWT "Status Subwoofer" <sonoff_basic> (Sonoff_Maintenance) { mqtt="<[ohBroker:tele/sonoff_subwoofer/LWT:state:MAP(reachable.map)]" }
String Sonoff_Subwoofer_FW "Firmware Subwoofer [%s]" <sonoff_basic> (Sonoff_Maintenance) { mqtt="<[ohBroker:stat/sonoff_subwoofer/STATUS2:state:JSONPATH($.StatusFWR.Version)"}

Switch  Sonoff_Wohnzimmerwand_LWT "Status Wohnzimmerwand" <sonoff_basic> (Sonoff_Maintenance) { mqtt="<[ohBroker:tele/sonoff_wohnzimmerwand/LWT:state:MAP(reachable.map)]" }
String Sonoff_Wohnzimmerwand_FW "Firmware Wohnzimmerwand [%s]" <sonoff_basic> (Sonoff_Maintenance) { mqtt="<[ohBroker:stat/sonoff_wohnzimmerwand/STATUS2:state:JSONPATH($.StatusFWR.Version)"}
val sonoff_device_ids = newArrayList(
    "sonoff_wohnzimmertisch",
    ...
    "sonoff_subwoofer"
)

rule "Update Sonoff Status"
when
    Time cron "0 0 0 ? * * *" // Update once a day
then
    for (String device_id : sonoff_device_ids) {

        logInfo("sonoff.rules", "Updating FW Item for Device: " + device_id )
        publish("ohBroker", "cmnd/" + device_id + "/STATUS", "2")

    }
end

This grabs the device firmware once a day or on query from the switch item.
It also grabs the latest existing tag from the tasmota github repo, so you can directly get an information about the current available firmware.

As far as i know the github api doesn’t need an authentication for public available repos and the data should be reachable for everyone.

8 Likes

I am trying to upload code to my sonoff pow device using the Arduino IDE. When compiling I get this error:

exit status 1
#error "MQTT_MAX_PACKET_SIZE is too small in libraries/PubSubClient/src/PubSubClient.h, increase it to at least 512"

No idea what is wrong here as it just throws an error if sth. went wrong. Any idea?

Go to the Arduino pubsubclient.h file.

It’s located somewhere like Arduino\Libraries\PubSubClient\src\pubsubclient.h.

Open the file using notepad or another file editor.

Change the packet size line to:

#define MQTT_MAX_PACKET_SIZE 512

Save and re-compile.

ok thanks, that had worked!

New Problem, the sketch is too big:

Der Sketch verwendet 528040 Bytes (105%) des Programmspeicherplatzes. Das Maximum sind 499696 Bytes.Globale Variablen verwenden 47228 Bytes (57%) des dynamischen Speichers, 34692 Bytes für lokale Variablen verbleiben. Das Maximum sind 81920 Bytes.

edit: nope, was a setting problem, has worked now, thanks again

That still has an ESP8266.

I finally succeeded to reprogram these.

I didn’t see the t16 on the list. Is it just a matter of flashing like a basic and then configuring the appropriate temperature sensor?

Yep, I’m running Tasmota on my TH16. I think it should work with the SonOTA method too unless it’s already been updated to a newer firmware.

Hey Jerome! That is a nice addition! Yes the GitHub api is public and unrestricted.

Could you please add your idea to the Tasmota->openHAB wiki page, maybe as a new section at the bottom? Your post here will be lost (out of sight) in two weeks and I try to collect all data related to openHAB and the Tasmota firmware in his article…

While at it don’t hesitate to improve other parts as well, or add devices as example configuration…

1 Like

Hi all,
I am using the Sonoff-Tasmota firmware successfully on about 10 devices now.
But in my last mail i received the Sonoff Slampher. I did manage to flash the firmware successfully but i am not able to get the Wifi Access Point Mode of the firmware working (4 quick presses on the button).
It seems to do with the fact that there is an RF module an a processor which catches the button presses before these are send to the 8266.
(I found some info about this here:
http://phalox.be/wp/electronics/itead-sonoff-slampher-custom-firmware-fix/
and here: https://wiki.fhem.de/wiki/Sonoff (See section Sonoff Slampher) )
Unfortunately the github site from Theo Arends does hardly provide info on the Slampher…

Hopefully anyone has experience with this device and can help me further.
Kind regards, Bert

The wiki is still a bit weak in some areas. Please be sure to add your findings…

That happened to me with another device as well. You need to configure the module during flash by changing the settings inside the file user-config.h (name similar). There you can directly configure your wifi and switch the wifi fallback option to access point mode.

Can you please provide some more information on how you managed this?

Did you manage to do it Over The Air? Did you connect to the GPIO pins? What firmware have you installed?

No GPIO needed :grinning:

There is an easier method he does not cover in the video… using the sonota.exe file on a windows machine, but this is covered in the Wiki. Took me less than 5 minutes to get a Sonoff talking MQTT to my NodeRed / OpenHab setup.

@QuagmireMan My question to @NDR008 is related to the cheaper “knock-off” devices which are being advertised as Sonoff but are not made by Itead.

The OTA method is for the genuine Sonoff firmware, but The “native” Windows sonota.exe has only been released in the last few days.