Hello world, this is my first post here,
I am using a 16 relay module low trigger (Amazon.com) and an Arduino uno r4 wifi (Arduino® UNO R4 WiFi — Arduino Online Shop).
My issue with both of them is that when I using a simple code like this one:
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
}
my relay N°2 wich is connected to my Digital Pin 2 is "OFF" (Everything ok) but when I I turn off the power source to my relay module and Arduino at the same time for a period of less than 1 second relay #2 turns on and then off again. This becomes a problem for me, as it is undesirable in my project. I have to mention that with the same code and connection when using an Arduino Uno R3 this doesn't happen. So, I'm starting to think that it might be some detail in the architecture of my Arduino Wifi.
Note: My 16-relay module is connected to an AC/DC adapter with an output of 12V DC and 2.5A, while my Arduino Wifi R4 is connected to an AC/DC adapter with an output of 9V and 1A.
I tried using the 5V pin on my relay module and connected it to the VIN pin on my Arduino. With this setup, the issue did not occur. However, I would like to know if it is possible to connect them using independent power source adapters.
With an Uno R3 you normally do this, to prevent activation of the relay during bootup.
void setup() {
pinMode(2, INPUT_PULLUP); // first enable internal pull up
pinMode(2, OUTPUT); // then set the pin to output
}
This 16-ch relay module has a design fault. Opto couplers, but no user-selectable opto isolation. With an Uno R3 and a 16-channel relay module you should power the Uno from the 5volt/GND of the relay module. No point using two supplies with this relay module.
No experience with the R4.
Leo..
Hello Leo,
thank you for taking the time to answer my post:)
I tried to use your sample code but I still have same problem. I have read about other issues relate to 16-ch relay module in the Arduino Forum, and there are some posts that say something and others that says the opposite (like the 5volt/GND of the relay module are inputs or outputs), I am a little confused right now.
also, I am using two different supplies due to I have read that is not a good idea to supply with the same one to both this is because to open the relays and turn on the LED, amperage is required, in addition to the Arduino. If the Arduino is drawing a significant amount of current for any reason (converted to 5v, as it operates at 5v), and simultaneously opening the relays, it may lead to insufficient power reaching everything from the power supply, causing potential issues.
That would be right for a 2,4,8-relay module with a JD-VCC jumper (if removed),
but the 16-channel relay module you have doesn't have a JD-VCC jumper.
It has 12volt relays, and a 5volt buck converter feeding off that. The buck converter powers the relay driver chips, and that VCC is directly connected to the Arduino. So no benefit to use two supplies.
Your problem seems to be the boot behaviour of the Uno R4.
As said, no experience with that beast.
VCC of the relay board should be connected to the 5volt pin of the Uno, not V-in.
A shared ground will then power the Uno from the relay module.
Leo..
Which doesn't work on the R4 believe it or not. Neither does:
digitalWrite(2, HIGH);
pinMode(2, OUTPUT);
Both of them leave pin 2 LOW.
The following mouthful of code does work with the R4s, at least in the case where nothing has previously set up D2 for anything else:
#if defined(ARDUINO_UNOR4_WIFI)
PORT1->POSR |= bit(5); // set D2 high on the R4 Wifi: port 1, bit 5
PORT1->PDR |= bit(5); // set D2 as an output
#else if defined(ARDUINO_UNOR4_MINIMA)
PORT1->POSR |= bit(4); // set D2 high on the R4 Minima: port 1, bit 4
PORT1->PDR |= bit(4); // set D2 as an output
#else
pinMode(2, INPUT_PULLUP); // first enable internal pull up
pinMode(2, OUTPUT); // then set the pin to output
#endif
Firstly, I want to express my gratitude for taking the time to read my post.
I don't have much experience with the C++ language, so I'm uncertain about how to implement the extensive code you provided.
While our discussion has centered around "bootup," my primary concern lies with the "bootdown or shutdown." I hope I have effectively conveyed my issue, but to ensure clarity, I've attached a brief video demonstrating the problem:
In the video, I showcase what happens to my Arduino Uno when I turn it off. Please take a moment to view it, and let me know if my explanation was not clear.
With 2,3,8-relay modules it is, but not with a 16-channel module.
With the 16-channel module you have it's the output of a 5volt buck converter.
Note that some of these 16-ch relay modules do have a buck converter and some don't.
Nothing bad will happen when you connect that 5volt output to the V-in pin of the R4.
But since it has to go through a buck converter on the R4, VCC of the R4 will be less than 5volt.
Strange things could be happen...
The supply of the Uno R4 probably dies before the supply of the relay module, setting all the pins LOW (no power state). Turning the active LOW relays 'on'.
Just power the relay module with 12volt,and the Uno R4 from the relay module.
You don't have opto isolation anyway.
Leo..
My reply was to Wawa to confirm that normal practices on the R3 don't work the same way on the R4. Setting the output high before enabling it to avoid a low pulse on the output at startup is one of them.
The R3 is a mature product. It has been largely de-kinked, as it were.
The R4 is still bleeding edge, and no, I didn't misspell that! There are sufficient "oh, that doesn't work" gotchas in it that unless there is some special function that you can only perform with the R4, my advice to you would be to save yourself much grief and just use an R3. It's what I do.