Sonoff wifi switch control with ESP Easy and Node Red
Vložit
- čas přidán 26. 08. 2024
- In this video I am showing how to use the Sonoff wifi switch (from itead.cc) and flash the ESP Easy firmware on the decide and control it from OpenHAB.
You can find the Node Red flow here:
flows.nodered.o...
Sonoff wiring explained: drive.google.c...
Thank you for the in depth video on how to set up esp easy not many tutorials on this out there
1-2 hete keresem a megoldást, hogy hogyan tudnék saját egyedi eszközöket a Home Assistans-hez kapcsolni... ÉS VÉGRE megvan a megoldas!!!
NAGYON KÖSZÖNÖM A VIDEÓT!
Üdv.: Tamás, Stockholmból
Thank you so much for the detailed video. I just ordered 4 Sonoff WiFi Switches and can't wait to reprogram them and use them in my existing Home Automation setup.
I also ordered another 5, but lost in the Christmas parcel maze. I am planning to release a few more videos on the subject. I also want to explore what is possible using local logic (in the rules). I think that could also open up possibilities for simple automation without a central "controller" (node-red, home automation, openhab, etc.).
Köszönöm!
Nem rég vágtam bele a lakás automatizálásba és nagy segítséget nyújtanak a videóid.
And also, on the switch I set the following: Pull UP = activated, Inversed = activated, Switch Type = Switch, Switch Button Type = Push Button Active Low.
Then in Node-red you wire the MQTT from the Sonoff directly into the UI switch, without additional functions etc.
I also want to explore adding rules in the ESP, so the button press can be handled locally. I have to spend a bit more time on this topic. My sonoff works just fine, but sometimes so not turn on or off the lights.
That's was very useful. Thank you!
Thank you very much for all the effort you put in these videos. This one has enabled me to flash ESP Easy onto a Sonoff and using Pete Scargill's "The Script" I have finally got Mosquitto at least running but never connecting on Node Red.
Today I started from scratch with the latest version of Raspian [stretch] and loaded it on a RPi3 then ran "The Script" and everything minus Node Red connecting to Mosquitto seems to work.
If I use an MQTT input node on Node-Red and set the server to node-red@RPi's IP address:1883 all I ever get after Deploying is "Disconnected"
If however I use the same address but port 1880 [which is wrong] I at least get a "Connecting" message but never connects.
I have tried using localhost:1883 and 127.0.0.1:1883 and nothing but "disconnected" message for the MQTT node.
I verified via SSH that the mosquitto server is running but beyond that, I fall off my Linux knowledge cliff
Only "the script" was ever able to get mosquitto to load cleanly as using any other method on the web gave me various dependencies missing
Sorry, your message was held in spam until now. I have to admit I don't know. I think when you put 1880 it says connecting because it is waiting for a response which never gets, and on 1883 it gets rejected automatically. On my MQTT, I have a username and password. Did you do that too? Go to /var/log/mosquitto/mosquitto.log and see if you see some error messages there. It looks like Node-Red's connection to the MQTT broker is rejected for some reason.
Thank you very much for taking the time to reply.
I usually copy and paste login/password credentials to save typing and minimize errors but it seems the source document I was using to copy these credentials contained a non-printable character which caused every attempt to fail in Node-Red/MQTT. My bad!!!!!
I got Node-Red running with MQTT and even had the dashboard running on my Android phone. Yay.
Then the very next day, without any edits, the Sonoff's response to any command would take about 30 seconds. Even when using my browser to look at the configuration pages, it would take 30+ seconds from page to page. I reflashed the Sonoff with both the R120 build and the latest build but now the Sonoff will no longer connect to my home network. Everything up to the point of it attempting to connect works.
I am waiting for my Sonoff as well to test it, but check out the new 2.0 version of ESP Easy. I have seen some people fixed their Sonoff by going to the new 2.0 firmware. Also try "esptool -cp COMx ce" (before attempting to flash again). This erases the flash on the ESP chip. That may also help removing traces of settings, earlier program in the memory. I am just guessing at this point, I did not have the chance to test it myself. Or switch to ESPurna. These are all my tips at this point.
The putty not work after flashing the firmware , any advice please??
Looks like this will not work with the newer sonoff's - I am hoping someone will post a new procedure :)
Hi Csongor Varga,
Great video and well explained. I would like to know if the Alexa Local Node in Node-Red will work with this setup? Thanks
I will try to integrate Google Home with Node Red. I think the way Google Home works is that is passes over the recognized words in text. That should be easy to understand (take out parts of the sentence to identify what you want to which and to which state). But again, did not work on this yet.
Hi, love your videos. I have a question for you, if I flash can I control the Sonoff with the Smart Life app for Alexa. Thanks and keep up the good work.
I don't know the Smart Life app, but I would say probably not. But there is Alexa integration in eWelink as well.
@@csongorvarga Thanks for the quick reply, but no I don't like eWelink. When I used it with Alexa it doubled all my switches and plugs and the Sonoff loses connection with the app when and if you're lucky that it paires.
Hi there. If I connect a debug output to the MQQT input from the Sonoff it keeps sending "1" and then "0" and then "1"... It keeps doing this forever. Have you had the same problem?
By the way. The "Star" you are referring to is calles "Hash"
Oxynaut oh yes, hash. back to your problem, I have no idea. What is the topic of the message. Maybe that help in understanding it. Also you can ask the ESP Easy forum.
Hashtag to be compleet :-)
Hash is the symbol, hashtag is from social media.
Klassz tutorial! Eddig te vagy az eslő magyar, aki foglalkozik a témával youtube-n. Esp32-vel foglalkozgattál már?
+Balint Radocz Kosz, meg nem volt szerencsem ESP32-hoz. Szerintem ebben az alkalmazasban felesleges a vegpontra nagyobb teljesítményű eszközöt telepiteni. A rele vezerlest es a mqtt kommunikaciot a 8266 is elvegzi. Sot ahhoz tul kezdo vagyok hogy en direktbe irjak ra programot ezert is hasznalom az ESP Easyt. De ha lesz ESP32-re egy NES emulator akkor epitek egy sajat kezi jatekgepet.
Great video!
it's me once again have you tried this POW sonoff module it reads power consumed have you looked at these? Can we use it with ESP Easy? I wouldn't mind connecting to my air conditioner. thank you for your video series I have learned so much from your work Don
Actually, the POW module was also on my bucket list of things to get, but it has not happened yet. ESP Easy supports a set of sensors, and I have no idea if it would work with POW or not. There is no circuit diagrams online to do some research beforehand. And after flashing the original firmware, there is no way of going back (as far as I know).
is there a sketch of the interfacing with the programmer?
ESP Easy is downloadable as a bin file and you flash that on the Sonoff basic.
@@csongorvarga is it true to make the connection TX-RX or should it be RX-RX
TX-RX and RX-TX. But if you do it wrong nothing will happen, you will not break the unit.
Köszönöm válaszod.
wifi ok.ping ok. ma magpróbálom újratelepíteni a rpi-t hátha...de menni kellene. már próbáltam espeasy fw és arduinoval is...igen nálam is gondok vannak 2-3 esp egymásoz közel nem ok...
hi!!! following your tutorial, I need an help, firmware is flashed properly (report same message of your video at the end) but after connected using Putty, pressing button on Sonoff something appears into the Putty terminal...what could be wrong?
same here flash worked fine but I tried putty and another terminal software and none of them gives me any return so i cannot connect to esp_0 wifi networking because its not showing up.
today I was finally able to flash and see some result, try flashing your sonoff from arduino Ide using ESP8285 board instead of 8266, this worked for me.
All sorted. Had "Wifi Status Led" on GPIO-0 for some reason. Üdvözletek délafrikábol.
Oxynaut good catch
very good explanation :D
Thanks a lot. It was a long video, but I am glad it makes sense.
Could you tell me where you bought the header to fit these? Could you give me the exact size/spacing of the header? I am somewhat new at this so I appreciate any help you could provide. Great video. Thank you.
Thanks, it is called "0.1 inch pitch single row male pin header". Just put it into ebay and pick one with the most purchases. Get the straight version (pins not bent). Size does not matter, it can be cut between the pins. (links are not allowed in comments).
Great Video. Good explaination.
Question:
I bought for my rollo a SonOff Dual Unit. I flashed the unit and I would like to switch the relais via MQTT.
I tried all GPIOs but it doesnt work.
Any idea?
I am not sure to be honest. I don't have a dual, but after a quick Google, I can see that it is a bit different even with the use of the button to go to flash mode. What if you use ESPurna or Tasmota firmware which all have specific code for Sonoff Dual? There is a long thread here, not sure if it has the info you need: www.letscontrolit.com/forum/viewtopic.php?t=2869
Csongor Varga
I still flashed the Unit. You are right its moore complicated
Szia Csongor, tudsz abban segiteni hogyan kell sonoff tasmota-t domoticz-be hozzáadni?
Sajnos nem, sosem hasznaltam domoticz-t
Hi can I flash a NodeMCU 12e to try espeasy? can you build a json message with rules or ??
Yes, ESP Easy works with any ESP8266 based boards including NodeMCU. And no, you cannot build a json message.
Run another firmware first then you can do your settings. By the way your Node-Red listen to ever thing not on* but on hash /#. /# listens to all message in a group of messages like /cats/# it looks for anything in the cats system. So best way to do the message is /cats/sonoff1/ {payload Off} or {payload On}. If you had ten sonoff then to check messages you would listen to /cats/# [All messages] output to Debug to see the messages. Plus Bigtimer needs to have a input from your MQTT broker I think.
had same problems before with no SSID - flashing methode will not work anymore with new sonoff. you have to use ESP8266 Flasher, 115200, 1 Mbit, 40 MHz and IMPORTANT - SPI-Methode must be DOUT. works fine ^^
Thanks for the update. All my Sonoffs from about 1 year ago, but I have some new ones being ordered.
Thanks!! This is working for me !
I am trying to flash the newer sonoff's to use in node red using ESP8266 but not sure of the procedure - any chance you can walk us through it?
please example who to access Sonoff wifi switch by console C++ application.
Hi Csongor love your video series. question can I write a rule to send a event to Matt broker? I loved the rule video you did can you do some more of them?
Don Biederman I don't know what a Matt broker is. As long as it is a simple http command it is possible. These are all the things I could think of in terms of rules.
how to you send a mqtt message to control a gpio output pin /systemname/gpio/???
yes, //gpio/ and payload is 1 or 0. So in my case /Sonoff1/gpio/12 and message 1 to turn the relay on.
To erase the device flash you could try:
esptool --port com2 erase_flash
That erases everything with my nodemcu modules.
I was not recommending this as my version of esptool was crashing in Win10. I will try to get a newer version which works ok. I also want to test the process of downloading the firmware, but again by version of esptool does not seem to do it.
Hi Csongor, its me again.... :-( where you put the server name in your mqtt node in nodered, you used a nodered@192 etc etc, i have my mqtt on a cloudmqtt server it says its connected under the mqtt node, but i dont get any messages flowing in the debug, i have pressed deploy and theres no errors there...... i get messages coming through on my tasmota console though
why did you use nodered@192.168.1.80 is that the ip of you raspberry pi or whatever you running nodered on...? i have raspberry pi running my nodered..
Yes, I have the MQTT broker running on the same IP as Node Red. When you are on the MQTT settings page, click on the edit button and you get into the MQTT broker configuration. You can change that local ip to your clouldmqtt domain and set the userid and password on the Security tab.
hmmmm i have done that already on my sonoff, in tasmota, and can control my sonoff through the web interface, and through my android device I also have raspberry pi running nodered, and have mosquitto on the pi.. I have not setup mosquitto mqtt broker on the pi, as already have a cloud mqtt broker setup in nodered and it shows connected in nodered.... do you think my mqtt broker needs the same ip as my nodered ? maybe i need to setup my mosquitto........
could you try something for me ? if you have a cloudmqtt broker could you try setting that up in nodered and see if it works...? i beginning to wonder maybe cloudmstt dont work on nodered...
I am pretty sure that node-red does not need to be on the same IP as the broker. If you phone and Sonoff can connect the cloudmqtt, your node-red should as well. I don't have an account, so I cannot test it.
ok no prob i will research it better later... strange though it shows connected in nodered... i assume you using mosquitto ?
thanks it was all interesting...is there a way we can use sonoff on Google Home?
I don't know yet. I have a Google Home, but I have not gotten into learning more about Google Home, or api.ai.
i am looking to connect home and sonoff since long not able to find any method 😫😫😫😫
api.ai is the platform for developing for Google Home.
gracias
Nagyon jó videó...grat..
Sajnos nekem valamiért nem komunikál egymással a node-red és az esp....node-red rpi3-on fut...
nem jövök rá miért nem látják egymást...már mindennel próbálkoztam, rúter tűzfal...vagy talán valami nincs feltelepítve raspberry-re...esetleg valami ötlet...megköszönöm...
Mit jelent hogy nem kommunikál? Gondolom egy Wifin vannak, Rpi-ről lehet pingelni a esp IPjét... Nekem hasonló problémám nem volt. Viszont azért látom hogy ezek az esp eszközök azért nagyon karcosak. Most van 5 Sonoff egymás mellett, egyiket látom, másikat nem. Mármint a wifi-re felmennek, de sokszor a honlapjuk nem válaszol. Másik hogy a wifi antenna ami ezekben az esp-kben van, rosszabbak mint a legocskább mobiletelefon. Főleg nálunk ahol beton falak vannak, ha másik szobában vannak mint router, már akkor észreveszem hogy sokkal lassabbak. Szóval elsőként próbáld a router mellett vagy közel beüzemelni. Ellenőrizd hogy kapott IPt, fent van a hálózaton. Hálózati feszültség nélkül kapcsold rá a programozót és Putty-ban nézd milyen státusz üzenetek jönnek át a soros porton keresztül. Ott lehet kiküld valami hibaüzeneteket is. Most hirtelen ennyi jutott eszembe.
Do you think that you MIGHT explain what PUTTY is?
I am sure that many people will not know.
´´Im using this application F.I.N.G. :D Csongor easily say fing app :D
there is a schematic on there site www.itead.cc/wiki/images/5/52/Sonoff_POW_Schematic.pdf
I swear I looked at it in the past, and I did not see this before. So with my limited knowledge it appears that the voltage and current sensor is an HLW8012 chip. Looking at ESP Easy, it does not support that chip at the moment. But if you Google HLW8012 the first hit from Tinkerman who explains his work on the Sonoff POW with custom firmware. Have a read through that article.
Thanks I'm reading that over now.
my phone did that I mean mqtt lol