New fermenter support
This commit is contained in:
parent
5991765c60
commit
6758716ae0
|
@ -53,4 +53,6 @@ class MockPIN(Actuator):
|
||||||
|
|
||||||
actuators = {
|
actuators = {
|
||||||
'heater': (GPIOPin if rpi else MockPIN)(pin=22, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH),
|
'heater': (GPIOPin if rpi else MockPIN)(pin=22, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH),
|
||||||
|
'fan': (GPIOPin if rpi else MockPIN)(pin=27, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH),
|
||||||
|
'humidifier': (GPIOPin if rpi else MockPIN)(pin=17, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH),
|
||||||
}
|
}
|
||||||
|
|
35
sensors.py
35
sensors.py
|
@ -7,6 +7,10 @@ from os.path import exists
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
|
||||||
|
# SHT40
|
||||||
|
import board
|
||||||
|
import adafruit_sht4x
|
||||||
|
|
||||||
# TODO client: add a way to disable live plotting? server: stop
|
# TODO client: add a way to disable live plotting? server: stop
|
||||||
# sending data periodically to everybody!
|
# sending data periodically to everybody!
|
||||||
|
|
||||||
|
@ -63,6 +67,28 @@ class Temperature1W(Sensor):
|
||||||
return (time, None)
|
return (time, None)
|
||||||
return (time, int(re.search("t=([0-9]+)", content[1]).group(1)) / 1000.0)
|
return (time, int(re.search("t=([0-9]+)", content[1]).group(1)) / 1000.0)
|
||||||
|
|
||||||
|
class SHT40(Sensor):
|
||||||
|
def __init__(self, what):
|
||||||
|
self.measure = what
|
||||||
|
self.i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
self.sht = adafruit_sht4x.SHT4x(i2c)
|
||||||
|
print('Serial: ', hex(self.sht.serial_number))
|
||||||
|
# FIXME:
|
||||||
|
self.sht.mode = adafruit_sht4x.Mode.NOHEAT_HIGHPRECISION
|
||||||
|
# Can also set the mode to enable heater
|
||||||
|
# sht.mode = adafruit_sht4x.Mode.LOWHEAT_100MS
|
||||||
|
# modes = [adafruit_sht4x.Mode.HIGHHEAT_1S,
|
||||||
|
# adafruit_sht4x.Mode.LOWHEAT_100MS,
|
||||||
|
# adafruit_sht4x.Mode.NOHEAT_HIGHPRECISION]
|
||||||
|
|
||||||
|
def read(self):
|
||||||
|
time = perf_counter()
|
||||||
|
temperature, relative_humidity = sht.measurements
|
||||||
|
# print("Temperature: %0.1f C" % temperature)
|
||||||
|
# print("Humidity: %0.1f %%" % (relative_humidity))
|
||||||
|
# print("")
|
||||||
|
return (time, temerature if self.measure == 'Temperature' else relative_humidityg)
|
||||||
|
|
||||||
class Sensors():
|
class Sensors():
|
||||||
def __init__(self, history=2621440):
|
def __init__(self, history=2621440):
|
||||||
self.starttime = (datetime.now(), perf_counter())
|
self.starttime = (datetime.now(), perf_counter())
|
||||||
|
@ -78,9 +104,12 @@ class Sensors():
|
||||||
def scan(self):
|
def scan(self):
|
||||||
# FIXME: should scan, apply stored data and return this
|
# FIXME: should scan, apply stored data and return this
|
||||||
self.available_sensors = {
|
self.available_sensors = {
|
||||||
'T_ext': Temperature1W('28-06214252b671'),
|
'T_food': Temperature1W('28-06214252b671'),
|
||||||
'T_food': Temperature1W('28-062142531e5a'),
|
'T_ext': SHT40('Temperature'),
|
||||||
'heater': GPIOState(22),
|
'H_ext': SHT40('Humidity'),
|
||||||
|
'heater': GPIOState(22),
|
||||||
|
'humidifier': GPIOState(17),
|
||||||
|
'fan': GPIOState(27),
|
||||||
}
|
}
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
|
|
Loading…
Reference in New Issue