1
0
mirror of https://github.com/osmarks/random-stuff synced 2025-09-18 01:54:04 +00:00

number research

This commit is contained in:
osmarks
2025-05-02 16:59:29 +01:00
parent 6cadd09b4e
commit d057781e3c
6 changed files with 980 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ TARGET_ID = 0x58
CTRL_MEAS_REGISTER = 0xF4
PRESSURE_REGISTER_BASE = 0xF7
TEMP_REGISTER_BASE = 0xFA
CALIBRAITON_VALUES = {
CALIBRATION_VALUES = {
"dig_T1": {"address": (0x88, 0x89), "unpack": "<H"},
"dig_T2": {"address": (0x8A, 0x8B), "unpack": "<h"},
"dig_T3": {"address": (0x8C, 0x8D), "unpack": "<h"},
@@ -32,7 +32,7 @@ def setup():
assert bus.read_byte_data(ADDR, ID_REGISTER) == TARGET_ID
bus.write_byte_data(ADDR, CTRL_MEAS_REGISTER, 0b101_101_11) # max oversampling mode (we don"t really care about power), power on
calibration = {}
for key, value in CALIBRAITON_VALUES.items():
for key, value in CALIBRATION_VALUES.items():
calibration[key] = struct.unpack(value["unpack"], bytes([bus.read_byte_data(ADDR, value["address"][0]), bus.read_byte_data(ADDR, value["address"][1])]))[0]
return calibration
@@ -81,4 +81,4 @@ start_http_server(9091)
while True:
read_temperature_pressure()
time.sleep(1)
time.sleep(1)