Skip to content

Instantly share code, notes, and snippets.

@9SQ
Created May 1, 2015 09:40
Show Gist options
  • Save 9SQ/ef1012994ecf7b58ea2d to your computer and use it in GitHub Desktop.
Save 9SQ/ef1012994ecf7b58ea2d to your computer and use it in GitHub Desktop.
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