ok so i have an Arduino UNO at my disposal and i plan on writing the code to detect my dogs presence with an PIR sensor. I currently have a relay shield with two relays. I plan on making one relay turn on when my dog gets close. to do this I have a PIR sensor shield. once this has been detected I want the first relay to turn to NC so that it may complete the circuit for a water pump to turn on and start pumping water. it should only pump water for five minutes and then turn off until the next PIR sensor trip is detected. this should be simple but I cannot get the info quick enough from the arduino books I have so I am looking for like minded folks to discuss the process with me to eliminate unnecessary waste of time. anyone willing to provide some advice is greatly appreciated. Thanks
PIR sensors come in various flavours. Alarm system ones usually are powered by 12v and have NC relay contacts as output. Hobby ones for Arduino projects usually will run on 5v and have a open collector output.
Whichever you use, the program will look for an input similar to any simple switch.
To time your running of the water, use millis().
Weedpharma
thank you weedpharma! if this helps any this is the exact properties of the PIR sensor I am utilizing.
Operating voltage range: DC4.5-20V
Quiescent Current: <60uA
Level output: Gao 3.3V / Low 0V
Trigger: reusable trigger (default)
Delay Time: The default 8S + -30%
Board Dimensions: 10 * 23mm
Induction angle: <100 degrees cone angle
Sensing distance: 3 meters
Working temperature: -20- + 80 degrees
Sensor Lens Dimensions: Diameter: 10mm
if i understand correctly any voltage from 5v to 20 volts would be acceptable to make this shield operate as intended. im sure voltage has to affect sensing range so ill be using a 12volt power supply for this project. so i am expecting a 1.5 meter or so detecting range which is fully acceptable. the 8s delay is no big deal and should not affect functionality.
so to ensure i am understanding right. I should set the analog pins A0-A5 to read the HIGH or LOW state of the PIR sensor? and the Digital pins to send the HIGH or LOW signal to the relay shield?
PIR sensors have digital outputs.
On or off.
OK to connect them to a digital input.
Do you have a link to the relay board.
Leo..
This looks like an open collector output so you need to tie the digital input to 5v.
The delay is likely to be the time it will remain active rather than a time to operate.
It will probably have a regulator onboard so voltage is unlikely to have much effect on range. It detects incoming rather than sending any signal.
Weedpharma
Thanks Wawa and thanks again Weedpharma
ill try to figure out the code tonight and play around with the setup. I should have everything I need to make the circuit tonight and test it out. so I should use delay to be the "OFF" time of the relay instead of the run time?
Relay board has these specs:
5V 2-Channel Relay interface board, and each one needs 50-60mA Driver Current.
Equiped with high-current relay, AC250V 10A ; DC30V 10A.
Standard interface that can be controlled directly by microcontroller (Arduino , 8051, AVR, PIC, DSP, ARM, ARM, MSP430, TTL logic).
Indication LED’s for Relay output status.
so according to this I dont need an external power supply but I will need one for the pump to operate so it will be accessible... why not use it to take the strain off the arduino im thinking...
The relays are most likely active LOW.
I don't think it's a problem to power two relays from Arduino's 5volt rail.
How are you powering the Arduino.
Mains plugpack, voltage?
Leo..
The sensor needs to be tested to see the state of the output in normal and triggered condition.
I expect that the output will be a steady state until triggered then change state for the delay period before resuming the steady state condition.
You need to detect the change of state only, for when it is triggered. The delay is not relevant.
Weedpharma
Thanks Wawa and Weedpharma.
I found some useful links to read and mull over for the sketch. I thought the hardware would work in this manner??
Relay Normally Open no current Until PIR sensor triggered.
would'nt this indicate that as long as the PIR sensor is in LOW state (Untriggered) there would be no signal going to the arduino for it to register. IOW the state be 0 or LOW?
Once triggered it would send Arduino a HIGH reading that would flip the relay to NC state. therefore powering the pump connected to the relay terminals.
So I anticipate having to:
Set pins for PIR sensor (+,-, OUT)
Set pins for relay input (VCC, IN1, IN2, GND)
Set pins for relay output(GND, NC, NO, COM)
Then Ask Arduino to read the input from PIR to determine wether to flip the COM on the relay and have this action delayed for 300,000ms to allow for pump to be active for 5minutes. then re-read the PIR state to check for movement after the 5 minutes is up.
If no movement switch the NC to NO and cut power to the pump so no more power is being used other than the loop of checking for PIR state which will occur continuously and only pause when the 5 minutes of water pumping is enabled.
am I thinking of this entirely wrong?
is the method your mentioning Weedpharma the best way to go? as far as ease and reliability?
from what I gather your telling me that the PIR sensor operates in high state and turns to LOW state when movement is detected? therefore I would need to tell arduino that as long as there is a high state the relay is to stay in the NO position? I may have the basis of the PIR sensor wrong, ill read some more on it but would continue to appreciate your knowledge on the matter. Thank you both for helping. perhaps a brief overview of how im going to program this would also help clear any confusion. not all the code or anything i'll do that but a brief overview of how the code is to be arranged such as
- code to assign pin values
- code to read state of PIR
- code to flip relay and delay for XX time
- loop back to 2.
is this on the right track?
Thanks
in response to Wawa's question, i will be powering this from an external Power supply provinding 12 volts to the motor via the relay connections and 5v to arduino via the built in power power plug
silverdrgn:
in response to Wawa's question, i will be powering this from an external Power supply provinding 12 volts to the motor via the relay connections and 5v to arduino via the built in power power plug
The DC jack needs 7.5volt minimum for Arduino's onboard 5volt regulator to do it's job.
With only two relays, it's safe to power the Arduino from 12volt (DC jack).
Leo..
Wawa:
The DC jack needs 7.5volt minimum for Arduino's onboard 5volt regulator to do it's job.
With only two relays, it's safe to power the Arduino from 12volt (DC jack).
Leo..
so I can just make a connector that gives arduino 12volts? that would not be an issue i just was not aware that it needed minimum of 7.5volts. thanks for that Wawa.
Hi,
This looks like an open collector output so you need to tie the digital input to 5v.
Tie the digital input to 5V, with a 10K resistor, don't just connect it directly.
This will let the open collector pull the input to gnd when activated.
Tom...
so i have been reading this wrong :o ... in order for current to pass through the pin must be in a high state. so high would be the equivalent of NC on a relay... from my understanding.
I would have to set Digital pins to Low state to be able to switch them to high state when PIR sensor is activated... The previous advice is making more sense now. I had the understanding inverted. ok well lets read some more to figure this all out...
Not quite there yet.
You do not set an input high or low. You use resistor connected to 5v to put a logical high on the input. This can then be taken to a low by switching it to gnd.
It is voltage that is read.
Weedpharma
The PIR sensors I have seen don't need any pull-up or pull-down resistors.
They have a 3.3volt digital output, sometimes with a 1k or 1.5k resistor in series.
Just connect the PIR to ground, 5volt, and a digital input.
Relay cards usually have an opto that has to be pulled LOW to activate the relay.
In this case, you are going to supply the relays from Arduino's 5volt rail.
So you have to connect +5volt, ground, and the relay input to the Arduino.
No pull-up or pull-down resistors.
Leo..