So in case the wifi is there and connections is good are u able to turn the light off and on from blynk and physical button like if u turn on the light from blynk dan u turn off the light from the physical button ? If yes after u turn it off from the physical button can u turn it on from blynk ?
Assuming the âphysical buttonâ youâre talking about is the switch thatâs attached to GPIO 0, then YES to everything. All methods work, and Blynk is always synchronized.
If the âphysical buttonâ youâre talking about is the wall switch, the answer is NO. Everything is off in that case. Thereâs no magic here. If you remove the power to the electronics, nothing works. I canât believe this is so difficult to understand.
If you look back at the the original posting, the on-at-startup version of the code was created for one very specific purpose. I wanted to use this system for an existing hard wired ceiling lamp. The only space for additional electronics was in the ceiling junction box. The junction box only receives power when the switch on the wall is ON, so I leave it on all the time, and use one of the various wifi methods to turn the light on and off. However, if I do need to turn on the light when the wifi is not working, itâs as simple as toggling the wall switch off and then back on. It doesnât need the wifi at that point, because I added the on-at-startup code to the setup function.
Now, if you want to continue to use a wall switch, Iâd suggest getting the iTead wall switch, which replaces the existing wall switch. Then, just use the original version of the code (at the top of the page), instead of the on-at-startup version. Then, every possible method for operating the light (including the wall switch) is available to you. Hereâs a link to the iTead wall switch.
Thanks for explanation - thatâs what I was trying to get at so it is nearly 100% but not quite. I thought you were saying it was 100% in sync all of the time and I couldnt understand how you would of done that.
The original code is a really versatile, inexpensive smart socket emulator (e.g. Wemo). Itâs always plugged in, so itâs always on, and always in sync with its app.
The on-at-startup code is a really versatile, inexpensive smart light bulb emulator. When you install a Phillips Hue or a Lifx bulb, itâs expected to be in a socket thatâs always receiving power. If that power is ever turned off, the app can only tell you that the product offline. It canât tell you its state.
Iâve been hoarding loads of sonoffs and uploading this code to all of them. Itâs so much better than sonoffs ewelink alternative and a lot better than standard ifttt + alexa web request thingy.
Anyway, Iâve been having problems⌠Randomly all devices will all turn on, sometimes some devices seem to drop from the network and also I get powercuts and the devices canât be turned back on with wifi, or the button on the sonoffâs, even though they were plugged in and turned on before the cut. Any ideas as to why this could be happening?
Hmmmm⌠Not sure how many âloadsâ is, but I know that thereâs a limit to the number of devices that Alexa will recognize. Iâve been running 5 of them for over three months, and theyâre rock solid. Have you tried swapping out the router?
If youâre using the on-at-startup version of the code, the ârandomâ turning on of all units could indicate a problem with your mains power supply, which you already mentioned suffers power cuts. If your mains dropped momentarily, all units would restart, and it would appear that they just randomly turned on.
I use echo dot, sonoff basic with nodemcu fimware. Upload code its fine. Alexa find new device.
Now, can you tell me what is the name of the device that is how to turn it on/off over alexa ??
The second question, which I need to change in the code, is to turn off the state when I plug the electricity lamp.
After uploading the code I did not get the AP and the network configuration, despite the fact that the blynk application works?
Is there something weird, since there is no auth and passw in the code anywhere. ?? The question is how the sonoff connected to my network without this data in the code ??
The code uses Wifi Manager to allow you to input the SSID and password. If your NodeMCU has previously connected to your wireless network (by having code uploaded that contains the correct credentials) it will remember these details and attempt to connect using them. If it canât connect then Wifi Manager will go into access point mode to allow you to input valid credentials.
He was connected to the network but with the Sonoff Fimvare, with Nodemcu fimvare and this code for the first time. Perhaps the router was remembered by the Mac address. But thatâs strange to me. By the way, it works through alexa. My mistake, I did not read the instructions properly.
I still have to figure out, how to make the lamp state off when I plug it in electric socket.
And it would be great if it could be open / close instead of on / off
Pete is correct. A quirk of the ESP8266 (and all of its derivatives) is that it remembers your wifi credentials independent of any code you upload to it.
If you want the device to start in the OFF state, just comment out these two lines in setup:
Blynk.virtualWrite(VPIN, HIGH);
Blynk.syncVirtual(VPIN);
As for what to call the device with Alexa, you can call it whatever you like. Thatâs the beauty of it. Simply go into the Alexa app on your phone or tablet, and under âSmart Homeâ, click on âCreate Group.â The word âgroupâ is a bit of a misnomer, since a group might contain just one device. Anyway, name the group whatever you want to (lamp, tv, living room, etc), and under the group heading, tick the box next to each of the devices that you want to control with that group name. For example, you might name your group âbedroom lamp.â Now just tick the device thatâs connected to your bedroom lamp, and when you ask Alexa to âturn on the bedroom lamp,â and she will. You might create another group called âall the lights,â and tick the boxes for every device in your home thatâs connected to a light. Then, when youâre headed to bed, you just ask Alexa to âturn off all the lights,â and every light in the house turns off.
The great thing about this is that you can create all sorts of groups, and you get to choose the language you use. The only limitation is that you have to use the words ON and OFF to define the state.
If youâre going to use a lot of these devices, you can simplify their identification within the Alexa app by giving them unique names in the Arduino code. I used âSonOfWemoâ in the examples above, but you can change that to any names you like.
SonOfWemo was just a little pun, alluding to the fact that the device was the âoffspringâ of the Belkin Wemo, and built on Sonoff hardware.
Yes, the first code works great. Iâm sorry I was bored, I thought they were the same.
I will also save another code for use on light coming from an electrical box. Although I have not understood well enough to connect the wires.
But slowly, maybe I can find a way.
Chrome, youâve been talking about electric shutters. Do you have any code for that?
This code is not good for that.
My electric rollers are connected in a way: one wire is live, and the other two are for opening and closing.
We should code with the interlocking function. So only one relay can work at a specified time, if another relay is working then the first must be switched off.
Similar to the Sonoff 4channel with interlocking function, only we need 2 chanell reley (for example, sonoff dual)
So that one relay could use to open and the other to close.