How many 5V relays can I control with Mega2560 R3 and Wemos Mini D1

Hi,

I have quiet successfully created a home heating control system using DhtP22 sensor and different arduino based boards to switch 220V actuators using relays.

To be specific:
Downstairs I use a Mega2560 T3 to switch 5 groups of actuators using a '8-Channel 5V Relay Module Board Shield for Arduino PIC AVR MCU DSP ARM'. Oh and the board also has an Ethernet Shield! (the sensor are connected to a separate Wemos board which sends it data over IP to the Mega2560)
This board was powered through the USB connector using a 5.2V 2A power supply.

It actually worked quiet fine and was relatively stable (sometimes working for months without any intervention) but recently I noticed the relays no fully switching especially if a few groups became active at the same time, leds were dim etc. So I replaced the power supply with a 12V 2A external power supply and using a 1pcs MB102 Breadboard Power Supply Module 3.3V 5V and it seems OK (for now)

However that meant that I had to change my configuration Upstairs:
a Wemos D1 that drives 4 relays! It is now powered through the USB with a 5.2V 2A power adapter. It seemed to work fine at first to drive the 4 relays and 4DHT 22 Sensors but after a couple of hours I stopped working :frowning: and now doesn't even seem to be able to switch 1 relay for a few minutes
The board keeps working fine when I disconnect the relays...

Basically I am a developer and understand code and binary logic very well but get a bit lost when talking voltage and currents? I thought the relays hardly drew any power when activated or maybe only even when you switch but that assumption now seems incorrect and I am afraid I might have damaged some of my boards or the things that are called 'voltage controllers' on them?!

to summarize I have some questions:

  1. How can I calculate how many relays I can use with each board (Mega2560 and Wemos D1)
  2. What is the recommended power supply for each board assuming it needs to drive 4-6 relays?
  3. Does it makes sense to delay switching relays 'on' to prevent a power surge or will the still draw the same power once they are all 'on'
  4. I am thinking of replacing my old boards with more capable WiFi based boards that can take in up to 8 sensors and drive up to 6 relays. Any suggestions?

Any help much appreciated

Everything depends on your relay modules.
Some have optocoupler inputs or an extra led, and it could be between 10 and 20 mA per channel.
The Mega2560 can output 20 mA with a pin, but there is a limit for the maximum current through the VCC and GND pins of the ATmega2560 microcontroller.
There is also a limit of the current that the 5V pin of the Arduino board can give.

The ESP8266 and ESP32 boards might not be able to output so much current. There are special relays modules for those.

Can you make a drawing of how everything is connected ?

This relay board ? https://www.amazon.com/8-Channel-Shield-Module-Optocoupler-Arduino/dp/B01ARS8OVQ.
The relay is SRD-05VDC-SL-C, it seems to requires 70 mA for the coil. Unless they are counterfeit and then it might be something else.

This voltage regulator board ? https://www.amazon.com/CorpCo-Breadboard-Supply-Arduino-Solderless/dp/B00ZO9YB1G.

  1. Then we have to know everything. Try to find the specifications, or measure the current that is required per channel.

  2. I suggest 250 mA for the board and 6 * 70 mA = 350 mA for the relays, so 1A power supply should be okay.

  3. There is no higher inrush current. Any decent power supply can supply enough current at once. On the other hand, if you have many relays and long wires, that can cause a voltage drop. Perhaps you don't like the massive sound of all the relays at the same time. If you want, you can put 10 to 100ms between them.

  4. ESP32 ? It depends on the sensors. The temperature sensor DS18B20 needs only one pin for multiple sensors. Perhaps there is a I2C relais module ?

If you buy from a good seller (Adafruit, Sparkfun, Pololu), then you get the schematic and it is easier to determine what components are used and how much current it needs. You will also support open-source companies.

I have a question for you: Do you think that your relay board is allowed to switch the mains voltage ?

You encountered a power supply failure, I would assume if you put a scope on the output you would see a lot of power line ripple. When you say relays, correct me if I am wrong but you are talking about those rated 10A or less and operate on DC voltage. I think the best way to look at this is what design what you want then calculate what you need.

#1. How many relays, this can be in the hundreds depending on your hardware & software configuration.
#2. Recommended power supply, depends if you are talking about the relay coils and or the load. Always leave at least a 10% or greater safety margin on the amperage. The power supply takes the abuse in most systems.
#3. Is load dependent, what is the connected load and if it is less then a few amps no problem
#4. It depends on your answers to the previous questions.
A power supply an Arduino IS NOT!

Thanks @Koepel and @Gilshultz for your detailed replies. I understand things a little better now.

And after doing some research I think I will upgrade my controllers to:

an Arduino MKR WIFI 1010 board
Plus the Arduino MKR Connector Carrier

As used in this project: https://create.arduino.cc/projecthub/Avilmaru/smart-plug-with-arduino-mkr-wifi-1010-63cb25?f=1

What do you think?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.