6 years, 11 months ago.

Which pins should my PIR sensor be using?

So Im guessing that the ground wire from the PIR sensor goes to ground, the power one (from what I can see on the internet) seems to go to the IF- pin (I think this is incorrect though) and that the output wire goes to a pin of your choosing, I chose 29.

Is what Im saying correct? because my PIR sensor isnt working with my mbed at all. It wont even run the PIR Hello world, and it never has. I think the PIR sensor is broken, because everything else seems to be working fine

Anyway let me know what you think, I attatched a pic of the pins my pir sensor is going into. please let me know if its correct (in the picture the circles are each wire, red is power, black is ground and yellow is output /media/uploads/sonny_maan/mbedmicrocontrollerpinout4.png

Okay, so new problem, I only have a breadboard mini, and there is only one free hole horizontal from each pin when I put the mbed on the breadboard.

posted by Amritpal Maan 16 May 2017

1 Answer

6 years, 11 months ago.

Please post more details on your PIR sensor so we can advise accordingly.

https://www.rapidonline.com/pdf/61-1462.pdf This is the exact part

posted by Amritpal Maan 15 May 2017

Ok. PIR diagram helps. Black wire on your PIR module is GROUND and you are correct to connect to 0v (GND). Pin 2 of the module (WHITE wire) is the output from the PIR module and pin 29 should be fine for the mbed connection. Be sure your mbed code is making use of the pin 29 port pin = p29 label. The most important is the power pin on the module = RED wire which must connect to +5v. The IF- pin is not correct. Take the RED wire from your module and connect it to the VU pin on your module. Be careful to not short to the pin above or below the VU pin. VU pin is the +5 volt rail taken from the USB connector. If possible, measure the voltage of the WHITE wire when there is no motion and then again when there is motion in front of this module. Another comment is that it is possible the WHITE wire is an open-drain output. This means that the module will output a LOW but no HIGH level unless you apply an external pull-up resistor for example a 10k to +3v3 (VOUT on the mbed module). Then, when the open drain pin is 'high', it is the external 10k resistor (value is not critical for this resistor but should be say 2k2 or higher to say 20k) to +3v3 that defines the logic high value. Give it a test and post your results.


Start with testing without the external resistor. The external resistor will be a connection to port pin p29 (aka WHITE WIRE) for one side of the resistor and the other side of the resistor to the positive 3.3 volt (+3v3) leg. This resistor value is not critical but should be 2,200 ohms (2k2) or higher. Again, for now, do not worry about this extra part and just test as-is with the new VU port pin powering your PIR. Do you have a voltage meter ? If yes, connect black wire of meter to ground and red lead of the meter to the WHITE wire and check the voltage when there is no motion; again measure when there is motion in front of the PIR.


The LPC mbed board you have takes in +5 volts off the USB port on your PC -> uses an onboard LDO (low drop out voltage regulator and outputs a voltage rail of 3.3 volts for your external projects). That is the VOUT pin on your mbed module. That is, if you need a 3.3 volt power rail, you can use VOUT on your LPC mbed module.


Excellent on your persistence so far. You are correct if the output is open collector = open drain = same thing, different name. You will need to dig out a resistor from somewhere in your parts chest. Again the value is not critical but recommending any value higher than 2.2k (2k2) and under 20k. Connect one leg to p29 and the other leg of the resistor to the VU pin or the VOUT pin. If the resistor is too low then the WHITE wire will always be 'high' because the pull-up is too strong (ie. resistor is under 1k for example may be too strong for the module). What should happen is that the PIR WHITE wire should be LOW with no motion and logic high (3v3 or 5 volts) when there is motion.

Adafruit has some details on similar PIR sensors:

https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor?view=all

Output: Digital pulse high (3V) when triggered (motion detected) digital low when idle (no motion detected).


Believe you are using a bread board ? If yes then you can just insert the one leg of the resistor to the hole that is horizontal to the p29 pin. They are all connector together in a horizontal line. Then for the other side of the resistor, find the VU pin on the mbed and the where it lands on the breadboard and use the next free pin on the breadboard but it must be horizontal. Summary, the all horizontal pins on a breadboard are connected together till you reach an insulator (gap in the plastic).

See here for some guidance (otherwise you will need to solder the resistor with a soldering iron):

(see the bottom removed RED breadboard here to see the x-ray view of how they work):

https://learn.sparkfun.com/tutorials/how-to-use-a-breadboard

but this website is awesome on explaining the breadboard connections:

https://computers.tutsplus.com/tutorials/how-to-use-a-breadboard-and-build-a-led-circuit--mac-54746

so in the picture, holes 1A to 1E are the same connection. Then holes 2A to 2E are the same connection. Keep in mind that 1F to 1J are separate connections on the other side of the breadboard.

So for your LPC mbed module, locate pin 1 and it should be occupying the 1A..1E block. VOUT will be at the 1F..1J block of pins. Does that make sense ? Place one leg anywhere in the 1F to 1J block for a 3v3 output on p29. Why ? Because the pull-up resistor is connecting to VOUT pin which is +3v3. You can use instead the VU pin by connecting the resistor to 2F to 2J block of bread board pins and then you should see a logic high as +5 volts. Why ? Because VU is at +5 volts.

--

If you do not have a breadboard then you will have to either solder the resistor in place of carefully strip the RED wire so that it remains connected to VU or VOUT pin and then just wrap one resistor leg around this stripped wire and the other side of the resistor to the stripped white wire. The connection must remain for the resistor to perform its task.

Do you have a soldering iron or breadboard ? If not, must haves moving forward and many deals on ebay, etc. Adafruit, Sparkfun sell many at fair prices through Digikey, etc.

posted by Sanjiv Bhatia 16 May 2017

Hey, I switched the red wire, but I have no idea how to apply the pull up resistor you are talking about, do do I take the white wire and instead of putting it into the mbed, do I instead put it in a breadboard, and then do what with a resistor? does it have to be 10k? and what is +3v3 and what do I need to do with VOUT?

posted by Amritpal Maan 16 May 2017

This is all starting to make more sense, but bear with me Im an idiot. So I tried without the resistor, to VU like you said and the hello world pir program diddnt work, also from the pdf of the part I can see it is an open collector output, so Im going to have to probably add the pull up resistor like you said. How do?

posted by Amritpal Maan 16 May 2017

Okay, so I understand, one leg goes to pin 29, and the other goes to VU. But I already have a wire going into VU and a wire going into pin 29, so how do I do that.

posted by Amritpal Maan 16 May 2017