wiringPi version 2 has been released and now has its own website (http://wiringpi.com/) to look after it. Most of the documentation on the projects site has been copied over to it the new site, but there may still be 1 or 2 pages that are still missing. I’d encourage you to use the new site if possible where there will be a forum and wiki.
The following tables give the mapping of the Raspberry Pi GPIO Pins to the GPIO connector in relation to the pin numbers and the physical location on the connector. This is a representation of the GPIO connector as viewed looking at the board from above, with the USB power at the top and the GPIO to the top-right of the board.
If using the connector pin numbering, then note that Pin 1 on the connector is the 3.3v supply. Pin 2 is the 5V supply, and pin 26 is marked SPI CE1 below.
P1: The Main GPIO connector:
wiringPi Pin |
BCM GPIO |
Name | Header | Name | BCM GPIO |
wiringPi Pin |
---|---|---|---|---|---|---|
— | — | 3.3v | 1 | 2 | 5v | — | — |
8 | R1:0/R2:2 | SDA | 3 | 4 | 5v | — | — |
9 | R1:1/R2:3 | SCL | 5 | 6 | 0v | — | — |
7 | 4 | GPIO7 | 7 | 8 | TxD | 14 | 15 |
— | — | 0v | 9 | 10 | RxD | 15 | 16 |
0 | 17 | GPIO0 | 11 | 12 | GPIO1 | 18 | 1 |
2 | R1:21/R2:27 | GPIO2 | 13 | 14 | 0v | — | — |
3 | 22 | GPIO3 | 15 | 16 | GPIO4 | 23 | 4 |
— | — | 3.3v | 17 | 18 | GPIO5 | 24 | 5 |
12 | 10 | MOSI | 19 | 20 | 0v | — | — |
13 | 9 | MISO | 21 | 22 | GPIO6 | 25 | 6 |
14 | 11 | SCLK | 23 | 24 | CE0 | 8 | 10 |
— | — | 0v | 25 | 26 | CE1 | 7 | 11 |
wiringPi Pin |
BCM GPIO |
Name | Header | Name | BCM GPIO |
wiringPi Pin |
- Board Revisions: Please note the differences between board revisions 1 and 2 (R1 and R2 above)
P5: The auxilliary GPIO connector present on Rev. 2 boards only:
wiringPi Pin | BCM GPIO | Name | Header | Name | BCM GPIO | wiringPi Pin |
---|---|---|---|---|---|---|
— | — | 5v | 1 | 2 | 3.3v | — | — |
17 | 28 | GPIO8 | 3 | 4 | GPIO9 | 29 | 18 |
19 | 30 | GPIO10 | 5 | 6 | GPIO11 | 31 | 20 |
— | — | 0v | 7 | 8 | 0v | — | — |
wiringPi Pin |
BCM GPIO |
Name | Header | Name | BCM GPIO |
wiringPi Pin |
Note also that the P5 connector is designed to be used from the underside of the Pi – ie. you solder on the top of the Pi board to install the connector! If you are using it from the top, then you need to mirror the diagram above.
Each side has three columns. The outermost column, headed wiringPi Pin refers to the pin number in the wiring Pi code. The middle one, headed BCM GPIO refers to the pin number of the BCM2835 chip, an this is the pin number used when addressing the GPIO using the /sys/class/gpio interface. The innermost column, Name is the name of the function of the pin.
The central column contains the pin numbers on the header on the board. Pin 1 is the 3.3v power supply on the P1 connector (Rev. 1 and Rev. 2 boards), and Pin 1 is the 5v power supply on the P5 connector on Rev. 2 boards only.
Note: This page was edited (again!) on the 19th of June 2012 to fix the mistakes of the earlier edit. I have double-checked this against the schematic and by building a set of 15 LEDs and connecting it all up.
The photo shows a static shot of a Raspberry Pi driving all 17 GPIO pins with LEDs. The program actually cycles up from Pin 0 to Pin 16 so I can check the exact pin ordering…
It looks like you might have swapped the pins for wiringPi numbers 10 and 11? On my Pi, the corner pin marked SPI CE0 above response as pin 10 on wiringPi, and CE1 responds as pin 11.
you’re not the first person to tell me this )-:
And each time, I check and see what’s what…
I’m sure the last time I refered back to the circuit diagram, but I’ll check it again!
-Gordon
This is really helpful – I’m new to all of this but have been using the arduino to control midi functions as in the example they give when you download the software. What I’d like to know is can I do something similar using the serial connection on the raspberry pi? Does your wiringPi code have a Serial.begin command where I can change the baud rate for midi setting etc? Thanks
Hi,
Thanks for the feedback. I do have a serial library which is general-purpose for most Linux/Unix devices, but it’s not part of wiringPi – however since you’re the 2nd person to ask for it, then I’ll add it in for the next release in a few days time, so keep watching.
It will be a C type interface, so rather than Serial.begin(), you’ll call serialOpen (“/dev/ttyAMA0”, 9600); etc. functions avalable are serialDataAvail(), serialGetchar(), serialPutchar() and serialPuts();
I’ve used this myself with real serial ports as well as USB serial ports – seems to work well.
I’ve been doing a lot with the Pi’s serial port to talk to an ATmega chip recently, so I think these will be a worthwhile addition!
-Gordon
Hi,
I was wondering if this is available yet, and if so where, as it’s just what I’m looking for to drive the gpio uart in a C program for a project I’m concidering.
Thanks
Richard
Hi,
Wondering what you’re after? wiringPi and the serial code it has is avalable via the web/git and has been for some time – have a look at: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/
or: https://git.drogon.net/
-Gordon
Hi,
That’s the info I was after. I got here via google and didn’t see that the serial had been in the wiringPi download already. I’m off to download and use now.
Thanks
Richard
Use GIT to fetch the latest & greatest from https://git.drogon.net/
Any issues just let me know.
-Gordon
@Gordon, thanks for providing wiringPi
Yes, having serial in the wiringPi is a must 🙂
Also any thoughts on including SPI and I2C as well?
There are (works in progress) on the SPI and I2C drivers in the Linux kernel and I will be testing some of these when I get some time, so have decided to not even think about doing my own.
I’ll be posting my testings here though!
-Gordon
I counted twice! There are 17 LEDs lit up, but you wrote
“I have double-checked this against the schematic and by building a set of 15 LEDs and connecting it all up.”
Possibly a typo! I did make a 15-LED board early on, before I added in support for the serial ports being used as GPIO pins…
See:
http://unicorn.drogon.net/15leds.jpg
http://unicorn.drogon.net/pi17leds.jpg
Gordon
Hi,
Thanks Gordon for your lib, but I’ve got a problem.
With this :
int MOSI = 12;
int SCLK = 14;
pinMode(MOSI, OUTPUT);
pinMode(SCLK, OUTPUT);
Clock is 23 on PCB instead of 11, Why ?
Maybe it’s my fault…
Ok sorry, my fault…
I understand your draw 🙂
No problems – it’s been a source of confusion for many people, myself included in the past!
-Gordon
What is the voltage output of the pins?
Is it 3.3V or 5V?
its 3.3V.I found it in one of your pages.
how can i convert this to 5V?
There are many way’s but if you need to interface to 5V logic, then something like this:
http://www.skpang.co.uk/catalog/logic-level-converter-p-511.html
would be the thing to use.
-Gordon
The logic pins are at 3.3v, but there is a single 5V supply pin too.
-Gordon
Hi,
how can i send a data WORD like 0x33 on the GPIO 8?
I habe tried as code:
#####################
[…]
pinMode(8, OUTPUT);
digitalWrite(8,0);
digitalWrite(8,0);
digitalWrite(8,1);
digitalWrite(8,0);
digitalWrite(8,0);
digitalWrite(8,0);
digitalWrite(8,0);
digitalWrite(8,1); //For 0x33 ind Binary 00100001
[…]
########################
But it doesnt Work…
How can i send a binary word like this over the pin 8?
And how can i get a binary word like this over the same pin after sending a word?
i doent think that this work:
########################
[…]
pinMode(8, INPUT);
int word[8]
for(i=0;i<8;i++)
word[i]=digitalRead(8);
[…]
########################
The sending part should work… However, it’s going to send those 8 bits out very quickly indeed. At the speed of about 20MHz, so it’s going to take under 1 microsecond to output those 8 bits – so whatever you have looking out for them, really needs to be quick!
Similarly for the input – it will do that entire loop in under 1 microsecond.
So whatever you’re talking to needs to be aware of this.
What is your application? If it’s something like a shift-register then have a look at the shiftOut and shiftIn functions, or just put delays in-between your calls to digitalWrite.
-Gordon
Thanks i will try it with delay.
I will connect to a digital tempreture sensor (DS18S20).
And for this i must send a word like 0x33 for reset, read ect.
Right. that’s a 1-wire device and from what I recall they have very precise timing requirements – far more precise than I think can be achieved under user-code running on the Pi…
However, there is an experimental kernel driver for 1-wire devices and while I’ve not had a chance to try it out, I understand it does work well.
You might want to read this: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=6649
-Gordon
The kenel Patch in the link wont work now because its for the old kernel, i have to wait until the new patch comes out for this
OK. There driver is in the kernel I’m using as a module, but it won’t load. It does need more investigations!
-Gordon
How can i Setup Linux .config variables: W1_MASTER_GPIO W1 W1_SLAVE_THERM?
I really don’t know – yet. I’ve not investigated the 1-wire stuff at all myself.
-Gordon
Interesting that no one else mentioned that 0x33 does NOT = 00100001, shouldn’t it be 00110011 ????
Does wiring python support SDCard LED which is pin 16 on rpi.gpio?
I’m not directy connected with the Python wrappers, however the underlying wiringPi code certianly does – in both GPIO and Sys modes, but not in native “pin” mode.
This stops the system from using that LED:
sudo sh -c "echo none > /sys/class/leds/led0/trigger"
then:
gpio -g mode 16 output
gpio -g write 16 0
gpio -g write 16 1
etc. and you can then use GPIO Pin 16 in your own code…
You can even export the pin for use in Python, etc. without running yor code a root:
gpio export 16 out
then you don’t need to be root if your code is using the /sys/class/gpio interface.
Note that the LED output is inverted – write 0 to turn it on, 1 to turn it off.
-Gordon
Now I got the REV2 board and try to set the pin2, 8 and 9 (WiringPi pin name) to high and low logic. But cannot control all 3 pins. I can use same code with REV; no problem.
Also create code with Python, the result are same.
I am not sure both 3 pins in Rev2 are reserved for PCM_DOUT (2 or pin 13 of header), SDA0 (8 or pin 3 of header) and SCL0 (9 or pin 5 of header).
Please advise.
Edit line 2 of my comment :
But cannot control all 3 pins. I can use same code with REV1 no problem.
Hm. OK…
I’m assuming you have the latest version of wiringPi. Try:
gpio -v
and see if it reports the board revision. (as 2!)
Pins 2, 8 and 9 are the ones that have changed in the board revisions from 1 to 2 – I put the changes in the code based on information I have – from the RaspberryPi forums, etc. but please make sure you have the latest version though – go check the output of the gpio command and get back to me on it.
-Gordon
Hi Gordon, I very sure now install WiringPi latest version. I still cannot send 0 and 1 to all 3 pins; GPIO2, 3 and 27 of R-Pi’s pin (It’s mean pin 2, 8 and 9 of WiringPi). Another pin can work no problem.
Please advise.
I can’t think of anything that would stop you for writing to pin 2 – pin 8 and 9 are the I2C pins so if the I2C driver is loaded it might interfere with that. However are you sure you have the pin numbers right?
BCM_GPIO pin 2 is wiringPi pin 8 but only on a rev 2 board – this doesn’t exist on a rev 1 board
BCM_GPIO pin 3 is wiringPi pin 9, but again only on a rev 2 board.
BCM_GPIO pin 27 is wiringPi pin 2, but once again only on a rev 2 board.
So it looks like either you have a rev 1 Pi, or wiringPi is not correctly detecting a rev 2 board.
Can you run
gpio -v
and see what board revision it thinks you have, and then check the board. If it has mounting holes and says “Made in UK” then it’s a rev 2 board.
-Gordon
I know I just posted in the softwarepwm section that I couldn’t find this. I made this as a way of keeping track myself:
http://jasonscotthoffman.com/PiPins.html
Hope it helps others.
gen 2 baord full wiring schematic has been posted, the dnc pins are now defined pin # 6, 14, 20, 25, 9 are ground pin #17 is 3.3 volt hope this helps. this site is a great resource
Thanks. I’ll be updating them soon(ish)!
-Gordon
Is there a way to overide the board version. im using the same os from a gen 1 board then updated to the latest version of wiring pi. however gpio -v returns version 1.1, i know its a gen 2 board. any thoughts ?
The latest version of wiringPi has a gpio version of 1.4. That ought to auto-detect the board type. Can you check that the output of gpio -v looks like:
gpio version: 1.4
Copyright (c) 2012 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
This Raspberry Pi is a revision 1 board.
-Gordon
Hey Gordon.
Thx for a great guide 🙂
I just have one problem. The same as “chaiwat” had/has. I Cant use gpio 2 for driveing a normal LED. Do you have any proposals to what could be wrong?
If it’s wiringPi pin 2 (aka BCM_GPIO pin 21 on a Rev1 board or 27 on a rev 2 board), then you should’t have any issues driving an LED. GPIO Pin -> 330Ω resistor -> LED -> Gnd.
Make sure the LED lights by connecting it to the Pi’s +3.3v pin, then move the connector to the GPIO pin.
-Gordon
I think the problem is that I use gpio version 1.1.
I have a rev 2 board.
Your download link, links to version 1.1.
Is there a way to download the new version without using git???
The links on the download page should take you to the GIT repository now. I’ll check though, however this is what you do:
cd
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build uninstall
./build
gpio -v
-Gordon
The download link is still version 1.1.
The problem is that we are on a school with a closed network so we can’t use the git clone thing.
So if you could update the download link, so we can download 1.4 and install it the old way. that would be very nice.
Ah, that’s somewhat sub-optimal!
I’ve just done a clone of the current wiringPi and put it in the old downloads area – it’s wiringPi.tgz (which links to wiringPi-15.tgz)
So you ought to be able to get that.
However, you can make the web interface give you a .tgz directly too. go to: https://git.drogon.net/ then click on wiringPi, then look for the “snapshot” link and it will create and download a .tar.gz for you.
-Gordon
Now it works.
Thanks for your time and great guide 🙂
– Martin
Do you know what the power-on state is for the GPIO pins on the header?
Is it input, output or floating and what are the signal levels (0V or 3.3V?
Are the pull up or pull down resistors activated?
Do the pins remain in the same state during boot?
I’m fairly sure the pins are set to inputs, however I go know that Pi 7 (BCM_GPIO 4) is set to some funny state, possibly an output at boot time, then quickly set to input – I notice it when booting a Pi with my Ladder board connected.
Also, from the manual, the pull-up/down’s are preserved over a power cycle, but I don’t know if the GPU boot or the Linux boot code does anything to them at boot time.
If you load the I2C and/or the SPI modules then the pins on the corresponding posts will be forced into the relevant state required for that port to work.
I could write a program to check their states but …
-Gordon
Thank you for what you have. I easily learned how to use 8 LEDs (0-7) and tried to use another 8, but got a couple of times to stop the system from 8 “input” to “output” are 7 (gpio lie to 8,9,10, 12, (11 -?) 13,14,15, and 16) with – r all works in reverse, and I think with-g in this way I get to stop working pi. how to make a nice 8 to 15? without reboot. How to get a “GPIO write January 11.”
Thank you, sorry for my English.
#!/bin/bash
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do gpio mode $i out; done
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
do
gpio write $i 1 # LED>On
sleep .5 # time out
gpio write $i 0 # LED>Off
done
That should work fine – but do make sure you don’t have the I2C or SPI modules loaded.
If you want to use ‘January’ then you need to declare it as a variable – so:
January=1
gpio write $January 1
-Gordon
strange, but 11 runs but does not work 14. 🙁
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do gpio mode $ i out; done
for i in 8 9 10 11 12 13 15 16; do gpio write $ i 1; sleep .5; gpio write $ i 0; done
done
exit 0
Do check the modules loaded – the SPI one may be interfering
-Gordon
how to check SPI?
sorry
use the lsmod command and look for anything with ‘spi’ in it.
-Gordon
after reboot my script started to make perfect nonsense, maybe I’m in the beginning that in missed?
I removed from the list of “14” and left the “16” is not pretty but it works 🙂
I’m a big idiot! put cable on the contrary, surprisingly but partially worked something.
Glad you’re going now!
-Gordon
I made a cube 3-3-3. GPIO used from 1-9 to control the Anodes, and GPIO 11-12 and 13 through the transistor switches on the cathode. Now I can light any diode, but strange behavior GPIO 7! in the console by typing gpio write 7 1, I can not light it, while running program all ok. it’s sort of a mystery or a feature, or my finger trouble?
my bash:
#!/bin/bash
while :
do
for i in 1 1 2 2 3 3 4 5 6 7 8 9 10 11 12 13; do gpio mode $i out; done
for i in 1 2 3 4 5 6 7 8 9; do gpio write $i 1; sleep 0.3; done
for i in 1 2 3 4 5 6 7 8 9; do gpio write $i 0; done
done
Is it true in the state of gpio pin (gpio readall) wiringPi 2 is the GPIO-27, he did not GPIO-21?
wiringPi pin 2 is BCM_GPIO 21 in a Rev 1 Pi, or BCM_GPIO 27 on a Rev 2 Pi. If your Pi has holes in the motherboard, then it’s a Rev 2.
-Gordon
i have Rev 2.Pi.
https://docs.google.com/open?id=0B5K8tYnSK_tQS0dqX0J0dEswS1U
I can’t see anything immediately wrong. Do remember that GPIO pins start at zero though, and check that you don’t have the I2C and/or SPI modules loaded too – they might interfere with pins 8 and 9 (I2C) and 10,11,12,13 and 15 (SPI).
-Gordon
thx. i im idiot. term modules be loaded
No wories! Hope it’s all working OK now.
-Gordon
Yes! All is Ok! Thx!
http://www.youtube.com/watch?v=cKmouz9y_JI&feature=share
Hi! I made a printer friendly version of the pin assignment:
https://docs.google.com/document/pub?id=1Pqu1Mpf9-3X0sNpuXtJUmiDIdtF0i-6DtpoU6tYzHnE
Gordon: If you like I can give you editing rights on the google doc for future updates.
Good picture, but no wories about editing it. It used to be printable – until I started to get comments 😉
However I’m working on a nice graphic that’ll be good for printing, but for now, I’ll put that link at the bottom of mine if you don’t mind?
Thanks,
-Gordon
Thanks Gordon!
I thought I had a fault on my Pi board GPIO 21 but i now know its GPIO 27 as I have a Rev 2 board but all documentation I’ve seen must be referring to Rev 1 boards!
I’ll be wiring out those other four GPIO pins too before long, Cheers !!! 🙂
If you stick to using wiringPi pin numbers and not the native BCM_GPIO numbers then you’ll be OK too as those numbers are the same between the Rev 1 and the Rev 2.
-Gordon
Hi Gordon,
Thanks very much for all the work you’ve done on the pi. I’m trying to use your wiringPiSPI.h and .c files to get the raspberry pi rev 2 to talk to an A2D converter (MCP 3201). I noticed that the mcp3201 does not have a DIN. Can I still use the wiringpi libraries?
Also, can I quickly confirm that the pins that I need are:
2(5V),6(gnd),8(Rx),23(sclk), 24(ce0 for CS)? I’ve put an osciloscope on the pins mentioned and am not reading anything at the moment. Please assist?
Hi,
You should be ok. The MCP3201 is a very simple chip – so all you do is open the appropriate SPI device, then do a 16-bit transfer (2 bytes) and pick the 12-bits out of the return.
So:
uint8_t spiData [2] ;
wiringPiSPIDataRW (SPI_A2D, spiData, 2) ;
and then pick the bits out of the spiData[] array. Look at the gertboard.c file in wiringPi to see how to initialise the SPI hardware and copy gertboardAnalogRead() but obviously there is no commands to send to the chip.
You need the 3.3v pin from the Pi, (pin 1) not the 5v pin, as well as the others. You won’t get anything back until you initiate a transfer from the Pi side.
-Gordon
I ordered and received (I believe) a model B Rev 2, but I don’t see the auxiliary GPIO you mention above. Is there a way to use the serial number to verify the version of my board?
You need to solder it on.
If your board has 2 mounting holes, then it’s a Rev 2.
Just run gpio -v
-Gordon
Gordon,
Thanks for the library, works well both on the RaspberryPi and via my laptop using Eclipse and linaro cross-compiler tools.
Even though there is the OWFS for 1-Wire, which I’ve used in some of my projects I’ve been experimenting over the past trying to implement reading my DS18B20 temperature sensor directly. After about 2-3 days of painfully getting it to work, I finally managed to get it working. Initially had some garbage data coming back so implemented CRC checking/matching lastnight which helped. Then stumbled across an odd error where CRC was matching but the scratchpad was empty. Added some additional code when retrieving the scratchpad which waits for presence detection which fixed this error. I later found out the reason for this error was due to OWFS module being enabled and I’m gathering causing a 1-wire bus clash.
So some pointers to anybody else trying to implement 1-Wire on a RaspberryPi:
* when sending a ROM / Function code, perform a pulse and wait for presence
* if you have data issues, check it’s not a clash with the OWFS module
Gordon, on another note I tried following your pin guide / diagram as I have my 1-Wire device physically on P1-07 which according to this reference is GPIO4:
http://elinux.org/RPi_Low-level_peripherals
However in code I have to use 7 in pinMode(), digitalRead() and digitalWrite(). Unless I’m mistaken, nothing seems to tally up between RPi Low-level and your pin mapping guide. FYI, I’m using a Rev2 board. Initially I was passing 4 to the WiringPi functions, but had to get out a voltage meter to verify output. It was at this point I discovered I was controlling the wrong pin.
Regards
Darryl
P1:07 – That pin is BCM_GPIO 4, or wiringPi pin 7.
It’s the same pin in Rev 1 or Rev 2 boards.
How are you initialising wiringPi? If you use wiringPiSetup () then you need to us pin 7 in your code, if you use wiringPiSetupGpio() then you need to use pin 4 in your code.
See the table here: https://projects.drogon.net/raspberry-pi/wiringpi/pins/
When I initially wrote wiringPi, I decided to use the inital names for the GPIO pins – which were numbered 0 to 7 rather than 17, 18, 21, etc. so I stuck with this way – which also reflects what happens in Arduino land too (you refer to pin 13 rather than port B, pin 5 for exmaple), however the die-hards wanted to use the “real” GPIO pins numbers which is why there are 2 wiringPiSetup functions. Do note that if you use wiringPiSetupGpio() then you’ll need to change your code if you use BCM_GPIO_21 (wiringPi pin 2) as that changed to 27 on a Rev 2 board. You don’t need to change if you use wiringPi pin numbers – it’s always pin 2 no matter what the board revision is…
I’m impressed you got 1-Wire going with wiringPi! I did look at it a while back, but Frank Buss pointed me to the kernel driver, so I never bothered doing any more with it – just assumed the kernel driver was fine and left it at that.
-Gordon
Hi Darril..
can you please tell me how to include the wiring PI library into eclipse, and also how to include the cross compiler into it.
Regards
Wael.
Hi,
Sadly I don’t know the answer to that. I compile natively on the Pi, never cross compile. I also use an editor (vi) and Makefiles for my projects rather than any other IDE.
-Gordon
Gordon, just re-read it and my bad I understand it now. The BCM column is the one that matches up with the RPi Low-Level Peripherals page, I was matching it against the Name column. I’ve only just also noticed the Header section of the table 🙂
Not sure what limitations, if any the kernel driver has. All I’ve done with OWFS is just written Bash and PHP scripts to open/read the slave device and cut out the temperature.
I was under the impression that the kernel driver was “where it’s at” – but I’ve not really looked…. I have a bunch of 1W temperature sensors that I might play with soon though…
-Gordon
Gordon, when coding for ATMEGA chips under AVRStudio I could set the pin to input and pull up/down or float. What is the best way to achieve this, at the moment I’m setting the pin to INPUT via pinMode and then issueing a digitalWrite with LOW/HIGH. I’m thinking I should be using the pullUpDnControl function though, would this be better?
Regards
Darryl
Using the pullUpDnControl() is the only way. the Pi doesn’t respond like the ATmega does, it’s a separate function in the hardware. (also the Pi can pull-down which the ATmega can’t)
-Gordon
ahh it’s been a while since I’ve played around with the ATMEGA and forgot that it only has pull-up resistors.
Whats the best way to float a pin. At the moment I’m just switching the pin to input mode, but wondering if I should switch to input and use pullUpDnControl() with PUD_OFF.
The pull up/downs are remembered over a power cycle, so unless something else interferres with them, you should be able to set them once (e.g. by using the GPIO program) then forget…
But yes, you should set it to PUD_OFF (or gpio mode pin tri) and input mode.
You can check with a multimeter too – setting the pull up or down will register on a multimeter connected to a pin when set to input mode.
-Gordon
Not sure if you saw the raspberry leaf (http://www.doctormonk.com/2013/02/raspberry-pi-and-breadboard-raspberry.html) a piece of paper to show you which pins are numbered what.
I’ve created a version which has WiringPi/Quick2Wire pin numbers – download from here:
https://dl.dropbox.com/u/17766973/raspberry%2Bleaf%2BWiriingPi%2BR1.pdf
I still visit this page lots though when I need to change GPIO to WiringPi etc. etc.
Yes, I’ve seen then – good idea – wish I’d thought of it!
-Gordon
It should be better if we have both GPIO and wiringPi number in one leaf.
I saw someone used ATA cable used inside desktop PC case to connect HDD and mainboard. Anyone tried? It will be great for test and clearer look than use separated wire for each.
@Gordon: Thank you very much for a very useful library which give newbie a quick and easy way to begin with GPIO like me!
I have made a new GPIO leaf which include both GPIO Name, PIN and wiringPi PIN. Here are they, you guys can use it to print directly using Adobe Reader with printer setting to Actual Size.
– Single printable:
+ Colored: https://dl.dropbox.com/u/308724/Raspberry%20Leaf%20R2%20-%20wiringPi.pdf
+ Black & White: https://dl.dropbox.com/u/308724/Raspberry%20Leaf%20R2%20-%20wiringPi%20-%20BW.pdf
– Multiple 20 leafs fit to A4 paper:
+ Colored: https://dl.dropbox.com/u/308724/Raspberry%20Leaf%20R2%20-%20wiringPi%20-%20Multiple.pdf
+ Black & White: https://dl.dropbox.com/u/308724/Raspberry%20Leaf%20R2%20-%20wiringPi%20-%20Multiple%20-%20BW.pdf
I’m seeing +1 volt difference for both the 3.3v and 5v pin. (3.3v reads > 4, and 5v reads > 6v). I was going to tack a 3.3v regulator onto the 3.3v pin, to get a steady 3.3vs, but wanted to see if this was expected behavior before doing so. I thought it would have already been a regulated 3v/5v output, but I guess I was wrong.
If look at the GPIO connector then you should see about 3.3v and about 5v. The 5v will be slightly less (usually) due to a little drop over the polyfuse, however there is a 3.3v regulator on the Pi itself – as most of the Pi runs at 3.3v. There is no 5v regulator – the Pi expects a regulated 5v supply.
I’d check your voltmeter.
-Gordon
Hi Gordon,
First of all thanks for your website and all you have posted… Learned alot about my Rasp pi. I have a question though, and I cant seem to find an answer. What is the minimum voltage level for the GPIO to detect a ‘HI’ signal. Im trying to connect my Rasp pi to the Omni-Vision camera cube and the thing is very finicky on voltage levels for the output of the cube and would rather not build amplifies for the bit level outputs…. any ideas would be most helpful …:)
Thanks in Advance and keep up the good work
Marc
I think it’s 1.1 volts, but I’d have to go & check.
-Gordon
That would be ideal. Thanks for checking.
Please fix your pin table
http://elinux.org/File:GPIOs.png
4 pin – not DNC
17 pin – not DNC
Thanks, i’m make fatality for connected device
There is nothing wrong with my pins table.
the DNC pins were do-not-connect in the Rev 1 Pi’s because there may have been changes – it turns out there weren’t, but they’re still OK to NOT connect to – you don’t HAVE to connect to them. You can not make a “fatal” connection by NOT connecting to them.
They’re updated in my new site which I’m launching soon though: http://wiringpi.com/pins/
-Gordon
hi gordon,
thanks for your work on wiringPi! Its really helpfull getting my projects working on the pi!
May you put a little notice in your article above? I noticed that P5 (aux GPIO on rev2 boards) is mirrored. So pin 1 is on the right side (near P1), not on the left side. The normal GPIO header (P1) has pin 1 on the left side.
Pin 1 is marked by a square solder pad.
If you dont have this in mind, 3.3V and 5V may be interchanged and 5V connected to the GPIO pins instead of 3.3V – and thus damage the pi.
Th P5 connector is designed to be used from underneath the board – I’ve added a note to the pages to reflect this.
-Gordon
Hi gordon,
is there a way to use wiring lib with a IO Extender like a MCP23017 ?
wiringPi v2 supports them directly. see http://wiringpi.com/ for the details. Get a beta by
wget -O- http://unicorn.drogon.net/wiringPi-2.6.tgz | tar xfz - ; cd wiringPi ; ./build
-Gordon
Ok, great, I’ll check asap.
If I wan to use pin A4 of my MCP23017, what I’d touse which :
gpio write ? 0
The pin number is whatever you choose for the base of the chip (+ 4). So if you installed it with a pinBase of 120, then you’d be writing to 124.
ie. gpio -x mcp23017:120:0x20 write 124 1
-Gordon
hey, I need explaination
…and help 🙂
# gpio -x mcp23017:120:0+20 readall
gpio: i2c address (0x0) out of range
0x20 not 0+20
(and readall isn’t working yet with extension modules – sorry)
-Gordon
Hi i’m simply trying to test if my Led’s are working and I’ve connected everything exactly the same way as your example for the tux crossing for 1 LED but the LED won’t light up. I know the LED works cause someone checked it for me yesterday I just don’t know how they tested it.
Test the LEDs with the Pi’s 3.3v supply before moving them over to the GPIO pins. That way you’ll know they’re plugged in the right way round.
-Gordon
does any one know if the gpio would take 2 add on boards at once. i think they use different pins but not sure which way id go on connecting them both to the 23 pin header.