Physical Button freeze (not acting)

Dear Pete,
I probably didn’t explain it very well. I don’t want any freezing when the button is pressed. It doesn’t matter if the servers are connected or not, or if there is no internet, or if blynk want to connect to the server.

It works without freezing in the above code, but when blynk try to connect to the blynk server after a certain period of time, the loop freezes and does not perform button its function (checkPhysicalButton()) despite the push of a button.

Dear Pete,
arduino have special interrupt command - attachInterrupt()
Let me check it, maybe I will solve this problem with that command.
I will write result here.
Thanks

Mega has 6 interrupt allowed pins

Mega, Mega2560, MegaADK 2, 3, 18, 19, 20, 21 (pins 20 & 21 are not available to use for interrupts while they are used for I2C communication)

I understood what you were saying, you didn’t understand my answer.
But, the answer is still the same.

I’m well aware of how interrupts work, but they won’t help with your issue. If you do use interrupts on physical buttons then you’ll need to use debounce code within your ISR.

Is there any reason why you’re using an Uno and not a NodeMCU or ESP32 ?

Pete.

a lot pins needed for my project.

  1. 2 temperature sensor
  2. 2 level sensor
  3. 1 outdoor temperature sensor
  4. 6 input for light switch
  5. 12 output for relay
    e.t.c

Pete.

ESP32 development board has 23 GPIO pins.

ESP some pins give HiGH when booting.

so there is no another solution?

pins 5, 14, and 15 only.

Personally, I’d say that you should be re-thinking your device topography.
It very rarely makes sense to have all of your loads and all of your physical switches wired back to a single MCU.
It almost always makes more sense to have a segmented system where your MCUs and relays are located close to the devices that are being controlled.
For example, I have 10 devices in the room where I’m sitting and they all use relays to control devices and all have physical switches and can be controlled via Blynk or Amazon Alexa.
Each device has its load connected directly to it, so they are all connected via WiFi rather than being hard-wired back to a central hub.
If the WiFi or connection to Blynk fails then they continue to work via the physical buttons.
This setup also makes the system extremely flexible and re-configurable.

Even if I were building a system where everything was wired back to a central control box, I wouldn’t use a single MCU for everything, I’d segment my system and not have a single point of failure.

Pete.

1 Like

Dear Pete,
Thanks for the advice, i will look that solution also.
Describe that, interrupt cant interrupt Blynk server. ))
During attempting reconnection loop is still freezing.
11:28:26.111 → Attempting reconnection #2

As I said before, interrupts don’t do what you are looking for, and…

Pete.

Dear Pete,
Blynk.disconnect(); also freeze system.
I decided change system. Going to use impuls relay+ light switch .
We can close this topic.
Thanky.

I’ve marked the topic as solved.

As I said earlier,

If you are using Blynk.begin and there is no internet connection then the code processing will stop at that point. It doesn’t matter what code you have after that point, that code will never be processed.

I’m not sure that this will deliver the same functionality that you’d get if you changed to an ESP32 or a NodeMCU plus port expander, or a de-centralised system.

But, I guess you’re better going for a solution that you’re comfortable with and that you understand.

Pete.

2 Likes

Dear Pete,
This solution going to work even there is no android. This pulse switch like latch relay and has two NO contact. So i can control light with pulse either from switch or android relay board. From NO contact android can get feedback signal light is on or off.

I think I’d go for one of the WiFi connectable DIN rail switches if it were me, but really the product you’re looking at isn’t much different to the standard relay boards that most people use.

I still don’t understand the unwillingness to look at products other than the Arduino.

Pete.

Standart relay de energised if there is no voltage of relay coil. But this relay keep energised once receive 220 V pulse from switch. Also de energised if second time receive pulse.

It depends how you wire the contacts.

Yes, and you can achieve exactly the same result using an ESP8266 or ESP32, plus you add Blynk remote functionality too.
But you’d need to throw away that 12 year old Uno technology.

Pete.