I wasn't sure exactly where to ask this.
I have looked around but I can't find what I am looking for.
Can anybody tell me what the lower current limit would be for the pi to sense an input from a gpio pin?
I want to use an LDR to sense a light source being covered but I need to know what the limits are of the inputs before I can build it.
Also am I correct with the 3v3 pin being able to output up to 50mA, and a simple pin being able to input up to 15mA?
-
- Posts: 2327
- Joined: Fri Feb 24, 2012 6:19 pm
- Location: Euxton, Lancashire, UK
- Contact: Website
Re: GPIO current limits
I'm using an ORP12 LDR and it detects it light/dark fine (with the GPIO software controlled pull-up resistor enabled) 
You really need to approach the GPIO pins as delicate little baby fingers - they really need coupling up to a buffer if you are going to so anything more than ideas testing - a ULN2003 buffer costs 0.37p
Yep - those are the limits but you don't want to be getting anywhere close to them as as you'll have a long wait to get another RPi
Simon

You really need to approach the GPIO pins as delicate little baby fingers - they really need coupling up to a buffer if you are going to so anything more than ideas testing - a ULN2003 buffer costs 0.37p

Yep - those are the limits but you don't want to be getting anywhere close to them as as you'll have a long wait to get another RPi

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
http://cymplecy.wordpress.com/ @cymplecy on twitter
Re: GPIO current limits
Thanks for the reply but I'm afraid you are talking a little bit above my knowledge.simplesi wrote:I'm using an ORP12 LDR and it detects it light/dark fine (with the GPIO software controlled pull-up resistor enabled)
You really need to approach the GPIO pins as delicate little baby fingers - they really need coupling up to a buffer if you are going to so anything more than ideas testing - a ULN2003 buffer costs 0.37p
Yep - those are the limits but you don't want to be getting anywhere close to them as as you'll have a long wait to get another RPi
Simon
Could you please just define a few terms for me?
-Pull up resistor (and how do you control that with the gpio)
-buffer
Also where do you get components from? At the moment I could only think of Maplin
-
- Posts: 2327
- Joined: Fri Feb 24, 2012 6:19 pm
- Location: Euxton, Lancashire, UK
- Contact: Website
Re: GPIO current limits
A pullup resistor just "pulls" the input up to 3.3V when its not connected to anything else. So you start off from a known state in that it is at 3.3V.Pull up resistor
To change this, you connect a low resistance (330 ohm is a good value as it limits the max current to about 10ma) to the pin and other end to 0V (Pin 6 on the RPi).
This lower value resistor causes the voltage on the pin to go down to near 0V and your software can detect this.
Its generally held to be a good way to be nice to electronic components even though its usually the opposite way that a beginner would try to do things.
Your software usually has a setting to do this and in python ends up as(and how do you control that with the gpio)
Code: Select all
import RPi.GPIO as GPIO
# to use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)
# set up GPIO input with pull-up control
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# input from RPi board pin 11
input_value = GPIO.input(11)
Best way to get bits is online - cpc.co.uk are a cheap place but there are many othersbuffer[/buffer]
A buffer protects the RPi from mistakes on the equipment side - search around here for info on ULN2003A for better people than me to tell you about it search for user joan
Also where do you get components from? At the moment I could only think of Maplin
Here is a link to a homebrew buffer board http://www.thebox.myzen.co.uk/Raspberry ... Board.html
Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
http://cymplecy.wordpress.com/ @cymplecy on twitter
- Burngate
- Posts: 6403
- Joined: Thu Sep 29, 2011 4:34 pm
- Location: Berkshire UK Tralfamadore
- Contact: Website
Re: GPIO current limits
If you've got a Maplin shop near you the guys there are usually very helpful. Also their catalogue (although it costs) can be a fund of knowledge.Janion wrote:... I could only think of Maplin
As Simon says, CPC (part of Farnell, MCM in the US) are good. And RS is another place.
Otherwise, for more out-of-the-ordinary parts, there are lots of places on line
Re: GPIO current limits
So wait... To get my GPIO pin at LOW to be 0V I need to bridge it to GND with a 330ohm resist?
I've just tested a relay and it turned on with 152mV on the GPIO pin which is it's LOW state, so I'm missing a resistor?
I've just tested a relay and it turned on with 152mV on the GPIO pin which is it's LOW state, so I'm missing a resistor?
-
- Posts: 2327
- Joined: Fri Feb 24, 2012 6:19 pm
- Location: Euxton, Lancashire, UK
- Contact: Website
Re: GPIO current limits
I am talking using a pin as an inputSo wait... To get my GPIO pin at LOW to be 0V I need to bridge it to GND with a 330ohm resist?

To prevent any disasters happenig, ITS ALWAYS a good idea to connect to the pins through a resistor that limits the amount if current that COULD flow 3.3/330 = 10mA which is safe if just using one pin
If using your RPi to turn the relay on, then you need a resistor to limit the amount of current that could flow through the coil of the relay.I've just tested a relay and it turned on with 152mV on the GPIO pin which is it's LOW state, so I'm missing a resistor?
If your controlling the relay by something else and your connecting the switch contacts to your RPi then you need a resistor as explained above.
If in ANY doubt - stick a 330ohm resistor in - it might not need it but you'll never blow your RPi up

Simon
PS Not the world's greatest electronics engineer BTW but very experienced in blowing things up by not taking precautions and don't want to see anyone else crying

Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
http://cymplecy.wordpress.com/ @cymplecy on twitter
- gordon@drogon.net
- Posts: 2023
- Joined: Tue Feb 07, 2012 2:14 pm
- Location: Devon, UK
- Contact: Website Twitter
Re: GPIO current limits
Hang on - you're connecting a relay directly to a GPIO pin? I'm guessing the other end of the relay is connected to +3.3v, so driving the GPIO pin low turns the relay on...TarjeiB wrote:So wait... To get my GPIO pin at LOW to be 0V I need to bridge it to GND with a 330ohm resist?
I've just tested a relay and it turned on with 152mV on the GPIO pin which is it's LOW state, so I'm missing a resistor?
Have you checked the current going through the relay coil? I'd be VERY surprised it if were in the 16mA limit for the Pi's GPIO pins.
So unless it's a really really small, lightweight relay designed to be driven from 3.3v and take under 16mA then you shouldn't be directly connecting it to the Pi at all...
All this talk of randomly putting in resistors, really suggests that you don't actually know what's going on, and while I encourage experimentation, I'd really suggest you go out and get some basic electronics knowledge...
-Gordon
--
Gordons projects: https://projects.drogon.net/
Gordons projects: https://projects.drogon.net/
Re: GPIO current limits
Admittedly I do not have a clue, that's what I'm trying to get. I am, however, not playing randomly with the wiresgordon@drogon.net wrote: So unless it's a really really small, lightweight relay designed to be driven from 3.3v and take under 16mA then you shouldn't be directly connecting it to the Pi at all...
-Gordon

The relay coil is driven by the 5V pin to the collector of the transistor - the GPIO pin is connected to 1kohm then the base of the transistor. The Emitter is connected to the ground pin. I was quite confident this was how it was supposed to be.
Problem is, no matter the state of the GPIO pin, the transistor always seem saturated. Only if I set the pin direction to IN will it desaturate and relay will turn off.
Re: GPIO current limits
What transistor are you using?
Sounds to me like you have a PNP transistor in there (or other fault in your circuit)
You need an NPN transistor, for that type of switching I tend to use digital FETs like FDV303N which is capabling of handling 2A continuous current (Idd), and can be driven directly on the gate with a GPIO pin.
What are you switching with the relay?
Small signal switching or mains electricity?
The only relays I regularly use for 3V3 or 5V coil voltage (and buil-in diode) cannot handled large load voltages and currents Pickering relay series 101, coil current less than 8mA.
Sounds to me like you have a PNP transistor in there (or other fault in your circuit)
You need an NPN transistor, for that type of switching I tend to use digital FETs like FDV303N which is capabling of handling 2A continuous current (Idd), and can be driven directly on the gate with a GPIO pin.
What are you switching with the relay?
Small signal switching or mains electricity?
The only relays I regularly use for 3V3 or 5V coil voltage (and buil-in diode) cannot handled large load voltages and currents Pickering relay series 101, coil current less than 8mA.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
or http://www.pcserviceselectronics.co.uk/pi/
Re: GPIO current limits
I have no idea - the writing is not visible and the manufacturer of the relay doesn't specify. However, it's a ready-made one and I can't find any solder flaws or other connection problems to my limited knowledge, on the board. It's this board.techpaul wrote:What transistor are you using?
I am also half-assuming it works correctly since disconnecting the GPIO pin turns the relay off, and also changing the direction to "in". But as long as it's "out" it will turn the relay on without fail.
I'm currently switching nothing, just hearing the "click" and observing the LEDs. I will be switching 12v 1-2A if I can make it work...techpaul wrote: Sounds to me like you have a PNP transistor in there (or other fault in your circuit)
You need an NPN transistor, for that type of switching I tend to use digital FETs like FDV303N which is capabling of handling 2A continuous current (Idd), and can be driven directly on the gate with a GPIO pin.
What are you switching with the relay?
Small signal switching or mains electricity?
The only relays I regularly use for 3V3 or 5V coil voltage (and buil-in diode) cannot handled large load voltages and currents Pickering relay series 101, coil current less than 8mA.
*EDIT* somehow this got spread out on two threads - I meant to discuss it here: http://www.raspberrypi.org/phpBB3/viewt ... 00#p166700
since that's talking about the similar board

- gordon@drogon.net
- Posts: 2023
- Joined: Tue Feb 07, 2012 2:14 pm
- Location: Devon, UK
- Contact: Website Twitter
Re: GPIO current limits
OK. The way it's wired is to be active low. So set the GPIO to output and write 0 to turn the relay on, and write 1 to turn it off..TarjeiB wrote:I have no idea - the writing is not visible and the manufacturer of the relay doesn't specify. However, it's a ready-made one and I can't find any solder flaws or other connection problems to my limited knowledge, on the board. It's this board.techpaul wrote:What transistor are you using?
I am also half-assuming it works correctly since disconnecting the GPIO pin turns the relay off, and also changing the direction to "in". But as long as it's "out" it will turn the relay on without fail.
I'm currently switching nothing, just hearing the "click" and observing the LEDs. I will be switching 12v 1-2A if I can make it work...techpaul wrote: Sounds to me like you have a PNP transistor in there (or other fault in your circuit)
You need an NPN transistor, for that type of switching I tend to use digital FETs like FDV303N which is capabling of handling 2A continuous current (Idd), and can be driven directly on the gate with a GPIO pin.
What are you switching with the relay?
Small signal switching or mains electricity?
The only relays I regularly use for 3V3 or 5V coil voltage (and buil-in diode) cannot handled large load voltages and currents Pickering relay series 101, coil current less than 8mA.
*EDIT* somehow this got spread out on two threads - I meant to discuss it here: http://www.raspberrypi.org/phpBB3/viewt ... 00#p166700
since that's talking about the similar board
HOWEVER.... It's being fed from a 5v supply and that 5V will sink into a GPIO pin at 3.3v and likely destroy it (in time - you might be "getting away" with it for now).
You really need to undo that jumper and connect the input side to +3.3v and the drive side to +5v.
And is the module you have the same as those photos on ebay? I'm guessing there are compnents on the underside as there are not enough on the top side to match the circuit diagram given...
-Gordon
--
Gordons projects: https://projects.drogon.net/
Gordons projects: https://projects.drogon.net/
Re: GPIO current limits
Thanks for the input - putting the reply here:gordon@drogon.net wrote: OK. The way it's wired is to be active low. So set the GPIO to output and write 0 to turn the relay on, and write 1 to turn it off..
HOWEVER.... It's being fed from a 5v supply and that 5V will sink into a GPIO pin at 3.3v and likely destroy it (in time - you might be "getting away" with it for now).
You really need to undo that jumper and connect the input side to +3.3v and the drive side to +5v.
And is the module you have the same as those photos on ebay? I'm guessing there are compnents on the underside as there are not enough on the top side to match the circuit diagram given...
-Gordon
http://www.raspberrypi.org/phpBB3/viewt ... 00#p166700