Hello everyone,
Having a problem with relays and cannot get the point.
I have 2 Arduino MKR1010 WiFi, latest Blynk library version, code with Arduino IDE on Mac OS.
On the first, I have a single relay connected just with Signal and GND pins, no VCC and works perfectly on Button Widget (Push/Switch) set to Digital Pin with no code, just declared the pin to be OUTPUT
in the void setup
.
On the second I have a 4 channel relay shield fully connected (VCC to VCC, GND to GND and Signal1-4 to D1-D4, won’t work without VCC pin). 4 widgets directly connected to D1-D4
void setup() {
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
This code returns the relays to start HIGH and work inverted (button ON = relay LOW). I tried to
-
add
digitalWrite(1, LOW)
in the setup, but nothing change. -
tried the opposite with
digitalWrite(1, HIGH)
in the setup, but again nothing change. -
add
digitalWrite(1, LOW)
in the loop: relays starts HIGH and button in not responding (obviously). -
switch 0-1 to 1-0 in the Widget and relays starts HIGH. Change to LOW after pushing the button twice (button ON->OFF).
-
declare the pins as
INPUT
orINPUT_PULLUP
, but nothing worked. -
do not declare any
pinMode
, but nothing changed.
I tried to change the code linking the widget to a virtual pin like this
BLYNK_CONNECTED() {
Blynk.syncVirtual(V5);
}
BLYNK_WRITE(V5) {
digitalWrite(1, param.asInt());
}
void setup() {
pinMode(1, OUTPUT);
and I had exactly the same behavior, but if I switch 0-1 with 1-0 in the Widget the relay starts always HIGH but goes to LOW in a few seconds and then works correctly.
this happen after any reboot of the Arduino and it is of course not acceptable because those relays will switch on and off other Arduinos on demand. The only solution I could think is to switch NC to NO on the other side of relays, but this would mean keeping HIGH the relays for most of the time and I am on battery power… I don’t know what is the exact power consumption, but I think it’s not a good idea anyway.
I tried 3 different 4 channel relays modules and they all work the same.
Can you help me solve this? I’m at your disposal for further tests.