Sonoff-HomeAssistant (Alternative firmware for Sonoff Switches for use with mqtt/HA)

are th switches bipolar_ I mean they disconnet both wires *line+neutral(, or they just disconnect one phase (the other is the ground pass through)???

Only one (labeled L) is hooked up to the relay, the other stays connected

so is unipolar.

Are there any switches the disconnects 2 wires?

Trying to flash my first Sonoff normal version.
I have this in my configuration

mqtt:
  broker: mxx.cloudmqtt.com
  port: 17215
  client_id: home-assistant-1
  keepalive: 60
  username: admin
  password: password

so I should change the code of the firmware this way? the MQTT_SERVER has to point to the pi3 address (192.168.1.238??) or to the address that is in the configuration.yaml (mxx.cloudqtt.com)??

THe # sign bedore define, should it be taken out???

define MQTT_CLIENT     "Sonoff_Living_Room_v1.0p"           // mqtt client_id (Must be unique for each Sonoff)
define MQTT_SERVER     "mxx.cloudmqtt.com"                      // mqtt server
define MQTT_PORT       17215                                 // mqtt port
define MQTT_TOPIC      "home/sonoff/living_room/1"          // mqtt topic (Must be unique for each Sonoff)
define MQTT_USER       "admin"                               // mqtt user
define MQTT_PASS       "password"                               // mqtt password

Oh well, I installed mosquitto, following some guides.

Not very user friendly the guide for installing this firmware, shall I modify any of these lines?

#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <PubSubClient.h>
#include <Ticker.h>

in Arduino IDE after compiling I receive this error

Arduino:1.8.1 (Windows 10), Scheda:"Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 1M (64K SPIFFS), ck, Disabled, None"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Claudio\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Claudio\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Claudio\Documents\Arduino\libraries -fqbn=esp8266:esp8266:generic:CpuFrequency=80,FlashFreq=40,FlashMode=dio,UploadSpeed=115200,FlashSize=1M64,ResetMethod=ck,Debug=Disabled,DebugLevel=None____ -ide-version=10801 -build-path C:\Users\Claudio\AppData\Local\Temp\arduino_build_963645 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2 -prefs=runtime.tools.mkspiffs.path=C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\0.1.2 -prefs=runtime.tools.esptool.path=C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\esptool\0.4.9 -verbose C:\Users\Claudio\Documents\Arduino\sketch_feb09a\sketch_feb09a.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Claudio\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Claudio\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Claudio\Documents\Arduino\libraries -fqbn=esp8266:esp8266:generic:CpuFrequency=80,FlashFreq=40,FlashMode=dio,UploadSpeed=115200,FlashSize=1M64,ResetMethod=ck,Debug=Disabled,DebugLevel=None____ -ide-version=10801 -build-path C:\Users\Claudio\AppData\Local\Temp\arduino_build_963645 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2 -prefs=runtime.tools.mkspiffs.path=C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\0.1.2 -prefs=runtime.tools.esptool.path=C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\esptool\0.4.9 -verbose C:\Users\Claudio\Documents\Arduino\sketch_feb09a\sketch_feb09a.ino
Using board 'generic' from platform in folder: C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0
Using core 'esp8266' from platform in folder: C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0
Detecting libraries used...
"C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/include" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include" "-IC:\Users\Claudio\AppData\Local\Temp\arduino_build_963645/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC   -DARDUINO=10801 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_ESP01"  -DESP8266 "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\variants\generic" "C:\Users\Claudio\AppData\Local\Temp\arduino_build_963645\sketch\sketch_feb09a.ino.cpp" -o "nul"
"C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/include" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include" "-IC:\Users\Claudio\AppData\Local\Temp\arduino_build_963645/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC   -DARDUINO=10801 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_ESP01"  -DESP8266 "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\variants\generic" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\EEPROM" "C:\Users\Claudio\AppData\Local\Temp\arduino_build_963645\sketch\sketch_feb09a.ino.cpp" -o "nul"
"C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/include" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include" "-IC:\Users\Claudio\AppData\Local\Temp\arduino_build_963645/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC   -DARDUINO=10801 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_ESP01"  -DESP8266 "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\variants\generic" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\EEPROM" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src" "C:\Users\Claudio\AppData\Local\Temp\arduino_build_963645\sketch\sketch_feb09a.ino.cpp" -o "nul"
"C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/include" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include" "-IC:\Users\Claudio\AppData\Local\Temp\arduino_build_963645/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC   -DARDUINO=10801 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_ESP01"  -DESP8266 "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\variants\generic" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\EEPROM" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266mDNS" "C:\Users\Claudio\AppData\Local\Temp\arduino_build_963645\sketch\sketch_feb09a.ino.cpp" -o "nul"
"C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/include" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include" "-IC:\Users\Claudio\AppData\Local\Temp\arduino_build_963645/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC   -DARDUINO=10801 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_ESP01"  -DESP8266 "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\variants\generic" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\EEPROM" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266mDNS" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ArduinoOTA" "C:\Users\Claudio\AppData\Local\Temp\arduino_build_963645\sketch\sketch_feb09a.ino.cpp" -o "nul"
"C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/include" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include" "-IC:\Users\Claudio\AppData\Local\Temp\arduino_build_963645/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC   -DARDUINO=10801 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_ESP01"  -DESP8266 "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\variants\generic" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\EEPROM" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266mDNS" "-IC:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ArduinoOTA" "C:\Users\Claudio\AppData\Local\Temp\arduino_build_963645\sketch\sketch_feb09a.ino.cpp" -o "C:\Users\Claudio\AppData\Local\Temp\arduino_build_963645\preproc\ctags_target_for_gcc_minus_e.cpp"
C:\Users\Claudio\Documents\Arduino\sketch_feb09a\sketch_feb09a.ino:39:26: fatal error: PubSubClient.h: No such file or directory

 #include <PubSubClient.h>

                          ^

compilation terminated.

Uso la libreria EEPROM alla versione 1.0 nella cartella: C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\EEPROM 
Uso la libreria ESP8266WiFi alla versione 1.0 nella cartella: C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi 
Uso la libreria ESP8266mDNS nella cartella: C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266mDNS (legacy)
Uso la libreria ArduinoOTA alla versione 1.0 nella cartella: C:\Users\Claudio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ArduinoOTA 
exit status 1
Errore durante la compilazione per la scheda Generic ESP8266 Module.

I am attempting to flash a
Sonof TH10/16 fitted with AM2303 / DHT22 supplied by ITEAD **** using Arduino IDE and Sketch ESPsonoff_TH-v1.01t.
When I do a verify/compile i receive the following error.

Arduino: 1.8.1 (Windows 10), Board: “Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 1M (64K SPIFFS), ck, Disabled, None”

ESPsonoff_TH-v1.01t:58: error: ‘DHT’ does not name a type

DHT dht(DHTPIN, DHTTYPE, 11); // (Don’t Change for Sonoff TH Series)

^

C:\Users\Dennis\Documents\Arduino\Portable\Sketchbook\arduino\ESPsonoff_TH-v1.01t\ESPsonoff_TH-v1.01t.ino: In function ‘void getTemp()’:

ESPsonoff_TH-v1.01t:235: error: expected primary-expression before ‘.’ token

dhtH = dht.readHumidity();

         ^

ESPsonoff_TH-v1.01t:236: error: expected primary-expression before ‘.’ token

dhtT = dht.readTemperature();

         ^

exit status 1
‘DHT’ does not name a type

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
Any help would be appreciated!!

Hi @KmanOz,

I finally got the Sonoff work! I I think that key change was that i use a external 3.3 V power supply to the Sonoff. So how after this it is working perfectly right now… (although i fried one sonoff accidentally cuz i applied 5V at the first time…:frowning:

Anyway, thanks a lot for helping and the great work!

1 Like

Anyway after receiving the item and analyzed it, I strongly urge all of you OF NOT USING THIS SONOFF LINE OF PRODUCTS.

It is totally against the electric regulation of any country in the world, and is also against common sense: this product is DANGEROUS and put life at risk.

I will report it to my authorities and ask for a ban of the product in Europe.

What is the main issue? Can you explain further?

main issue is how the “main” is exposed and connected: accessibility (distances, ground, sockets type) … that is how you engineer a DC powered appliance not an AC powered one.

Way, way, way too dangerous.

I think is the way you using,it been awhile in the market,no issue yet,as long as you put the cover on screw it tight,I don’t think there is any dangerous .

I am not here to convince anyone about the electric safety regulations. I feel obliged to warn anyone using this product, then do as you are pleased.

p.s. YOu can also play with an exposed cable attached to a 220V socket and live well after it: its just a matter of knowing your RISKS

Yes there is only a SPST relay in them which means Active only gets switched. Potentially it means that if you wire the Sonoff up incorrectly and reverse active and neutral there is the possibility that you may still have a live wire in whatever you’re switching even though the device is off. That’s why usually a DPST would have been ideal but oh well, it’s $5 bucks.

If wired correctly though, it poses no risk at all. I wire mine correctly so your statement means very little to me. It does however pose a problem to people who aren’t familiar with the dangers of wiring mains voltage with any device, not just Sonoff’s because a lot of devices only switch active.

As I thought, your comment is a little over the top. If Europe bans this device, there are a million others that pose a far worse risk than this does.

You are overreacting :smiley:

1 Like

Is not only changing line for neutral, what about line and neutral proximity? The type of connector that holds the two wires (so small and thin plastic), the case is not screwed and is very lose (can open so easily and expose main) … naaa its a design for a DC product, not an AC product.

If I remember correctly you have 20 of them behind your wall … well to me is a high risk situation, but then again, do as you are pleased

there are tons of life risk situation (not only electricity), what I am saying is that Sonoff line of product ARE AGAINST THE LAW.

I am sure is not the only product against the law, but still is against the law, and I urge anyone to NOT USE THIS PRODUCT

The case does loosen very easily. That’s the first thing i noticed. But aren’t those screw holes which you can screw to tighten the cover?

I worked with sonoff and also wiring of ikea pendant and ceiling light. They’re all dangerous.

What LAW ? Links please.

1 Like

Once you screw the screws in it does not come apart.

Yeah, that’s what i wrote on my second sentence…

1 Like