The Python Console

Before writing a Python program to measure and report the temperature, we can try some experiments in the Python Console.

To launch the Python Console type:
# python
Python 2.7.3 (default, Apr  3 2013, 21:37:23) 
[GCC 4.7.3 20130205 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
First, we need to import the library, so enter the command:
>>> import Adafruit_BBIO.ADC as ADC
Now enter the command below into the Python Console to setup the ADC (Analog to Digital Convertor).
>>> ADC.setup()
You can now read the value at the analog input (between 0 and 1) using the command below. Try it a few times while putting your finger on the TMP36 to warm it up. The readings should gradually increase.
>>> ADC.read("P9_40")
0.38999998569488525
>>> ADC.read("P9_40")
0.38833332061767578
>>> ADC.read("P9_40")
0.39722222089767456
>>> ADC.read("P9_40")
0.42500001192092896
Note: Using the up arrow will repeat the last line that you entered in the Python Console.
These readings are not yet an actual temperature, so in the next section we will write a short Python program to display the temperature in both degrees C and F.
Last updated on 2015-05-04 at 04.27.11 PM Published on 2013-06-27 at 10.22.13 AM