GPIO Ignorance

7 posts
by elcentro3m » Thu Jan 03, 2013 4:41 pm
I'm curious about setting up a temperature sensor.

I think a datalogger will get me where I want to be quicker, but, the experience of setting one up for a PI will teach me about breadboards, temperature sensors, the GPIO, and programming.

That's what I'm looking for from setting one up.

I've looked on YouTube, seen the Beginners tutorials. Looked at the manuals I can get my hands on, including the most recent one.

To put my knowledge (ignorance) in perspective, this is an example of my level of understanding that works for me:


I simply picked this because I knew the Arduino and the PI can be used for parallel purposes - temperature sensors, led lights, etc. And I wanted to see if I could simply find something that would explain the process in terms I could wrap my mind around. For the record, I'm 50+ years old. I do tech support for a living. I've setup an OS on the PI as well as XBMC, as well as a headless server. That's largely the software side of the equation. The GPIO is the hardware side. I've done programming before, so, I'm looking forward to working with Python, but, frankly, show me a fully connected breadboard or an electronic schematic and I'm just LOST.

So many of the tutorials seem to be of the here's what it looks like, here's how it works variety. It reminds me of a cartoon in which a scientist is standing before a blackboard smothered in formulas in the midst of which is the phrase "and then a miracle happens" to which a second scientist remarks, "I think this part [referring to the "miracle happens"] needs more work".

That's my level of comprehension. And I'm not finding anything that breaks it down for me any better than that. I'd like to see FAR more detailed explanation of the connecting of the temperature sensor to the breadboard, and the breadboard to the GPIO. "It's simple really." won't work (for me). If ANYTHING I've seen to this point were THAT simple, I wouldn't be asking.

It's a bit embarrassing (and awesome at the same time) that this very young girl is so capable and competent in regards to her understanding and explanation of the Arduino. Currently I have a Raspberry PI (two actually - 256k / 512k). I'm considering dabbling with the Arduino based on her tutorial.

I'd like to find something comparable regarding the GPIO, breadboards, and the Raspberry PI.

P.S. What exactly are the differences between the Arduino and the Raspberry Pi? Aside from the ports (HDMI, LAN, etc)?

Posts: 4
Joined: Tue Sep 25, 2012 9:44 am
by piglet » Thu Jan 03, 2013 5:02 pm
I can only touch on the P.S.

The Arduino is a micro-controller (no operating system), the Pi is a computer (normally running linux).

The Arduino will do stuff in real time in response to signals on its pins, and will be very fast and responsive; running low level code. The Pi (running linux) will do stuff when the operating system gets round to allocating time to the process you have looking at pins. You can code it with high level languages like Python.

Of course there are some very clever chaps running code directly on the Pi "bare metal" which means that they can make it run more like a micro-controller.
User avatar
Posts: 533
Joined: Sat Aug 27, 2011 1:16 pm
by tedhale » Thu Jan 03, 2013 6:43 pm
The simplest way to read temperature is with a One Wire Digital Temperature Sensor such as the DS18B20.

Here is a good tutorial on how to use it.
- Ted B. Hale
User avatar
Posts: 105
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
by abishur » Thu Jan 03, 2013 7:07 pm
Welcome to the forums! If I could make a request, please don't add so many carriage returns to your posts, it can result in some very awkward formats on smaller screens (i.e. mobile devices). If you let the forum automatically wrap the text then it will auto size it to the individual's screen ;-)

I've seen this discussed in other places on the forum if you use the search box for "temperature sensor" it might be able to point you in the right direction (I've also moved this to the appropriate sub-forum) :-)
Dear forum: Play nice ;-)
User avatar
Posts: 4225
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by bgirardot » Thu Jan 03, 2013 10:04 pm
I am almost exactly in your spot as well. I posted this on another thread a few days ago, but it applies here to the very basics of GPIO, please forgive the copy/pasta:
bgirardot wrote:
If you are using python on the raspbian os, a recent download of it, you do not need to download anything.

You can google for stuff like "raspberry pi python gpio tutorial" or introduction. Just remember this about any tutorials you find: You do NOT need to install RPi.GPIO, it is already installed on recent versions of Raspbian Wheezy, so you can just skip those parts of any tutorials, that part is already done. You will have the latest version, 0.4.1a-1 installed by default.

I know there are things on YouTube for beginners with GPIO.

The best, most gentle introduction to working with the GPIO pins I have found is the one Gordon has on his site, and I would do that first.

First you have to download and install Gordon's software, just follow the simple instructions here, it is literally 4 easy commands and they just work:

Then start with his simple, "let us turn on a led with no typing at all" first step:

You do not have to finish his whole tutorial, it would be good if you did, but get the first 1 or 2 leds working at a minimum before moving on to Python tutorials.

Also, and this is important: I suggest you use what is called the GPIO or BCM numbering for the pins, not the wiringPi numbering to refer to the pins (this will make more sense after you read Gordon's 1 led example page). Gordon recommends using the wiringPi numbering, but the majority of tutorials I see for Python use the GPIO numbers. (EDIT: Actually probably all python tutorials use the bcm numbers because they are not using Gordon's software, which is what creates the wiringPi numbers :)

It is a little confusing, but just know you need to pay attention to that and make it a priority to understand the pins are numbered 2 or 3 different ways, and understand what the GPIO/BCM numbers for them are.

The temperature sensor is a bit more complicated because the readings that come out of a 3 pin temp sensor are "analog" it is just a good old fashion voltage between 0-5v which the Raspberry Pi does not really understand very well. It sort of understands either 0 or 3.3V, but not the gradient between 0-5v or 0-3.3v.

To convert between analog and digital, you need an analog-to-digital converter, often called an ADC. The arduino has this built in, the Raspberry Pi does not. So you can hook up 3 wire temp sensor directly to the arduino and it will know what to do with 0-5v, converting it automatically to a number between 0-1024 ( I think, maybe between 0-255 ). You can get ADC chips and then connect those to the RPi, but obviously a bit more complicated.

There is a way to create a sort of ADC on a simple bread board with a capacitor, but I can not find the link to that now. It is actually a pretty good little exercise in bread boarding and would also be a good lesson. Found it: ... -gpio-pin/

So, I guess I mean to say, start simple with a few LEDs and Gordon's tutorial. Then move on to the temp sensor. The arduino might be easier since it has a build in ADC and the RPi needs an external one.

I think you can just use the arduino as an external ADC for the RPi as well, so if you get an arduino that will also help you learning the GPIO on the RPi as well.

Hope some of that made sense, it is late at night here :)
Posts: 517
Joined: Wed Oct 10, 2012 6:20 am
Location: Switzerland
by elcentro3m » Fri Jan 04, 2013 4:32 am
Thank you all for your replies.

I will look at all of your suggestions.

This is helpful.


Thank you.
Posts: 4
Joined: Tue Sep 25, 2012 9:44 am
by elcentro3m » Fri Jan 04, 2013 4:56 pm
Just did a lookup on the DS18B20 temperature sensor and the raspberry pi and found this. He's using, as best I can tell, the most recent wheezy image. This does a much more comprehensible job of explaining the "miracle that happens when the electrical components are connected to the breadboard and from there to the PI. I wasn't listening to the audio when I watched it so I don't know which breadboard he's using, if it matters at all, and it would've been a little better if the pins connected to the breadboard (the colored wires matched the colors coming off of the PI instead of being ALL red). Even so, he did put some effort into covering the part prior to turning it on and running the program on the PI).
Thought it was interesting too that he was running his from a MacBook Pro. Every computer I own is a PC based (Windows) - even though they boot to Linux. Just different - at least to me. ... 121-1.html

Posts: 4
Joined: Tue Sep 25, 2012 9:44 am