Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion adafruit_funhouse/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def init_mqtt(
# pylint: enable=too-many-arguments

def _get_mqtt_client(self):
print(self._mqtt_client)
if self._mqtt_client is not None:
return self._mqtt_client
raise RuntimeError("Please initialize MQTT before using")
Expand Down
27 changes: 27 additions & 0 deletions adafruit_funhouse/peripherals.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
from analogio import AnalogIn
import touchio
import simpleio
import adafruit_dps310
import adafruit_ahtx0
import adafruit_dotstar

__version__ = "0.0.0-auto.0"
Expand Down Expand Up @@ -74,6 +76,10 @@ def __init__(self):
cap = touchio.TouchIn(pin)
self._ctp.append(cap)

self.i2c = board.I2C()
self._dps310 = adafruit_dps310.DPS310(self.i2c)
self._aht20 = adafruit_ahtx0.AHTx0(self.i2c)

# LED
self._led = DigitalInOut(board.LED)
self._led.direction = Direction.OUTPUT
Expand Down Expand Up @@ -203,6 +209,27 @@ def light(self):
"""
return self._light.value

@property
def temperature(self):
"""
Return the temperature
"""
return self._aht20.temperature

@property
def relative_humidity(self):
"""
Return the relative humidity
"""
return self._aht20.relative_humidity

@property
def pressure(self):
"""
Return the temperature
"""
return self._dps310.pressure

@property
def led(self):
"""
Expand Down
19 changes: 7 additions & 12 deletions examples/funhouse_adafruit_io_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@
#
# SPDX-License-Identifier: MIT
import time
import board
import adafruit_dps310
import adafruit_ahtx0
from adafruit_funhouse import FunHouse

i2c = board.I2C()
dps310 = adafruit_dps310.DPS310(i2c)
aht20 = adafruit_ahtx0.AHTx0(i2c)

funhouse = FunHouse(default_bg=None)
funhouse.peripherals.set_dotstars(0x800000, 0x808000, 0x008000, 0x000080, 0x800080)

Expand Down Expand Up @@ -58,16 +51,18 @@ def message(client, feed_id, payload):
while True:
funhouse.network.mqtt_loop()

print("Temp %0.1F" % dps310.temperature)
print("Pres %d" % dps310.pressure)
print("Temp %0.1F" % funhouse.peripherals.temperature)
print("Pres %d" % funhouse.peripherals.pressure)

# every 10 seconds, write temp/hum/press
if (time.monotonic() - sensorwrite_timestamp) > 10:
funhouse.peripherals.led = True
print("Sending data to adafruit IO!")
funhouse.network.mqtt_publish("temperature", dps310.temperature)
funhouse.network.mqtt_publish("humidity", int(aht20.relative_humidity))
funhouse.network.mqtt_publish("pressure", int(dps310.pressure))
funhouse.network.mqtt_publish("temperature", funhouse.peripherals.temperature)
funhouse.network.mqtt_publish(
"humidity", int(funhouse.peripherals.relative_humidity)
)
funhouse.network.mqtt_publish("pressure", int(funhouse.peripherals.pressure))
sensorwrite_timestamp = time.monotonic()
# Send PIR only if changed!
if last_pir is None or last_pir != funhouse.peripherals.pir_sensor:
Expand Down
12 changes: 3 additions & 9 deletions examples/funhouse_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@
# SPDX-License-Identifier: Unlicense
import board
from digitalio import DigitalInOut, Direction, Pull
import adafruit_dps310
import adafruit_ahtx0
from adafruit_funhouse import FunHouse

funhouse = FunHouse(
default_bg=0x0F0F00,
scale=2,
)

i2c = board.I2C()
dps310 = adafruit_dps310.DPS310(i2c)
aht20 = adafruit_ahtx0.AHTx0(i2c)

funhouse.peripherals.set_dotstars(0x800000, 0x808000, 0x008000, 0x000080, 0x800080)

# sensor setup
Expand Down Expand Up @@ -71,10 +65,10 @@ def set_label_color(conditional, index, on_color):
funhouse.display.show(funhouse.splash)

while True:
funhouse.set_text("Temp %0.1F" % dps310.temperature, temp_label)
funhouse.set_text("Pres %d" % dps310.pressure, pres_label)
funhouse.set_text("Temp %0.1F" % funhouse.peripherals.temperature, temp_label)
funhouse.set_text("Pres %d" % funhouse.peripherals.pressure, pres_label)

print(aht20.temperature, aht20.relative_humidity)
print(funhouse.peripherals.temperature, funhouse.peripherals.relative_humidity)
set_label_color(funhouse.peripherals.captouch6, onoff_label, 0x00FF00)
set_label_color(funhouse.peripherals.captouch7, capleft_label, 0x00FF00)
set_label_color(funhouse.peripherals.captouch8, capright_label, 0x00FF00)
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ adafruit-circuitpython-dotstar
adafruit-circuitpython-requests
adafruit-circuitpython-simpleio
adafruit-circuitpython-minimqtt
adafruit-circuitpython-dps310
adafruit-circuitpython-ahtx0