[WIP] Fermenter
This commit is contained in:
parent
8ad5195b94
commit
b57f8c9fd4
@ -36,3 +36,23 @@ build_flags = ${common.build_flags} -DNODE_GREENHOUSE -DHOSTNAME=\"Greenhouse\"
|
|||||||
monitor_speed = ${common.monitor_speed}
|
monitor_speed = ${common.monitor_speed}
|
||||||
upload_protocol = espota
|
upload_protocol = espota
|
||||||
upload_port = 10.0.0.169
|
upload_port = 10.0.0.169
|
||||||
|
|
||||||
|
[env:FermenterUSB]
|
||||||
|
platform = ${esp12e.platform}
|
||||||
|
board = ${esp12e.board}
|
||||||
|
framework = ${common.framework}
|
||||||
|
lib_deps = ${common.lib_deps}
|
||||||
|
build_flags = ${common.build_flags} -DNODE_FERMENTER -DHOSTNAME=\"Fermenter\"
|
||||||
|
monitor_speed = ${common.monitor_speed}
|
||||||
|
upload_port = /dev/ttyUSB0
|
||||||
|
upload_speed = 460800
|
||||||
|
|
||||||
|
[env:FermenterOTA]
|
||||||
|
platform = ${esp12e.platform}
|
||||||
|
board = ${esp12e.board}
|
||||||
|
framework = ${common.framework}
|
||||||
|
lib_deps = ${common.lib_deps}
|
||||||
|
build_flags = ${common.build_flags} -DNODE_FERMENTER -DHOSTNAME=\"Fermenter\"
|
||||||
|
monitor_speed = ${common.monitor_speed}
|
||||||
|
upload_protocol = espota
|
||||||
|
;upload_port = 10.0.0.169
|
||||||
|
|||||||
24
src/Fermenter.cpp
Normal file
24
src/Fermenter.cpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifdef NODE_FERMENTER
|
||||||
|
|
||||||
|
#include "patrix/bme680.h"
|
||||||
|
#include "patrix/tsl2561.h"
|
||||||
|
|
||||||
|
DS18B20 ds18b20();
|
||||||
|
|
||||||
|
DS18B20Sensor sensor(ds18b20);
|
||||||
|
|
||||||
|
PWMOutput heater();
|
||||||
|
|
||||||
|
void patrixSetup() {
|
||||||
|
ds18b20.setup();
|
||||||
|
sensor.setup();
|
||||||
|
heater.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void patrixLoop() {
|
||||||
|
ds18b20.loop();
|
||||||
|
sensor.loop();
|
||||||
|
heater.loop();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
74
src/patrix/DS18B20.h
Normal file
74
src/patrix/DS18B20.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#ifndef HELLIGKEIT_DS18B20_H
|
||||||
|
#define HELLIGKEIT_DS18B20_H
|
||||||
|
|
||||||
|
#include "OneWire.h"
|
||||||
|
#include "DallasTemperature.h"
|
||||||
|
|
||||||
|
class DS18B20 {
|
||||||
|
|
||||||
|
enum State {
|
||||||
|
IDLE, CONVERTING, DONE
|
||||||
|
};
|
||||||
|
|
||||||
|
String& name;
|
||||||
|
|
||||||
|
const int pin;
|
||||||
|
|
||||||
|
OneWire oneWire;
|
||||||
|
|
||||||
|
DallasTemperature sensors;
|
||||||
|
|
||||||
|
State state = IDLE;
|
||||||
|
|
||||||
|
unsigned long timeout = 1000;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
explicit DS18B20(String& name, int pin) : name(name), pin(pin), oneWire(pin), sensors(&oneWire) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
void begin() {
|
||||||
|
sensors.begin();
|
||||||
|
sensors.setWaitForConversion(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
switch (state) {
|
||||||
|
case IDLE:
|
||||||
|
sensors.requestTemperatures();
|
||||||
|
break;
|
||||||
|
case CONVERTING:
|
||||||
|
if (sensors.isConversionComplete()) {
|
||||||
|
|
||||||
|
} else if (millis() - last > timeout) {
|
||||||
|
Serial.printf("DS18B20 \"%s\" pin #%d: timeout", name.c_str(), pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class DS18B20Sensor {
|
||||||
|
|
||||||
|
DS18B20& bus;
|
||||||
|
|
||||||
|
const int index;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DS18B20Sensor(DS18B20& bus, int index) : bus(bus), index(index) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //HELLIGKEIT_DS18B20_H
|
||||||
Loading…
Reference in New Issue
Block a user