Edison, Getting Started, http://schemas.google.com/blogger/2008/kind#post, Intel Edison, Intel Galileo, IoT Linux image, mraa, python, Tutorial, upm

Python on Intel Galileo/Edison – Part 5:Temperature sensor with mraa and upm

The temperature sensor that we are gong to use for this post is from Grove. This sensor outputs the voltage that represents the temperature hence we will need the ADC module on the Intel Galileo/Edison to interface with this peripheral.
Reading the temperature with mraa:
The temperature sensor is connected to the pin A1. ADC is used to get the voltage reading out of the temperature sensor. The following code prints out the temperature onto console. The formula used here is taken form example code found here.

 Reading the temperature with upm:
As mentioned in one of my previous posts, upm can be used to interface with sensors. Either you can write code using mraa to drive your sensor (in the process write initializing code and supporting code in case of more complicated components) or you can leverage on the work done by good folks at Intel and use upm.
upm supports an array of sensors and peripherals for you to use. The following script does the same thing as done by the previous script but this time with upm and you can see how simple things can get with the upm. In the script below, we import the upm library using

import pyupm_grove

and specify the ADC in pin that you want to use

temp = pyupm_grove.GroveTemp(1)

You can read the temperature using the “value” method.

Other parts:
part0: Getting started on Galileo/Edison
part1: GPIO output
part2: GPIO input(button)
part3: pwm
part4: adc
part5: Temperature sensor
part6: Light sensor



6 thoughts on “Python on Intel Galileo/Edison – Part 5:Temperature sensor with mraa and upm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s