Skip to content

Instantly share code, notes, and snippets.

@whatnick
Last active July 21, 2016 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save whatnick/232a5010faa201dc41cc9c85738a47b9 to your computer and use it in GitHub Desktop.
Save whatnick/232a5010faa201dc41cc9c85738a47b9 to your computer and use it in GitHub Desktop.
Test MPL3115 barometer/altimeter using Python
temp_raw_file = open('/sys/class/i2c-dev/i2c-1/device/1-0060/iio:device0/in_temp_raw','r')
temp_scale_file = open('/sys/class/i2c-dev/i2c-1/device/1-0060/iio:device0/in_temp_scale','r')
print "temperature: %.2f" %(int(temp_raw_file.read())*float(temp_scale_file.read()))
pres_raw_file = open('/sys/class/i2c-dev/i2c-1/device/1-0060/iio:device0/in_pressure_raw','r')
pres_scale_file = open('/sys/class/i2c-dev/i2c-1/device/1-0060/iio:device0/in_pressure_scale','r')
print "pressure: %.4f" %(int(pres_raw_file.read())*float(pres_scale_file.read()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment