Hi, I am currently working on a project. I am using a relay module to act as a switch and an array of photodiodes to sense whether is there any light source.
Once there is light source, the relay will be trigger and switch on my device.
I having problem with the relay module. If I just running it without using any sensors, it work just fine.(Just sending HIGH and LOW to the pin)
But when I connect it to my main circuit, which is with the sensors, the red led on relay lights up but the relay won't work.
I supposed is current not enough?
http://www.sgbotic.com/index.php?dispatch=products.view&product_id=1717
the relay I am using right now
If only you had posted your program and a circuit diagram I might have been able to help.
UKHeliBob:
If only you had posted your program and a circuit diagram I might have been able to help.
Hi,
void setup(){
Serial.begin(9600);
pinMode(7,OUTPUT);
}
void loop(){
digitalWrite(7,LOW);
int val1 = analogRead(A3);
if(val1 < 700){
Serial.println("wake up");
digitalWrite(7,HIGH);
}
}
this is the code i using the test out
That code does absolutely nothing so no wonder nothing is happening...
Code edit in the mean time..
UKHeliBob:
If only you had posted your program and a circuit diagram I might have been able to help.

sorry currenly using my tablet... so i drew it on a paper, hope you understand
septillion:
That code does absolutely nothing so no wonder nothing is happening...
When I using this code, the relay module 's LED did light up when I shine lights on my photodiode. But the light is very dim.
Would you help me with this?
I wrote about your code but you made an edit in the mean time. This code makes more sens although it will never turn off the relay.
The circuit is very small (low resolution) so it's hard to spot an error.
But it should not matter if the load is connected or not. Or doe you power the load from the same power supply as the Arduino? You do get the message in serial monitor?
septillion:
I wrote about your code but you made an edit in the mean time. This code makes more sens although it will never turn off the relay.
The circuit is very small (low resolution) so it's hard to spot an error.
But it should not matter if the load is connected or not. Or doe you power the load from the same power supply as the Arduino? You do get the message in serial monitor?
Yes I do get the wake up message from the serial monitor. The load is using another power supply. I supply the arduino using a 9V battery
Do you hear the relay click?
I can't see your circuit (something with my server settings), but if you are powering the UNO and the relay board with a 9V brick, you don't have enough power. Try paralleling two or three 9V bricks to see if it delivers enough power to fire the relay(s) and supply the LED. Maybe try using a wall wart? The low power would explain why the LED is dim, and maybe why the relay is hanging.
septillion:
Do you hear the relay click?
Nope, never hear any, guess the current is too low for the relay coil
123Splat:
I can't see your circuit (something with my server settings), but if you are powering the UNO and the relay board with a 9V brick, you don't have enough power. Try paralleling two or three 9V bricks to see if it delivers enough power to fire the relay(s) and supply the LED. Maybe try using a wall wart? The low power would explain why the LED is dim, and maybe why the relay is hanging.
I need it to be portable, I will use a wall adapter to try it out tmr. Btw I am using arduino mega, does that make any differences?
Or do you think it is wise to design one more extra npn circuit to boost the current?
Well, so far you've done everything right, including posting all of the relevant information for us to look at. (Hint for the people who see the image "too small" right-click it to open it in a new window.)
That relay module looks like it's the perfect thing for this. "5V TTL interface" should mean that it has its own NPN transistor on board. Adding another won't help. A 9V battery is insufficient to drive motors but it should be able to drive many of these relays.
So on to the code...
void loop(){
digitalWrite(7,LOW);
int val1 = analogRead(A3);
if(val1 < 700){
Serial.println("wake up");
digitalWrite(7,HIGH);
}
}
This writes the output LOW on every cycle of the loop. Then, if the condition is met it writes HIGH. But the loop repeats and writes LOW again!
Move the first digitalWrite() into the else part of the if statement.
Damn, don't know how i overlooked the digitalWrite LOW :o That's why I said it never turns off again. But yeay, this way the relay gets pulsed very fast and a relay doesn't like that.
MorganS:
Well, so far you've done everything right, including posting all of the relevant information for us to look at. (Hint for the people who see the image "too small" right-click it to open it in a new window.)
That relay module looks like it's the perfect thing for this. "5V TTL interface" should mean that it has its own NPN transistor on board. Adding another won't help. A 9V battery is insufficient to drive motors but it should be able to drive many of these relays.
So on to the code...
void loop(){
digitalWrite(7,LOW);
int val1 = analogRead(A3);
if(val1 < 700){
Serial.println("wake up");
digitalWrite(7,HIGH);
}
}
This writes the output LOW on every cycle of the loop. Then, if the condition is met it writes HIGH. But the loop repeats and writes LOW again!
Move the first digitalWrite() into the `else` part of the if statement.
I tried this method but it still doesn't fires up the relay, it is on but same problem, displaying a very dim LED light.
Tried using wall adapter as well, doesn't work.
It works now. I typed something wrong in my code. THANKS FOR THE HELP GUYS 