Created
April 8, 2015 16:56
-
-
Save navin-bhaskar/aeba281a7e3f94a5d9dd to your computer and use it in GitHub Desktop.
Temperature sensor using mraa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import mraa | |
| import time | |
| import math | |
| # More info here -> http://www.seeedstudio.com/wiki/Grove_-_Temperature_Sensor | |
| B=3975 | |
| ain = mraa.Aio(1) | |
| a = ain.read() | |
| resistance = (1023-a)*10000.0/a | |
| temp = 1/(math.log(resistance/10000.0)/B+1/298.15)-273.15 | |
| print "Temperature now is " + str(temp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment