Skip to content

Instantly share code, notes, and snippets.

@navin-bhaskar
Created April 8, 2015 16:56
Show Gist options
  • Select an option

  • Save navin-bhaskar/aeba281a7e3f94a5d9dd to your computer and use it in GitHub Desktop.

Select an option

Save navin-bhaskar/aeba281a7e3f94a5d9dd to your computer and use it in GitHub Desktop.
Temperature sensor using mraa
#!/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