Created
July 5, 2014 22:11
-
-
Save murilopontes/106636230ecb7acf47cd to your computer and use it in GitHub Desktop.
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 | |
from Adafruit_I2C import Adafruit_I2C | |
from time import sleep | |
ms5611 = Adafruit_I2C(0x77,2) | |
#reset | |
ms5611.writeList(0x1e,[]) | |
sleep(2/1000.0) | |
#prom | |
t=ms5611.readList(0xa2,2) | |
c1=t[0]*256+t[1] | |
t=ms5611.readList(0xa4,2) | |
c2=t[0]*256+t[1] | |
t=ms5611.readList(0xa6,2) | |
c3=t[0]*256+t[1] | |
t=ms5611.readList(0xa8,2) | |
c4=t[0]*256+t[1] | |
t=ms5611.readList(0xaa,2) | |
c5=t[0]*256+t[1] | |
t=ms5611.readList(0xac,2) | |
c6=t[0]*256+t[1] | |
#c1=40127 | |
#c2=36924 | |
#c3=23317 | |
#c4=23282 | |
#c5=33464 | |
#c6=28312 | |
while True: | |
ms5611.writeList(0x40,[]) | |
sleep(1/1000.0) | |
adc=ms5611.readList(0x00,3) | |
d1=adc[0]*65536+adc[1]*256+adc[2] | |
#d1=9085466 | |
ms5611.writeList(0x50,[]) | |
sleep(1/1000.0) | |
adc=ms5611.readList(0x00,3) | |
d2=adc[0]*65536+adc[1]*256+adc[2] | |
#d2=8569150 | |
dt = d2 - c5*(1<<8) | |
temp=2000+ dt*c6/(1<<23) | |
off= c2*(1<<16) + c4*dt/(1<<7) | |
sens=c1*(1<<15) + c3*dt/(1<<8) | |
p=(d1*sens/(1<<21) - off)/(1<<15) | |
print c1,c2,c3,c4,c5,c6,d1,d2,dt,temp/100.0,off,sens,p/100.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment