0

When I connect the OUT lead from my motion sensor to GPIO2 or GPIO3, it always reads as HIGH, but when I connect it to any other GPIO pin, it correctly identifies when motion is detected. Since it works on other GPIO pins, I know my code and motion sensor are both working, I'm curious to know if there is any special properties of GPIO2 and GPIO3 that don't allow this, or if I'm doing something wrong.

Raspberry Pi 2

Edit: one more potentially critical piece of information: before I got jumper wires, I was wrapping bare wires around the GPIO pins and know for sure at least once I connected two GPIOs together, there was a little spark so I know it connected (possibly GPIO2 and GPIO3?). Could this have broken these? If so, is there any way to fix this besides buying a new pi board?

4
  • 1
    Try to avoid "I know my code is working because..." as an excuse not to include the code. It may seem like a reasonable inference, but, in this (as often is the) case it is sort of true in an obvious way but false in a perhaps less-obvious-to-you but clearly more literal way. – goldilocks Dec 4 '15 at 18:51
  • Absolutely. I'm actually at work now, but will post my code when I get back home. I'm curious to see what I can do to my code/wiring to get GPIO2 and GPIO3 to work. Also, going forward, whenever I post on this RPi Stack Exchange, I'll try to post my code no matter how confident I think I am. – sooprise Dec 4 '15 at 19:37
  • Part of my point was that if you had posted code, someone could have told you what to add to it -- as is we don't even know what language you are using. I believe you need to change the ALT function on the pins, which should be pretty simple using one of the pi-specific GPIO libs; it also can't be done via sysfs. But I haven't actually done this. – goldilocks Dec 4 '15 at 20:02
  • If we saw your code we could also be more confident that you are using GPIO 2/3 (pins 3/5 on recent Pis). wiringPi has a pintest utilty, my pigpio has a gpio test script. Both will do a GPIO confidence test. – joan Dec 4 '15 at 21:41
3

Those two pins are the I2C interface on the B+ and 2 Models, by default they will have real, physical 1.8 KΩ pull-ups {R1 & R2} to 3.3 Volts, which might be confusing things depending on the nature of the output from your motion sensor - what is it by the way?

Edit: updated once I determined what form the pull-ups took.

7
  • I did notice the I^2C designation for these pins but couldn't find any information about these. Can you clarify what you mean by pull-ups and whether I should even bother trying with these pins or just ignore them in the future? I just got a PIR off of Amazon, here's the link: amazon.com/gp/product/… – sooprise Dec 4 '15 at 18:18
  • "Pull-ups" means they are attached to a + which drives them high, unless a ground is attached to short the pull-up (which is why they have resistors). You can configure this, but unless there is a real need you might as well avoid them, the SPI, and the UART pins for use as GPIOs. – goldilocks Dec 4 '15 at 18:44
  • Just from my newbie perspective, should I just steer clear of I^2C and SPI/UART pins, or are the SPI/UART pins require no extra configuration like the regular GPIO pins? – sooprise Dec 4 '15 at 19:44
  • That is a decent separate question ("Do I need to do anything special to use the UART pins as GPIOs?"). I'm actually not sure about SPI either, so you could go with "UART or SPI". I'm gonna guess the answer is no for the former and yes for the latter but that is just off the top of my head. – goldilocks Dec 4 '15 at 20:04
  • @goldilocks Actually for these two pins you cannot "configure this" for pull-ups - they are real resistors on the PWB (R1 and R2) so telling the Pi to pull them down with (much higher) resistors inside the IC is not going to have any effect! – SlySven Dec 7 '15 at 11:44

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.