In this article, I covered the basics of the connection between Arduino and the relay module with an LDR as the trigger. Upload the code and test the working of the circuit after that check the serial monitor to read the LDR readings and adjust the threshold value according to your need. If (sensorValue < thresholdValue) //setting a threshold valueĭigitalWrite(relayPin, HIGH) //turn relay ONĮlse digitalWrite(relayPin, LOW) //turn relay OFF Serial.println(sensorValue) //prints the values coming from the sensor in serial monitor Serial.begin(9600) //sets serial port for communication PinMode(relayPin, OUTPUT) //pin connected to the relay Int sensorValue = 0 // variable to store the value coming from the sensor Int sensorPin = A0 // select the input pin for ldr Program for triggering a relay with arduino and LDR The word "Normal" refers to the de-energised state.Įdit, sorry, I don't have the quote thing down.If you are using a normal relay instead of a relay module (which contains an in-build transistor/opamp on PCB) then you have to use a transistor in between the Arduino and relay to drive the relay because Arduino alone cannot supply enough current to drive a relay. contact on a relay will be shown as Open and an N.C. When you draw a diagram such as yours it is normal (conventional) to show all devices in their condition with no voltage applied. I added it because the buzzer was chattering rather than a clean loud sound. ![]() The top relay was giving me grief before I added the wire connecting +12V between the relays. Yeah, I don't think I need a diode there. Instead of guessing.Ģ0V for the bottom relay is coming straight off the power supply. If I'm correct about a resistor dropping voltage, I was just looking for a reasonable starting point from experienced people for the resistor value. Maybe something like 18V and 10V instead of 20V and 12V will do the trick. I'm not even certain a resistor will drop the voltage but assume it will. That's why I'm considering adding a pot in front of that relay to find a point where the relay will reliably open and close nicely when it's supposed to. If that relay is closed for a second, 12V can't open it. My problem is when 20V is lost that 24V relay gets hit immediately with 12V and the relay won't cleanly close. ![]() If the fuse blows and 20V is still applied to the bottom relay, the top relay will close sounding the alarm. The pump won't be running and that's a problem. They've been running like that 24/7 for over two years. My power supply has adjustable voltage and I chose 20V because it drives the 24V pumps well. The only other suggestion I can make is to put a diode in the line from the lower relay to the buzzer, to keep voltage from back-feeding through that path, but that really shouldn't make any difference if your diagram is correct.Ģ0 volts is an oddball supply voltage, where does it come from? Is the 20V for the lower relay supplied directly from the 20V supply, before the diode shown in the diagram? If it were powered after the diode, I can see a situation that would put that relay into oscillation. I can't really see any way for the top relay to get into the situation you describe, unless I'm misunderstanding the lower relay. ![]() If that is correct, then whenever you lose the 20V supply, the 12V battery will be powering the pump and upper relay coil, and also the buzzer, which will buzz constantly as long as the battery supplies sufficient power, regardless of whether the fuse is blown or not. You haven't shown the switch contacts in the lower relay, I'm assuming the +20V and ground on the left side are to power the coil, and the 12V on the NC contact will connect to the line on the right side when the relay de-energizes. If the fuse blows (the one shown on the diagram), then no voltage will be able to reach the upper relay, regardless if it is 20V or 12V, so there shouldn't be a problem. That still doesn't make much since in terms of the diagram you posted. Evidently, the contact blade is jumping back and forth at a good enough clip to cause vibration. ![]() It's not enough to hold the relay cleanly open but it's not de-energized either. But in practice as soon as the upper relay loses 20V it's hit with 12V. If I supply 12V to the 24V relay, it remains de-energized as expected. The idea is to hold the 24V upper relay open with 20V, then when 20V is lost the backup 12V kicks in, but 12V wont be able to hold the 24V relay open. Yes, just one battery and a battery tender (charger). The upper relay I'm having trouble with is to alert me to a blown fuse.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |