Пример #1
0
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import busio
import adafruit_lps2x

i2c = busio.I2C(board.SCL, board.SDA)
# uncomment and comment out the line after to use with the LPS22
# lps = adafruit_lps2x.LPS22(i2c)
lps = adafruit_lps2x.LPS25(i2c)
while True:
    print("Pressure: %.2f hPa" % lps.pressure)
    print("Temperature: %.2f C" % lps.temperature)
    time.sleep(1)
    def read_byte(self, addr):
        while not self.i2cbus.try_lock():
            pass
        self.i2cbus.readfrom_into(self.ctrl_address, addr,self.buffer, start=1)
        self.i2cbus.unlock()
        return self.buffer[1]


lps25h_addr = 0x5c
lsm9ds1_mag_addr = 0x1c
hts221_addr = 0x5f # Matches Adafruit breakout and library - here for reference
led2472g_addr = 0x46
lsm9ds1_xg_addr = 0x6a

i2c=busio.I2C(board.GP21,board.GP20)
lps25h=adafruit_lps2x.LPS25(i2c,lps25h_addr)
hts221=adafruit_hts221.HTS221(i2c)
lsm9ds1=adafruit_lsm9ds1.LSM9DS1_I2C(i2c,lsm9ds1_mag_addr,lsm9ds1_xg_addr)

dpad=DPad(i2c)
leds=LedMatrix(i2c)

leds.clear()

i=0

while True:
    print("LPS25H")
    print("Pressure: %.2f hPa" % lps25h.pressure)
    print("Temperature: %.2f C" % lps25h.temperature)
    print()