Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Raspberry PiとLPS25Hで気圧取得
import sys
import wiringpi2
from time import sleep
wiringpi2.wiringPiSetup()
i2c = wiringpi2.I2C()
lps25h = i2c.setup(0x5C)
whoami = i2c.readReg8(lps25h,0x0F)
if whoami != 0xBD:
print "error"
sys.exit(1)
i2c.writeReg8(lps25h,0x20,0x90)
sleep(1)
ppxl = i2c.readReg8(lps25h,0x28)
pol = i2c.readReg8(lps25h,0x29)
poh = i2c.readReg8(lps25h,0x2A)
counts = poh << 16 | pol << 8 | ppxl
print "Pressure %.2f" % (counts/4096.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment