I was trying to write a simple Python to detect the motion sensor output and print a message on the screen.

My connection was like below:

Raspberry Pi model B+

VCC of sensor: 5V (Pin 2) of Pi GND of sensor: GND (Pin 6 on Pi) Output of sensor: GPIO2 (Pin 3 on Pi)

am using the GPIO.BOARD congugration and I directly set my Pin 3 as input

When I read from this pin, it is always HIGH (Really surprising!)

Now I just change the connection as below

VCC of sensor: 5V (Pin 2) of Pi GND of sensor: GND (Pin 6 on Pi) Output of sensor: GPIO17 (Pin 11 on Pi)

I just change a variable called sensorpin in my code to 11 an everything works as expected!!!!

I do not understand what is the difference between using pin11 and pin3.... while both should have functioned as GPIOs.

Can anyone please help?


Pin 3 & 5 are intended for I²C and have 1.8kΩ pullups to +3.3V.

  • Milliways, thanks a lot for your answer. After you mentioned it, I connected an LED to this pin and I realized what you are saying. Once again thanks a ton for the answer. May 27 '16 at 6:06
  • I should add a small (entirely self-serving) point to this: gpiozero would guard against this. As of 1.2 it knows which pins have physical pull-ups and any attempt to use such a pin as an input with pull-down (e.g. by constructing MotionSensor(2)) will result in a PinFixedPull exception with an appropriate message. However, we don't support BOARD mode.
    – Dave Jones
    May 27 '16 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.