Using normal Arduino loop with Blynk? (Arduino Doorbell Project)

Hello there!
Disclaimer: I’m new to Blynk and IoT in general.

I have an arduino project where I listen to the doorbell with a piezo and depending on the pattern of the door ringing I have a servo which presses the door opening button. In the code, I use the arduino loop-function to check for the door bell.

My plan is to use an ethernet shield to put on my Arduino Uno to get internet access.
Now, I want to be able to also open the door using a button on my smartphone using blynk.
My question is: How can I still have a loop running that does all these things the arduino did before? (Because I can’t really use the arduino “void loop()”-function anymore when using blynk)
I read through the documentation and I am still unsure.

To put it another way, I think I know how to use a virtual pin to control the servo to open the door with the button in the app, but how can I maintain the “doorbell listening functionality” which has to run in a loop to constantly check on the doorbell?

My current relevant code as pseudocode:

void loop()
       check for doorbell (piezo)
            if someone is ringing:
                 check pattern
                          if correct: open door

And don’t get me wrong, this part of the code works fine, the question is just how I can implement it when using a blynk sketch.

I’m sure somebody can help me with this :slight_smile:

Joel

You have a few options…

1 (simplest) keep your void loop as it is, and put some Blynk.run commands in your check for doorbell, check pattern and open functions, so that the Blynk library gets its share of attention.

2 increase the Blynk heartbeat timeout beyond the default 10 seconds to avoid unwanted disconnections

3 a combination of 1 and 2

4 go for an ESP32 processor and run a multi-threaded sketch which uses both cores of the processor. There are a few examples of how to do this, including this one:

Speaking from personal experience, I wouldn’t touch an Arduino + Ethernet shield combo ever again. I wrestled with this setup, and with multiple Ethernet shields, for months. I did all the tricks with capacitors across the reset button, and code to ping external websites and reset the device if the pings failed, but I couldn’t get a system that worked reliably 24/7 without manual intervention.
The Uno + ESP-01 combo is somewhat better, but still no match for an ESP8266 or ESP32 with native IoT capabilities.
For those reasons alone, I’d go for the ESP32 option.

Pete.

2 Likes

Thank you so much for your answer!

I didn’t know about the ESP32, but it sounds like a really good option.
I will definitely try it out!

Thank you
Joel.

If you find out your answer for this thread please also share code with me :blush: @schoeggi

Will do!