HI I have to agree with squalazzo use tasmota to flash it then you can use the wifi access point software called wifi manager that is all built in and you can configure a ton of settings like MQTT or use the long row of holes to use as pin outs for a bunch of stuff and extra hole you didn't use is all ready preconfigured as a switch for that gpo pin also use tasmota to flash esp8266 stuff also and all the Sonoffs will have built in OTA updatingAlso just can not stand the ground not being connected when using a tail like that where your just cutting the cable to splice in the Sonoff don't cut the green ground wire just route it out side of the box and tape or hot glue It to the side of the case but that ground could save you or a pet some day Just my 2 cents :)
Yes I agree that the tasmota would work great with it. I am simply showing how you can customize and not have to rely on an outside source of code if you don't want to. Also this was a very crude connection to show how things work and so yes I would highly recommend that if you are installing this switch into an actual system that you connect all grounds and if you install it into a steel box you connect a grounding screw to the box and bond your grounds. If you are in the US you definitely need to adhere to the NEC (National Electric Code) or the best would be to have a professional install these if you are unsure. Great comment thank you!!
Thanks for great video. I have been struggling with days trying to get my Sonoff with Tasmota working and not know how to see if the Topic is the same on the Sonoff and HA. I added sonoff2 in Tasmota and in HA but still not working. The switch just turns off as soon as I click on it. Going try your firmware .
too much hassle: flash them with tasmota, configure via web using their access point, use them, done... not even need to compile anything, there are precompiled binaries, flashable with nodemcu flasher
Hey there thanks for your comment. Yes there are pre-compiled binaries that are very use full. I was simply showing people how to build their own. I am, by no means, saying that this is the only way to do this. This is simply a way that you can have full control over what the code is going onto the SonOff. Thank you for the suggestions o ftasmota and other binaries that does help for someone that does not want to build from scratch as a simple and quick solution. Good comment!
I had a similar problem when working with the Sonoff Wifi Switch, bought recently from Amazon. When set with Flash Mode DIO, the code seemed to load but would not run. I switched to DOUT, then it worked fine.
Well I just set it up on my network again and got it to work. What are you seeing in the Serial terminal from the arduino? Also my terminal settings are "No line ending" and "115200 baud". Make sure you have the baud correct because it is coded for 115200. Also double check your Mqtt server settings and make sure you do not have any MAC address filtering on your router. Let me know.
At last got my Sonoff switch to work , thanks to you. Awesome you rock. Struggled with Tasmota. Just a question, if I need to add a second switch , which of the fields do i need to change besides the one ha/switch2 ? thanks
Thanks for the feedback and I. Happy you got it to work. I believe the ha/switch2 is all you will need to change on the Sonoff code. Now in the ha config you will have to change that and the IP address for the new switch. Let me know if you have any problems
Hi thanks for the video. I have communications problem between Sonoff and Hass with an other firmware. I tried your firmware but after flashing sonoff it's "dead", I can't find it in my network either. For the first time I can see "live" in the switch in Hass but it hasn't contact with Sonoff. When I flash it again with the old firmware the Sonoff is active again. Any idea, any advice?. Do you know whats the problem is? Did a mistake somewhere? Thanks
you played with that switch way too long and seemed to get really excited. You even exclaimed "woo hoo" as you talked about space. ps That's exactly why the conductive traces are large. for current carrying capacity. I really do like your "don't care, gonna rip that right outa there." mentality. Keep up the good work!
Hi again, I have tried again a couple of times, but with the same result. This firmware is the solution to my communication problems Sonoff - Hass. I need your help to find out where the fault is and be able to flash the Sonoff normally. You can not imagine how many things I have tried but without positive results. I am very sure that this firmware is the key to solve this problem. Thanks in advance.
Hmmmm... Yeah this sounds like maybe the code I have has a bug. Well I promise this weekend I will take a look at it myself and see if I can reproduce and then provide a code revision to github and make sure it works. Thanks for trying this and I will get back to you soon.
Would that be on the input or the output terminals? It depends on how they have it configured on the circuit board. If they are using a full bridge rectifier then I would say it really does not matter for the polarity since it is AC. However, since they have indicators on the plastic that states "L" for line and "N" for neutral I would follow those symbols since it is cheap gadget and you don't know if they have protected it correctly.
Yeah, like I said it depends on how the circuitry is set up on the inside of the box. It may do nothing since it is AC as long as they have used a full bridge rectifier in their design and not grounded it. I would not chance it because if they did not build the circuitry properly it could explode! And that would be bad! :)
Hello. First it is a great Video and second sorry for my bad english. I'm German. So i try to tell my issue. I have use your script and i have follow your instructions 100%. I have put my SSID and Password in the Script and loaded it on my SONOFF. I use the embedded MQTT from Home Assistant and use your Config. But it don't Work. If i but the SONOFF on the Arduino Monitor it tell me this " wdt reset load 0x4010f000, len 1384, room 16 tail 8 chksum 0x2d csum 0x2d v4ceabea9 ~ld" again and again... Have you any idea ?
Ahhh yes I have seen this as well. What it could be is that if you have anywhere in the code a possibility of an infinite loop that can cause a watch dog timeout (wdt). Also the ESP8266 library in arduino was recently updated and can cause this problem. Try reverting back a few versions of the esp8266 board library. Hope this helps.
Good point there. You definitely need to use 3.3V when programming or you will burn up the onboard ESP8266. Also NEVER try programming it when it is connected to MAINS voltage!!!! You can Damage your USB port in your computer or worse the computer itself. Always be careful when working with Mains!
Yes you could. I would suggest using If this than that www.ifttt.com I have many videos on this. come check out the google assistant videos on my channel for help.
hi , just ask if the ideia will work would be possible add on code something specific as reduce the speed of motor in the start .... than go quickly .... the slow down at end ..... on the way back same slow... go quick... than slow again ..... so something about it here but my ideia was to put on sonoff mini www.dummies.com/computers/arduino/how-to-change-the-speed-of-a-dc-motor-with-the-arduino/ How to Change the Speed of a DC Motor with the Arduino Sometimes you need to have greater control over the speed of your motor, which the Arduino allows you to do with the MotorSpeed sketch. The following shows you how to control the speed of your motor with the same circuit. The MotorSpeed sketch Open a new Arduino sketch, save it with a memorable name, such as myMotorSpeed, and then type the following code. int motorPin = 9; void setup(){ pinMode(motorPin, OUTPUT); } void loop() { for(int motorValue = 0 ; motorValue = 0; motorValue -=5){ analogWrite(motorPin, motorValue); delay(30); } } After you’ve typed the sketch, save it and press the Compile button to check your code. The Arduino Environment should highlight any grammatical errors in the Message Area if they are discovered. If the sketch compiles correctly, click Upload to upload the sketch to your board. When uploading is done, you should have a motor that spins very slowly to start with, speeds up to its fastest spin, spins back down to a stop, and then repeats. It can be difficult to see this, so you should fix something more visible, such as adhesive putty, to show you what’s going on. You may find that at its slowest point, the motor just hums. If so, this is not a problem; it just means that the electromagnet doesn’t have enough voltage to spin the motor; it needs more voltage to generate the magnetism and gain momentum. The MotorSpeed sketch breakdown The pin you are using to control the motor circuit, digital pin 9, is declared. int motorPin = 9; Because it’s an output, you define it in setup. void setup() { pinMode(motorPin, OUTPUT); } In the main loop, you use analogWrite to send a PWM value to pin 9. This is the same principle as in the Fade sketch, used to fade an LED. The first for loop sends a gradually increasing value to pin 9 until it reaches the maximum PWM value of 255. The second for loop gradually returns this value to 0; then the cycle repeats itself void loop() { for(int motorValue = 0 ; motorValue = 0; motorValue -=5){ analogWrite(motorPin, motorValue); delay(30); } } This process could be likened to revving a car engine. If you push the pedal down, you accelerate to full speed. If you tap the gas pedal, the engine accelerates and then slows down. If you tap it at a constant rate before it slows, you will maintain some of the momentum of the spinning motor and achieve an average (if somewhat jerky) speed. This is what the transistor is doing, but very quickly. The intervals between on and off and the momentum of the motor allow you to achieve analog behavior from a digital signal.
Yes I agree. I was showing this for demo purposes. I am working on another video about testing this with full ratings and seeing if it is really reliable in your house. Also I will show how to professionally install this device with grounds and proper safety.
On the other hand.. sonof should however include this in the product too.. :) just a circuit connection passing the switch would be fine for me aswell :)
I agree about the ground. However, this was a demo of what you can do. If I were installing it into something I would have a ground wire present in the box that I would be bonding everything to. Also I am working on a video series of whether or not things will work and I am very skeptical of the sonoff switch. I had a viewer request this video so here it is. Thanks for the comment.
HI I have to agree with squalazzo use tasmota to flash it then you can use the wifi access point software called wifi manager that is all built in and you can configure a ton of settings like MQTT or use the long row of holes to use as pin outs for a bunch of stuff and extra hole you didn't use is all ready preconfigured as a switch for that gpo pin also use tasmota to flash esp8266 stuff also and all the Sonoffs will have built in OTA updatingAlso just can not stand the ground not being connected when using a tail like that where your just cutting the cable to splice in the Sonoff don't cut the green ground wire just route it out side of the box and tape or hot glue It to the side of the case but that ground could save you or a pet some day Just my 2 cents :)
Yes I agree that the tasmota would work great with it. I am simply showing how you can customize and not have to rely on an outside source of code if you don't want to. Also this was a very crude connection to show how things work and so yes I would highly recommend that if you are installing this switch into an actual system that you connect all grounds and if you install it into a steel box you connect a grounding screw to the box and bond your grounds. If you are in the US you definitely need to adhere to the NEC (National Electric Code) or the best would be to have a professional install these if you are unsure. Great comment thank you!!
I do like videos keep making them :)
Thanks for great video. I have been struggling with days trying to get my Sonoff with Tasmota working and not know how to see if the Topic is the same on the Sonoff and HA. I added sonoff2 in Tasmota and in HA but still not working. The switch just turns off as soon as I click on it. Going try your firmware .
too much hassle: flash them with tasmota, configure via web using their access point, use them, done... not even need to compile anything, there are precompiled binaries, flashable with nodemcu flasher
Hey there thanks for your comment. Yes there are pre-compiled binaries that are very use full. I was simply showing people how to build their own. I am, by no means, saying that this is the only way to do this. This is simply a way that you can have full control over what the code is going onto the SonOff. Thank you for the suggestions o ftasmota and other binaries that does help for someone that does not want to build from scratch as a simple and quick solution.
Good comment!
I had a similar problem when working with the Sonoff Wifi Switch, bought recently from Amazon. When set with Flash Mode DIO, the code seemed to load but would not run. I switched to DOUT, then it worked fine.
Thanks for the information
What the app control in your phone?
Thanks buddy, I hope you find a solution to the problem. I will be very grateful for that. I'll be waiting. Thanks a lot!
Well I just set it up on my network again and got it to work. What are you seeing in the Serial terminal from the arduino? Also my terminal settings are "No line ending" and "115200 baud". Make sure you have the baud correct because it is coded for 115200. Also double check your Mqtt server settings and make sure you do not have any MAC address filtering on your router. Let me know.
Hi. I have the same problem. After flashing. Dead...
contact me by mail (cototo2005@gmail.com). Are you swedish?
At last got my Sonoff switch to work , thanks to you. Awesome you rock. Struggled with Tasmota. Just a question, if I need to add a second switch , which of the fields do i need to change besides the one ha/switch2 ? thanks
Thanks for the feedback and I. Happy you got it to work. I believe the ha/switch2 is all you will need to change on the Sonoff code. Now in the ha config you will have to change that and the IP address for the new switch. Let me know if you have any problems
Hi thanks for the video. I have communications problem between Sonoff and Hass with an other firmware. I tried your firmware but after flashing sonoff it's "dead", I can't find it in my network either. For the first time I can see "live" in the switch in Hass but it hasn't contact with Sonoff. When I flash it again with the old firmware the Sonoff is active again. Any idea, any advice?. Do you know whats the problem is? Did a mistake somewhere? Thanks
hey Great Video!! I have done everything but in HA i can toogle the light on but not off do you know what im doing wrong
What does your .yaml file configuration look like?
you played with that switch way too long and seemed to get really excited. You even exclaimed "woo hoo" as you talked about space.
ps That's exactly why the conductive traces are large. for current carrying capacity.
I really do like your "don't care, gonna rip that right outa there." mentality. Keep up the good work!
Hi again, I have tried again a couple of times, but with the same result. This firmware is the solution to my communication problems Sonoff - Hass. I need your help to find out where the fault is and be able to flash the Sonoff normally. You can not imagine how many things I have tried but without positive results. I am very sure that this firmware is the key to solve this problem. Thanks in advance.
Hmmmm... Yeah this sounds like maybe the code I have has a bug. Well I promise this weekend I will take a look at it myself and see if I can reproduce and then provide a code revision to github and make sure it works. Thanks for trying this and I will get back to you soon.
What will happen if I connect + wire to - Position & - wire to + position by Live Current. ⚡️⚡️
Would that be on the input or the output terminals? It depends on how they have it configured on the circuit board. If they are using a full bridge rectifier then I would say it really does not matter for the polarity since it is AC. However, since they have indicators on the plastic that states "L" for line and "N" for neutral I would follow those symbols since it is cheap gadget and you don't know if they have protected it correctly.
@@misperry Yes , Something Like Same "L" To "N" Position & "N" To "L" Position. Than What will happen. 🙄
Yeah, like I said it depends on how the circuitry is set up on the inside of the box. It may do nothing since it is AC as long as they have used a full bridge rectifier in their design and not grounded it. I would not chance it because if they did not build the circuitry properly it could explode! And that would be bad! :)
@@misperry THANKS FOR YOUR COMMENTS. 😃😃
Hello. First it is a great Video and second sorry for my bad english. I'm German. So i try to tell my issue. I have use your script and i have follow your instructions 100%. I have put my SSID and Password in the Script and loaded it on my SONOFF. I use the embedded MQTT from Home Assistant and use your Config. But it don't Work. If i but the SONOFF on the Arduino Monitor it tell me this
" wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v4ceabea9
~ld"
again and again...
Have you any idea ?
Ahhh yes I have seen this as well. What it could be is that if you have anywhere in the code a possibility of an infinite loop that can cause a watch dog timeout (wdt). Also the ESP8266 library in arduino was recently updated and can cause this problem. Try reverting back a few versions of the esp8266 board library.
Hope this helps.
@@misperry Can you tell my which library you add. Sorry but i'm new in Arduino and i'm not sure that i have the right one.
Looks like the ESP8266 library update to 2.4.1 breaks this. Just revert it back to 2.4.0 and you're gold.
Excellent! Thanks for the tip.
“I wanna stress you’ve got to be very careful with that...”
Then at least connect the ground wires!
Cheers!
Good point there. You definitely need to use 3.3V when programming or you will burn up the onboard ESP8266. Also NEVER try programming it when it is connected to MAINS voltage!!!! You can Damage your USB port in your computer or worse the computer itself. Always be careful when working with Mains!
Can it use with google home?
Yes you could. I would suggest using If this than that www.ifttt.com I have many videos on this. come check out the google assistant videos on my channel for help.
hi , just ask if the ideia will work
would be possible add on code something specific as reduce the speed of motor in the start .... than go quickly .... the slow down at end ..... on the way back same slow... go quick... than slow again .....
so something about it here but my ideia was to put on sonoff mini
www.dummies.com/computers/arduino/how-to-change-the-speed-of-a-dc-motor-with-the-arduino/
How to Change the Speed of a DC Motor with the Arduino
Sometimes you need to have greater control over the speed of your motor, which the Arduino allows you to do with the MotorSpeed sketch. The following shows you how to control the speed of your motor with the same circuit.
The MotorSpeed sketch
Open a new Arduino sketch, save it with a memorable name, such as myMotorSpeed, and then type the following code.
int motorPin = 9;
void setup(){
pinMode(motorPin, OUTPUT);
}
void loop() {
for(int motorValue = 0 ; motorValue = 0; motorValue -=5){
analogWrite(motorPin, motorValue);
delay(30);
}
}
After you’ve typed the sketch, save it and press the Compile button to check your code. The Arduino Environment should highlight any grammatical errors in the Message Area if they are discovered.
If the sketch compiles correctly, click Upload to upload the sketch to your board. When uploading is done, you should have a motor that spins very slowly to start with, speeds up to its fastest spin, spins back down to a stop, and then repeats. It can be difficult to see this, so you should fix something more visible, such as adhesive putty, to show you what’s going on.
You may find that at its slowest point, the motor just hums. If so, this is not a problem; it just means that the electromagnet doesn’t have enough voltage to spin the motor; it needs more voltage to generate the magnetism and gain momentum.
The MotorSpeed sketch breakdown
The pin you are using to control the motor circuit, digital pin 9, is declared.
int motorPin = 9;
Because it’s an output, you define it in setup.
void setup() {
pinMode(motorPin, OUTPUT);
}
In the main loop, you use analogWrite to send a PWM value to pin 9. This is the same principle as in the Fade sketch, used to fade an LED. The first for loop sends a gradually increasing value to pin 9 until it reaches the maximum PWM value of 255. The second for loop gradually returns this value to 0; then the cycle repeats itself
void loop() {
for(int motorValue = 0 ; motorValue = 0; motorValue -=5){
analogWrite(motorPin, motorValue);
delay(30);
}
}
This process could be likened to revving a car engine. If you push the pedal down, you accelerate to full speed. If you tap the gas pedal, the engine accelerates and then slows down. If you tap it at a constant rate before it slows, you will maintain some of the momentum of the spinning motor and achieve an average (if somewhat jerky) speed.
This is what the transistor is doing, but very quickly. The intervals between on and off and the momentum of the motor allow you to achieve analog behavior from a digital signal.
No ground connection.... very bad example.... you better connect the grounds to eachother and hook up the ground back in to the source...
Yes I agree. I was showing this for demo purposes. I am working on another video about testing this with full ratings and seeing if it is really reliable in your house. Also I will show how to professionally install this device with grounds and proper safety.
On the other hand.. sonof should however include this in the product too.. :) just a circuit connection passing the switch would be fine for me aswell :)
Had to stop the vid - Im seasick...
Terrible wiring connections and Earth not used
I agree about the ground. However, this was a demo of what you can do. If I were installing it into something I would have a ground wire present in the box that I would be bonding everything to. Also I am working on a video series of whether or not things will work and I am very skeptical of the sonoff switch. I had a viewer request this video so here it is. Thanks for the comment.