|
3 | 3 | # |
4 | 4 | # SPDX-License-Identifier: MIT |
5 | 5 | import time |
6 | | -import board |
7 | | -import adafruit_dps310 |
8 | | -import adafruit_ahtx0 |
9 | 6 | from adafruit_funhouse import FunHouse |
10 | 7 |
|
11 | | -i2c = board.I2C() |
12 | | -dps310 = adafruit_dps310.DPS310(i2c) |
13 | | -aht20 = adafruit_ahtx0.AHTx0(i2c) |
14 | | - |
15 | 8 | funhouse = FunHouse(default_bg=None) |
16 | 9 | funhouse.peripherals.set_dotstars(0x800000, 0x808000, 0x008000, 0x000080, 0x800080) |
17 | 10 |
|
@@ -58,16 +51,18 @@ def message(client, feed_id, payload): |
58 | 51 | while True: |
59 | 52 | funhouse.network.mqtt_loop() |
60 | 53 |
|
61 | | - print("Temp %0.1F" % dps310.temperature) |
62 | | - print("Pres %d" % dps310.pressure) |
| 54 | + print("Temp %0.1F" % funhouse.peripherals.temperature) |
| 55 | + print("Pres %d" % funhouse.peripherals.pressure) |
63 | 56 |
|
64 | 57 | # every 10 seconds, write temp/hum/press |
65 | 58 | if (time.monotonic() - sensorwrite_timestamp) > 10: |
66 | 59 | funhouse.peripherals.led = True |
67 | 60 | print("Sending data to adafruit IO!") |
68 | | - funhouse.network.mqtt_publish("temperature", dps310.temperature) |
69 | | - funhouse.network.mqtt_publish("humidity", int(aht20.relative_humidity)) |
70 | | - funhouse.network.mqtt_publish("pressure", int(dps310.pressure)) |
| 61 | + funhouse.network.mqtt_publish("temperature", funhouse.peripherals.temperature) |
| 62 | + funhouse.network.mqtt_publish( |
| 63 | + "humidity", int(funhouse.peripherals.relative_humidity) |
| 64 | + ) |
| 65 | + funhouse.network.mqtt_publish("pressure", int(funhouse.peripherals.pressure)) |
71 | 66 | sensorwrite_timestamp = time.monotonic() |
72 | 67 | # Send PIR only if changed! |
73 | 68 | if last_pir is None or last_pir != funhouse.peripherals.pir_sensor: |
|
0 commit comments