-
Notifications
You must be signed in to change notification settings - Fork 85
adds TMP36/LM35 library with an example #35
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| """ | ||
| tmp36-lm35.py | ||
| Alaa Agwa - 3/2014 | ||
|
|
||
| Example program for PyBBIO's TMP36LM35 library. | ||
| Reads the temerature from the TMP36 or LM35 sensors from analog pin. | ||
|
|
||
| This example program is in the public domain. | ||
| """ | ||
| from bbio import * | ||
| from TMP36LM35 import * | ||
|
|
||
| data_pin = GPIO1_15 # P8.15 | ||
|
|
||
| sensor = TMP36LM35(data_pin) | ||
|
|
||
| def setup(): | ||
| pass | ||
|
|
||
| def loop(): | ||
| temp = sensor.readTempC() | ||
| if (not temp): | ||
| # The sensor reported an error. | ||
| print "Error reading the sensor value" | ||
| else: | ||
| print "Temp: %0.2f C" % temp | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indent this line by one more level |
||
|
|
||
| delay(1000) | ||
|
|
||
| run(setup,loop) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Servo - v0.1 | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Servo" ? |
||
| Copyright 2014 Alaa Agwa | ||
| agwatic@gmail.com | ||
|
|
||
| Library for controlling servo motors with the BeagleBone's PWM pins. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Description needs to be corrected |
||
|
|
||
| As well as the included example programs: | ||
| PyBBIO/examples/tmp36-lm35.py | ||
|
|
||
|
|
||
|
|
||
| Servo is released as part of PyBBIO under its Apache 2.0 license. | ||
| See PyBBIO/LICENSE.txt | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| """ | ||
| Servo - v0.1 | ||
| Copyright 2012 Alexander Hiam | ||
|
|
||
| Library for reading the values of TMP36/LM35 temperature sensors. | ||
| """ | ||
|
|
||
| from bbio import * | ||
|
|
||
| class TMP36LM35(object): | ||
| def __init__(self, data_pin=None): | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty line not needed |
||
| self.data_pin = data_pin | ||
|
|
||
| def readTempC(self): | ||
| """ Gets the sensor data in Celsius """ | ||
| return ((analogRead(self.data_pin)*3.3)/1024) # 3.3 for the gpio pin it's max volt are 3.3 V | ||
|
|
||
|
|
||
| def readTempF(self): | ||
| """ Return the sensor data in Fahrenheit """ | ||
| tempC = ((analogRead(self.data_pin)*3.3)/1024) # 3.3 for the gpio pin it's max volt are 3.3 V | ||
| return ((tempC * 9.0/5.0) + 32) | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. strange EOF characters |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # __init__.py for TMP36LM35 | ||
|
|
||
| from TMP36LM35 import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent lines 23+24 by one more level