Digitalwrite in timer does not work

Hello,

i’m trying to have my window blinds/rollers being opened by ESP32/Blynk. I was inspired by It's possible push a virtual button and disable other button? - #12 by Blynk_Coeur

But when adding a digitalWrite (for steering my relays) in the function that was called by the timer, the ESP32 rebooted when coming in this part of the code. When i removed the digitalWrite, all works fine.

Does anybody know why this happens and how it can be solved?

  1. Search forum for similar topics
  2. Check http://docs.blynk.cc and http://help.blynk.cc/
  3. Add details :
    • Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
    • Smartphone OS (iOS or Android) + version
    • Blynk server or local server
    • Blynk Library version
    • Add your sketch code. :point_up:Code should be formatted as example below.

Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.


void loop()

1 Like

Are you using blynk legacy or IOT ?
And post the sketch you’re using please.

Do you use a relay board ?
Did you try to use 2 power supplies , one for esp32 and one for the relay board?
I suspect a power loss.

Hi John,
i’m using Blynk legacy.
I indicated the added code by /added code/ . Without the added code if works fine, with the added code, the device reboots/stalls when triggering the rollerup-button.

[Unformatted code removed by moderator]

Hi Blynk_Coeur,
i’m using an simple 2 module relay (https://cdn.myonlinestore.eu/e40d5160-bac0-4897-baae-d6065a5d5915/image/cache/full/97ce289cafaef9a4e1728627e66b5906ef3949a1.jpg)

I doubt power loss, since by triggering the relay in the button push (no timer), it works just fine and stable.

1 Like

First, this is not the whole sketch

Second, please edit your post and add triple backticks at the beginning and the end of your sketch, triple backticks look like this```

It’s much easier to create a similar project in blynk IOT using the automation, I highly recommend you to try it.

John, Blynk_Coeur, thanks for your advice. Meanwhile i found the problem: power loss of the ESP32 due to triggering of the relay. Blynk_Coeur you were spot on. I was confused because i hadn’t any issues directly in the button routine, but the timespan for the relay was much shorter (1 ms vs 10ms) there.

2 Likes