As per my requirement I would like to turn on and off 3 single relay modules in 5 seconds interval. I have written simple program to achieve the same.
For this I am using ATtiny2312 MC, after executing the below program I observed weird results.
I connected pin#4 with relay module 1 - working fine. (single relay module)
Now, I connected pin#5 with relay module 2 then the both relay module LED's are blinking continuously and relay1 is turned OFF (connected two relays with 4 and 5 respectively.)
Now, I connected relay module1 with pin#4, relay module 2 with pin#5 and relay module 3 with pin 6. Now, the same scene repeated as mentioned in point#2.
I tested the all the above scenarios with arduino usb power 5v.
Now I realized that the usb power is not sufficient to drive all relay modules, so I connected with external 5v 1.5amp power supply for ATtiny2313 and all the relay modules.
The worst part is the same scene repeated with external power supply as well.
I am really not sure what's wrong with my connections.
// Pin definitions
const int RELAY1 = 4;
const int RELAY2 = 5;
const int RELAY3= 6;
const int BLINKLED = 13;
void setup() {
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(BLINKLED, OUTPUT);
digitalWrite(RELAY1, LOW); // Ensure START_RELAY is off initially
digitalWrite(RELAY2, LOW); // Ensure START_RELAY is off initially
digitalWrite(RELAY3, LOW); // Ensure STOP_RELAY is off initially
digitalWrite(BLINKLED, LOW); // Ensure dry run LED is off initially
}
void loop() {
digitalWrite(BLINKLED, HIGH); // Ensure dry run LED is off initially
delay(1000);
digitalWrite(BLINKLED, LOW); // Ensure dry run LED is off initially
delay(1000);
// Activate RELAYS
digitalWrite(RELAY1, HIGH); // Turn on START_RELAY
digitalWrite(RELAY2, HIGH); // Turn on START_RELAY
digitalWrite(RELAY3, HIGH); // Turn on START_RELAY
delay(5000);
digitalWrite(RELAY1, LOW); // Turn on START_RELAY
digitalWrite(RELAY2, LOW); // Turn on START_RELAY
digitalWrite(RELAY3, LOW); // Turn on START_RELAY
}
Arduino has no on-board power. It must always be supplied with power. Did you mean to say that the servo is being powered through USB cable by PC/laptop?
Posting an annotated schematic would make solving this much easier. Be sure the grounds are all connected together and the arduino ground and relay ground connect at the power supply. This keeps the relay current from passing through the Arduino.
I tried with 5v 3Amp. external power supply for both MCU and all relay modules. But still all relay output led's are dim its brightness and continuously blinking
If I try to trigger multiple relay modules at a time then the relay module power is going down. I tried to connect with external power supply rated 5v and 3Amp. Still issue persists.
Connect Relay1 with the MCU and turn it in the setup function. Get 5V and GND of the Relay1 from the Host Arduino. Check that onBoard LED of Relay1 is on and the Realy1 is not chattering.
How are you programming your MCU -- using Arduino as ISP or AVR Programmer?
Yes I did the same. Relay1 is working fine if I connect with the arduino power. Problem with triggring two relays at a time either with arduino usb power or external power supply. I am using ATtiny2313 microcontroller.
Your program is OK.
The issue is probably caused by bad wiring on your breadboard and/or unconnected grounds
The ATtiny ground, the relay grounds and the power supply grounds must all be connected together