Attached is what seems like a simple program to turn a relay on and off and to post the relay status to a Blynk template.
When I run this simple program without the Blynk functionality, the ESP32 behaves as expected and the relay toggles on/off at specified intervals.
When I add the Blynk functionality, the template shows the virtual flag going on/off, but the physical relay does not actuate. Any ideas why this is happening?
I am experiencing the same behavior with all my other projects that need to actuate a relay - in one case, this is now happening on code that worked a year ago. I am completely stumped.
please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly. Triple backticks look like this: ```
Hi Pete, thanks - I think I got it right now. Could really use some help with this. I had an application that uses a relay working earlier in the year - suddenly nothing I am doing works. All the logic seems to be fine, but the relay itself does not get energized. I am wondering if this has something to do with current draw - I am measuring between 75 - 150 mA on my meter, but that seems to be within the limits of the ESP32.
Because each timer object can support up to 16 timer instances. So, one timer object (which you’d normally call timer) should be used.
Then, what you’re doing with your timers is a bit weird. You’re turning your relay on once every second, all of the time. Then, you’re turning it off once every other second. Depending on how the timing of this works, your code could be turning your relay on, then immediately (within a fraction of a second) turning it off again. The end result could appear that the relay is always on, even though it is actually being turned off for an instant.
Are your relays active HIGH or active LOW ?
Are they the same relays that you’ve used previously?
What version of the ESP32 core, and Blynk library do you have installed?