Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Interface a normal PIR to a PIC?

Status
Not open for further replies.

Hippogriff

Member
Hi,

A while ago I created a nice project where I used a PIR sensor that outputs a +5V when it senses something, lovely for interfacing to a PIC. It's a little bare-bones, though, as it's just the sensor on a tiny PCB and three wires (positive, negative and output)... I now want to look into something a bit more complete or professional looking. So I started to look at normal PIR sensors that you can buy for adding to security systems.

While I do have a mains socket (or USB) close to where the project will go, I'm not entirely sure how you can get a normal PIR to work with a PIC - are there accepted standards for how PIRs work, or is each one different and you'd need to read a datasheet, for example?

I was looking at this... https://www.amazon.co.uk/Brennenstuhl-1170900-Infrared-Motion-Sensor/dp/B002ZXWVZW ...as an example. Looks nice.

But I'm not entirely sure a) how I would power it (do I end up knocking-up my own mains cable?) and b) what it outputs when it senses something and whether I can easily connect that to a PIC (it seems to me that these PIR devices can act as a load switch... it sense something and it switches on a floodlight or something).

Is there a more complete product out there that outputs a logic 1 / high voltage when it senses something? My standalone PIR sensor does exactly that but it's not in a box and currently stands-out as it's looking at the area I want to cover and held up with Blu-tack. :) Not the best.

Are there PIR sensors that connect to a normal plug socket? Are there PIR sensors that are USB-powered? Searching - so far - seems to indicate not.
 
If a standard mains-operated PIR doesn't include a volts-free relay output you could use the PIR to switch a mains-to-low-voltage transformer, or opto-isolator, to interface with a PIC.
 
This is what I hate about Amazon: No links to manufacturer's data. This does say it is mains powered, but does not say it's potential free. I would suppose it isn't.

A security system PIR will likely be low voltage powered and with a SPDT or SPST potential free switch.

Security systems use the concept of a "monitored contact" where a resistor is placed at the End of Line (typically called an EOL resistor).

This allows detecting if the cable has been severed.
 
I admit to remaining somewhat confused.

So, are we saying that it's not going to be easy to find a mains-powered PIR sensor (or even a USB-powered one)? Not even one that would be designed to just turn a light on, not one that's intended for use in a formalised security system where it needs to be tamper-proof and all that?

I'm not sure I understand the concept of "potential free"... is that referring to what it 'outputs' when it senses something? I want a logic 'high' ideally (or something I can detect via a PIC interrupt pin), but they are all designed to switch something..? Is there a standard out there for what PIRs do when they detect something? I'd've thought so, if different PIRs were to play nicely with other systems.

Apologies for the - still - dumb questions. You start to think I might be better working harder on creating a case for my Parallax PIR sensor... https://www.parallax.com/product/555-28027 ...which I always thought was quite expensive for what you got and what it did...
 
There is no shortage of PIR Occupancy Sensors out there and many as you have noticed will simply switch AC Mains for lighting applications. There are also others as used in security systems and assorted industrial applications. For example I have one sitting here labeled a CX-105. A simple Google shows me it is one of these. It's a simple 3 wire device which requires 24 VDC power and when it detects the third wire goes high (24 VDC). Good enough to drive a small relay or be easily divided down to input to a uC. Unfortunately new they cost about $60 USD and up. There are PIR sensors like this one which can be easily connected to a uC or interfaced to any number of other devices.

What did you plan to spend?

Ron
 
Want professional:

http://www.visonic.com/Products/Wired-Detectors/PIR-outdoor-12v

Many motion detectors are designed for security, so a 12V or 24V UPS (battery system) is used. Reccom makes a nice power supply http://www.recom-power.com/?id=271&no_cache=1&user_recom_pi2[sword]=RAC03-SC that can be put into an electrical box.

I've used supplies from this http://www.alarmsaf.com/ company in a complex arrangement. Each output was Class 2 (PTC power limited), so it didn't require conduit. I needed multiple output sources (contact closure on) of 24 VDC power as well as some backed up 24 VDC power. The three major areas for use is access control, fire approve panels and camera. 12/24 and even 24 VAC is common.

My only comment is that it's a little tight in there. I added some DIN rail for the connections. The upgraded system had to have a separate battery box.
 
Nice stuff there Kiss.

Ron
 
FWIW: The outputs were strobes. The "same model" had two different inrush specs. The later design worked with the PTC's.

With Alarm-Saf "something" is missing with the documentation, but I really can't put a finger on it. It's basically, if you used the stuff before and have played with it, it makes sense as though you have to be part of the FAP/Access/Alarm/CATV professional. I wasn't impressed with the connections to AC.
 
There are PIR sensors like this one which can be easily connected to a uC or interfaced to any number of other devices.

This item is what I'm using now... it works fine - powered by 5V, outputs a logic high that my PIC can interrupt on, just a little "bare-bones"... doesn't look pleasant. Should either spend time putting it into some plastic case or buy something better looking - like the unsuitable Brennenstuhl I linked to in my first thread entry. I certainly don't mind paying an amount like £20 to £30 for something that would aesthetically do the business and work.

Also, these commercial (in the sense that they're being sold to the public, I mean) PIRs often have a light sensor included - so they only activate when a) something is sensed and b) there is a certain level of light.

My project does this, but I use a TSL237 as well... maybe there's a way I could get a PIR that would give me the logic high when both conditions are met?
 

This Visonic PL-1 looks to be a nice sensor to me, and it has a built-in photocell. I'd obviously need to use the 240v AC socket and regulate / change the voltage, via a wall-wart?, to 12v DC?.

It says it has a "N.O. relay output" how can I begin to equate that to a "logic high" for my PIC's interrupt pin? Apologies, I've not looked at this before - my interest has only been in RGB LEDs (as many know) in their various forms - strips, rings etc..
 
It says it has a "N.O. relay output" how can I begin to equate that to a "logic high" for my PIC's interrupt pin? Apologies, I've not looked at this before - my interest has only been in RGB LEDs (as many know) in their various forms - strips, rings etc..

One relay connection to 5V, other to PIC pin, pulldown resistor from PIC pin to 0V.

However, it's more 'normal' to use a pullup resistor, and have the relay contact down to 0V rather than 5V, this reverses the logic but you simply program it that way.
 
I'll obviously need to look into this, as I've not even used a relay before, nor do I have one in my bundle of bits (to play around with).

No big deal, I'd never used a diode (not light-emitting) until a few months back. :angelic:
 
It says it has a "N.O. relay output"
Caution. That MAY mean both/all the relay contacts are volts-free (hopefully); or it MAY mean that the Common terminal of the relay has a connection to mains Live and that the N.O output becomes connected to mains voltage when the relay operates. You would need to confirm before using the arrangement Nigel suggests in post #13.
 
This item is what I'm using now... it works fine - powered by 5V, outputs a logic high that my PIC can interrupt on, just a little "bare-bones"... doesn't look pleasant. Should either spend time putting it into some plastic case or buy something better looking - like the unsuitable Brennenstuhl I linked to in my first thread entry. I certainly don't mind paying an amount like £20 to £30 for something that would aesthetically do the business and work.

Also, these commercial (in the sense that they're being sold to the public, I mean) PIRs often have a light sensor included - so they only activate when a) something is sensed and b) there is a certain level of light.

My project does this, but I use a TSL237 as well... maybe there's a way I could get a PIR that would give me the logic high when both conditions are met?

Then you can either place it in a nicer enclosure or you can run with a commercial type sensor. Most commercial I have seen start at around $50 to $60 USD so that would seem to fit your budget. Some as you have seen include light sensing so they only turn a light for an example on after darkness. Also as mentioned interfacing a set of relay contacts to your uC input really isn't difficult at all. There are plenty of options out there. :)

Ron
 
it MAY mean that the Common terminal of the relay has a connection to mains Live and that the N.O output becomes connected to mains voltage when the relay operates.

I would have thought that is EXTREMELY unlikely, has anyone ever heard of any such thing? - and the N.O part of the spec. pretty well indicates otherwise.
 
Struggling to find that Visonic PL-1 to buy anywhere on-line... their "Where To Buy" section links me to loads of places, some with websites, some not. The usual of Amazon and eBay did not seem to be successful. If I can be confident in relaying to a PIC then I'll be golden with anything like this, I reckon...
 
NO means Normally Open (C to NO is disconnected when the relay coil is unpowered)
NC means Normally Closed (C to NC is connected when the relay coil is unpowered)
C means common

For a relay.

Relays can also be described by a for number. Form C, happens to be an SPDT relay.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top