I’m using a Wemos D1 R2 and a 5V Relay. I want to make it go ON and OFF separated by a 500 delay, I saw that this was referet to as a momentary switch.
I’ve modified the webserver sample in the Build Web Server with ESP32 and ESP8266 (great book!) so I can press a button and open the relay and then another button to close it.
I would like it to make it in one procedure, but it doesnt work.
I just want to make a “blink”, open the relay and then 500ms later close triggering this using one single button creating the momentary switch effect (click-click)
This code is not working, it get stucked and it doesnt even click once.
void R1ON_OFF() digitalWrite(relay1, LOW); delay(500); digitalWrite(relay1, HIGH); }
I have to make two separate functions to make it work, hence I had to use two button, one for ON and another for OFF.
void R1ON(){ digitalWrite(relay1, LOW); } void R1ON(){ digitalWrite(relay1, LOW); }
Is there any limitation on the Wemos D1 R2 or the Relay?
Thanks for your help!
Hi.
Here are two tutorials that might help with your project:
- https://randomnerdtutorials.com/esp32-esp8266-web-server-outputs-momentary-switch/
- https://randomnerdtutorials.com/esp32-esp8266-web-server-timer-pulse/
Let me know if you are able to mix it up with your project. Don’t hesitate to ask more questions.
Regards,
Sara
Sara, that was fast! I’ll try both methods and let it know here just in case somebody have this very same problem 🙂