ArduinoGeneral

Relay Shield for Arduino V2.1 (DFR0144) - Relays not activating

userHead Rasmuskjer 2013-02-28 20:31:52 9089 Views9 Replies
Hi there.

I am having trouble turning on the relays on the brand new 2.1 relay shield.

Let me explain to you what I am doing.
[list]
[*]
Using the newly provided sample code for the 2.1 shield where you have to push the buttons to activate relay

[*]
Hooking up a normal lightbulb and wire to the relay.
The end connected to the wallplug is inserted in the COM1 port, the end going to the bulb is connected to the NO1 port.

[*]
Arduino gets 5v, the shield gets 9v. USB is connected.

[/list]
I dfrobot in Denmark so the wallplug voltage is 240v.

Connecting the one end of the lightbulb to the NC1 port makes the bulb shine - so the bulb and wiring is working.

What can i be doing wrong here? Pressing the S1,S2,S3,S4 buttons does not turn the light when it is connected to those relays.

I have never heard a clicking sound indicating that the relays are turning on.

I also tried using the following code to try to make it work.
[code]
void setup(){
Serial.begin(9600);
Serial.println("Starting Up");
pinMode(2,OUTPUT);
}

void loop(){
Serial.println("Going High");
digitalWrite(2,HIGH);
delay(3000);

Serial.println("Going Low");
digitalWrite(2,LOW);
delay(3000);
}
[/code]

Monitoring the serial port output showed that everything was working as expected.
LED1 was turned on for 3secs, then off for 3 secs - lamp didn't turn on/off.

A multimeter test showed that relay 1 never gets activated.

What are your thoughts ?
2024-08-09 00:19:22

Here is a different approach to code using this shield. The original post code did not work for me.

Notice the case statements - much cleaner. 0 for on/off all relays, not pwr.

 

#include<IRremote.h>
   
#define button_0 16593103
#define button_1 16582903   
#define button_2 16615543      
#define button_3 16599223    
#define button_4 16591063

int RECV_PIN = 11;      
IRrecv irrecv(RECV_PIN);
decode_results results;

unsigned int value;

int relay1 = 2;
int relay2 = 7;
int relay3 = 8;
int relay4 = 10;

bool relayState1 = LOW;
bool relayState2 = LOW;
bool relayState3 = LOW;
bool relayState4 = LOW;
bool allState = LOW;

bool x = 1;

void setup()  {
 Serial.begin(9600);

 pinMode(relay1, OUTPUT);
 pinMode(relay2, OUTPUT);
 pinMode(relay3, OUTPUT);
 pinMode(relay4, OUTPUT);

 irrecv.enableIRIn();  
}

void loop() {
 
 if (irrecv.decode(&results))  {
   Serial.println("code recieved");
   value = results.value;
   switch(value) {

     case button_0:   if (x = 1) {
                   allState = !allState;
                   digitalWrite(relay1, allState);   
                   digitalWrite(relay2, allState);
                   digitalWrite(relay3, allState);
                   digitalWrite(relay4, allState);
                   }
                   break;

     case button_1:  if (x = 1) {      
                     relayState1 = !relayState1;      
                     digitalWrite(relay1, relayState1);
                     }                        
                     break;
     case button_2:  if (x = 1) {      
                     relayState2 = !relayState2;      
                     digitalWrite(relay2, relayState2);
                     }                        
                     break;
     case button_3:  if (x = 1) {      
                     relayState3 = !relayState3;      
                     digitalWrite(relay3, relayState3);
                     }                        
                     break;
     case button_4:  if (x = 1) {      
                     relayState4 = !relayState4;      
                     digitalWrite(relay4, relayState4);
                     }                        
                     break;

      default: {
                 Serial.print("Key ");
                 Serial.print(value);
                 Serial.println(" not programmed");
               }
               break;
   }

   Serial.println(value);      
   irrecv.resume();
   Serial.println("Resumed the IR reciever");   
 }
}

userHeadPic Donnie.Alfonso
2015-10-26 17:37:30 Change your Baud rate to 57600baud on the serial monitor userHeadPic lennonf
2013-04-24 10:34:36 @ KlausF

[quote="KlausF"]
I also have a problem with a brand new Relay Shield 
I have followed the posts here - downloaded the sample code and tried everything i can think of - but I can't make anything happen!
I have connected power to the power port on the attached Arduino board, i can trace power to the Vin 5v and 3V pins on the shield, but the power LED on the shield does not light and none of the push buttons have any effect on the relays.

Anyone with any thoughts - your input would be greatly appreciated!

Klaus
[/quote]

Hi, do you power the Arduino board from 7 to 12v? You said that you can trace power from 5V header on the shield, that means the PWR led should be light. Can you give a diagram picture or more details?

Best
userHeadPic Phoebe
2013-04-24 10:18:32 @Rasmuskjer
[quote="Rasmuskjer"]
I already am supplying power with 5v through to the Arduino Uno power jack and 9v to the relay shield jack.

Are you saying that I should put i.e. 9v in the Arduino Uno jack and 0v in the relay shield jack?
[/quote]

Hi, Really really sorry for replay so late :-\ . Yes , you are right , please put 9v in the UNO jack. the Screw terminal on the shield is just power for servo. So you needn't power it if you not use servos.
By the way, have you solved the problem?

Best
userHeadPic Phoebe
2013-04-23 19:48:31 I also have a problem with a brand new Relay Shield 
I have followed the posts here - downloaded the sample code and tried everything i can think of - but I can't make anything happen!
I have connected power to the power port on the attached Arduino board, i can trace power to the Vin 5v and 3V pins on the shield, but the power LED on the shield does not light and none of the push buttons have any effect on the relays.

Anyone with any thoughts - your input would be greatly appreciated!

Klaus
userHeadPic KlausF
2013-03-05 15:09:17 I already am supplying power with 5v through to the Arduino Uno power jack and 9v to the relay shield jack.

Are you saying that I should put i.e. 9v in the Arduino Uno jack and 0v in the relay shield jack?
userHeadPic Rasmuskjer
2013-03-05 12:02:25 Hi,

The relay shield must be powered from 7 to 12V, you should supply power from the Arduino power jack so that it can work. Check,weather  the PWR led is on :)

Best regards
userHeadPic Phoebe
2013-03-05 02:57:53 Wow, thank you so much for making so much effort to help me. It's just amazing to see :)
I really do appreciate your efforts here! :)

I have now done exactly at described in the wiki, and none of my shield relays are working :(

I tested my method on a simple Grove relay i bought a while ago and made it work right away.
I believe i am doing everything right - so i guess the board must be faulty. 
userHeadPic Rasmuskjer
2013-03-01 10:56:58 Hi,

Relay shield for Arduino V2.1 has update. Please check the site:
[url=http://www.dfrobot.com/wiki/index.php/Relay_Shield_for_Arduino_V2.1_(SKU:DFR0144)]http://www.dfrobot.com/wiki/index.php/Relay_Shield_for_Arduino_V2.1_(SKU:DFR0144)[/url]
userHeadPic Phoebe