This commit is contained in:
PaulVua
2025-02-11 10:06:44 +01:00
parent 62c729b63b
commit ecd61f765a
11 changed files with 297 additions and 10 deletions

View File

@@ -48,9 +48,11 @@ ser = serial.Serial(
timeout = 0.5
)
# 1⃣ Request PM Data (PM1, PM2.5, PM10)
#ser.write(b'\x81\x11\x6E') #data10s
ser.write(b'\x81\x12\x6D') #data60s
time.sleep(0.5) # Small delay to allow the sensor to process the request
#print("Start get_data_v2.py script")
byte_data = ser.readline()
@@ -61,8 +63,9 @@ PM1 = int.from_bytes(byte_data[9:11], byteorder='big')/10
PM25 = int.from_bytes(byte_data[11:13], byteorder='big')/10
PM10 = int.from_bytes(byte_data[13:15], byteorder='big')/10
# Write command to retrieve temperature and humidity data
# 2⃣ Request Temperature & Humidity
ser.write(b'\x81\x14\x6B') # Temp and humidity command
time.sleep(0.5) # Small delay to allow the sensor to process the request
byte_data_temp_hum = ser.readline()
# Decode temperature and humidity values