Connecting 8-relay module to Mega with external power

Hi all,

I experienced some weird problem with operating a 5V 8-relay board with an Arduino Mega.
I followed the excellent guidance specified here.

Please not that although in the below pictures, the jumper is still on the VCC and JD-VCC, it was removed for all experiments.

The external power that I use to power the relay board is 12V - 2000mA (see attachment).
To make sure that this power does what it is expected to do, I just hooked it up to the relay board as specified in the wiki and connected it to the VCC. The relay board's IN1 ... IN8 was connected to its GND.
It all looks like you can find in the attachment Scheme_1.

To go from 12V to 5V is done by the ywrobot board that outputs 700mA max. But that appears to be sufficient as all the relais were ON.

As a next step, I added the Arduino Mega with its own power-supply being the same type as the relay board power supply.
Now the VCC of the relay board is connected to the VCC of Arduino Mega.
The relay board's IN1 ... IN8 is connected from the Arduino pin 28 to 35.
Please find this in attachment Scheme_2.

The following sketch was loaded in the Arduino Mega, every second turning the next relay on and when they are all on, every second turning the next relay off in the same order.

#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Time.h>

//Arduino1 - mac address
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//Arduino1 - ip number
IPAddress ip(192, 168, 111, 19);
//Arduino1 - local port
unsigned int localPort = 8888; // local port to listen on

void setup(){
  Serial.begin(9600);
  //start ethernet
  Ethernet.begin(mac, ip);
  for (int i = 28; i < 36; i++){
    pinMode(i, OUTPUT);
    digitalWrite(i, HIGH);
  }
}
void loop(){
  for (int i = 28; i < 36; i++){
    Serial.println ("Relay " + String(i-5) + " on");
    digitalWrite(i, LOW);
    delay (1000);
  } 
  for (int i = 28; i < 36; i++){
    Serial.println ("Relay " + String(i-5) + " off");
    digitalWrite(i, HIGH);
    delay (1000);
  }
}

The results are as follows:

  • the first time the relays are turned on one by one, everything goes well up until the 7th. Turning the 8th on rattles because it is switching on and off as quick as possible
  • when the relays are then turned off one by one, the 8th no longer rattles as the first 2 relays are turned off.
  • the second time the relays are turned on (because the program keeps running), the 7th relay goes nuts in the same way and so does the 8th.
  • Once the first 2 relays are turned off, the rattling stops are those relays are just on as expected.
  • This keeps going in the same way for the rest of the time.

Then I tested with another power supply to power the Arduino (12V - 1000mA). See attachment.
Executing the same sketch results in the first 7 relays being turned on as expected. The last relay was not turned and the led was not brightly shining. Once 1 or 2 relays were turned off, the 8th relay became on.

Thanks in advance for the help on clarifying this!

Adapter12V2000mA.jpg

Probably drawing too much current for the breadboard and jumper wires. Try wiring it all up directly.

Paul

deejay808:
To go from 12V to 5V is done by the ywrobot board that outputs 700mA max. But that appears to be sufficient as all the relais were ON.

Not possible with 12volt input.
This board has 7111 regulators that top at ~1watt power dissipation on a board like that.
They have to drop (12-5=) 7volts.
1watt is reached at 1watt/7volt = 143mA.
You can drive TWO relays with a 12volt supply.
You might be able to use 8 relays with a 6.5volt supply.

You should have bought a 12volt relay board.

Edit: Saw your ethernet code. If you use an ethernet shield on top of the Mega, then the onboard regulator of the Mega could also be in trouble with a 12volt supply (shutting down randomly). Feel if the black part next to the DC jack is hot. If so, drop the supply to 9volt, or even 7.5volt.
Leo..

1 Like

Thanks Wawa! Indeed, I dropped the voltage to 6V and it works as expected. Thanks also for the advice on the ethernet board combined with the Mega.

David