Raspberry Pi GPIO problems

Got a hardware problem? ask for help

Raspberry Pi GPIO problems

Postby kieranc » February 6th, 2013, 4:42 pm

Hi there,
I'm trying to set up my raspberry pi to log input from an LDR. I've found some information which seem to cover exactly what I need, but I can't make it work.
Here's a link: http://pyevolve.sourceforge.net/wordpress/?p=2383

I've built the circuit and it works fine - if I connect an LED to the output it responds to a changing light level on the LDR. The problem comes when I connect that output to the Pi, the level of the GPIO pin seems to change at random, unrelated to the output from the circuit.
I've tried both python RPi.GPIO and the wiringPi gpio utility, both provide the same result. It seems like the input is floating but I've tried both internal and external pullup & pulldown resistors, neither improved the situation.

I feel like I'm missing something obvious but I'm clearly beyond the limits of my knowledge so I'm hoping someone else will have some useful insight! No idea too daft, I'll try anything :)
Posts: 1
Joined: December 19th, 2012, 2:56 pm

Re: Raspberry Pi GPIO problems

Postby st2000 » February 7th, 2013, 8:51 am

I have not done any HW hacking w/my RPi yet. But have done some w/PICs. Drawing on that and some Google'ing it sounds like you are still having problems configuring your GPIO control registers. Look at some of the examples on this page: http://code.google.com/p/raspberry-gpio-python/ and see how it compares with what you are doing. Also, I usually call what you are using a CdS for cadmium sulphide. LDR is a good description. It just caught me (and maybe others) off guard. BTW, most (all?) CdS light detectors have a really bizarre valance bands (many many electron energy states) (I think that's what you would call it). Such that it takes a (human) noticeable amount of time to turn off (as the electrons fall back to a non conductive energy state). Making it unusable for any type of fast acting detection such as data communication. So you may see a delay of a second or two after removing light from the detector.

If I were doing this, I am not sure I would bother with the transistor. Simply tapping into a point between a properly selected pull up resistor and the LDR connected to ground would probably provide all the voltage fluctuation you need to detect light at a GPIO pin programmed to be an input w/o any programmable pull up or pull down resistors. You need the transistor to drive a high current device such as a relay. But I can't imagine a programmed GPIO input w/o pull ups/downs to be much of a load.

-good luck

Edit: added later...

BTW, on the page you referenced, the "LDR" (aka CdS) light detector symbol should not a diode. And I am fairly sure it makes no difference which way current flows through it.
Posts: 1454
Joined: February 3rd, 2011, 6:10 pm

Return to Help me! Hardware

Who is online

Users browsing this forum: No registered users and 2 guests