Compare commits
2 Commits
5b01a417c7
...
b57f8c9fd4
| Author | SHA1 | Date | |
|---|---|---|---|
| b57f8c9fd4 | |||
| 8ad5195b94 |
@ -1,13 +1,58 @@
|
||||
[env:Greenhouse]
|
||||
platform = espressif8266
|
||||
board = esp12e
|
||||
[common]
|
||||
framework = arduino
|
||||
lib_deps = https://github.com/adafruit/Adafruit_TSL2561
|
||||
lib_deps = https://github.com/milesburton/Arduino-Temperature-Control-Library
|
||||
https://github.com/adafruit/Adafruit_TSL2561
|
||||
https://github.com/knolleary/pubsubclient
|
||||
https://github.com/adafruit/Adafruit_BME680
|
||||
build_flags = -DHOSTNAME=\"Greenhouse\"
|
||||
build_flags =
|
||||
monitor_speed = 115200
|
||||
upload_protocol = espota
|
||||
upload_port = 10.0.0.169
|
||||
;upload_port = /dev/ttyUSB0
|
||||
;upload_speed = 460800
|
||||
|
||||
[esp12e]
|
||||
platform = espressif8266
|
||||
board = esp12e
|
||||
|
||||
[esp32]
|
||||
platform = espressif32
|
||||
board = esp32dev
|
||||
|
||||
[env:GreenhouseUSB]
|
||||
platform = ${esp12e.platform}
|
||||
board = ${esp12e.board}
|
||||
framework = ${common.framework}
|
||||
lib_deps = ${common.lib_deps}
|
||||
build_flags = ${common.build_flags} -DNODE_GREENHOUSE -DHOSTNAME=\"Greenhouse\"
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
upload_port = /dev/ttyUSB0
|
||||
upload_speed = 460800
|
||||
|
||||
[env:GreenhouseOTA]
|
||||
platform = ${esp12e.platform}
|
||||
board = ${esp12e.board}
|
||||
framework = ${common.framework}
|
||||
lib_deps = ${common.lib_deps}
|
||||
build_flags = ${common.build_flags} -DNODE_GREENHOUSE -DHOSTNAME=\"Greenhouse\"
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
upload_protocol = espota
|
||||
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
|
||||
24
src/Greenhouse.cpp
Normal file
24
src/Greenhouse.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#ifdef NODE_GREENHOUSE
|
||||
|
||||
#include "patrix/bme680.h"
|
||||
#include "patrix/tsl2561.h"
|
||||
|
||||
TSL2561 gardenTSL("garden");
|
||||
|
||||
BME680 gardenBME("garden");
|
||||
|
||||
BME680 greenhouseBME("greenhouse");
|
||||
|
||||
void patrixSetup() {
|
||||
gardenTSL.setup();
|
||||
gardenBME.setup();
|
||||
greenhouseBME.setup();
|
||||
}
|
||||
|
||||
void patrixLoop() {
|
||||
gardenTSL.loop();
|
||||
gardenBME.loop();
|
||||
greenhouseBME.loop();
|
||||
}
|
||||
|
||||
#endif
|
||||
31
src/main.cpp
31
src/main.cpp
@ -1,31 +0,0 @@
|
||||
#include <bme680.h>
|
||||
#include "mqtt.h"
|
||||
#include "tsl2561.h"
|
||||
#include "wifi.h"
|
||||
|
||||
TSL2561 gardenTSL("garden");
|
||||
|
||||
BME680 gardenBME("garden");
|
||||
|
||||
BME680 greenhouseBME("greenhouse");
|
||||
|
||||
void setup() {
|
||||
delay(500);
|
||||
Log.printf("\n\n\nStartup\n");
|
||||
wifiConnect();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
wifiLoop();
|
||||
mqttLoop();
|
||||
if (isSetupTimeAfterBootDelay()) {
|
||||
gardenTSL.setup();
|
||||
gardenBME.setup();
|
||||
greenhouseBME.setup();
|
||||
}
|
||||
if (isAfterBootDelay()) {
|
||||
gardenTSL.loop();
|
||||
gardenBME.loop();
|
||||
greenhouseBME.loop();
|
||||
}
|
||||
}
|
||||
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
|
||||
18
src/patrix/Patrix.cpp
Normal file
18
src/patrix/Patrix.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "Patrix.h"
|
||||
|
||||
void setup() {
|
||||
delay(500);
|
||||
Log.printf("\n\n\nStartup\n");
|
||||
wifiConnect();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
wifiLoop();
|
||||
mqttLoop();
|
||||
if (isSetupTimeAfterBootDelay()) {
|
||||
patrixSetup();
|
||||
}
|
||||
if (isAfterBootDelay()) {
|
||||
patrixLoop();
|
||||
}
|
||||
}
|
||||
11
src/patrix/Patrix.h
Normal file
11
src/patrix/Patrix.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef PATRIX_H
|
||||
#define PATRIX_H
|
||||
|
||||
#include "wifi.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
void patrixSetup();
|
||||
|
||||
void patrixLoop();
|
||||
|
||||
#endif
|
||||
@ -1,8 +1,8 @@
|
||||
#ifndef BME680_H
|
||||
#define BME680_H
|
||||
|
||||
#include <Adafruit_BME680.h>
|
||||
#include <mqtt.h>
|
||||
#include "Adafruit_BME680.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
class BME680 {
|
||||
|
||||
@ -16,7 +16,7 @@ public:
|
||||
|
||||
unsigned long intervalMs;
|
||||
|
||||
explicit BME680(const String& name, const unsigned long interval_ms = 5000) : name(name), intervalMs(interval_ms) {
|
||||
explicit BME680(String name, const unsigned long interval_ms = 5000) : name(std::move(name)), intervalMs(interval_ms) {
|
||||
//
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#include "wifi.h"
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <PubSubClient.h>
|
||||
#include "PubSubClient.h"
|
||||
#include <WiFiClient.h>
|
||||
|
||||
WiFiClient client;
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef TSL2561_H
|
||||
#define TSL2561_H
|
||||
|
||||
#include <Adafruit_TSL2561_U.h>
|
||||
#include "Adafruit_TSL2561_U.h"
|
||||
|
||||
class TSL2561 {
|
||||
|
||||
@ -15,7 +15,7 @@ public:
|
||||
|
||||
unsigned long intervalMs;
|
||||
|
||||
explicit TSL2561(const String& name, const uint8_t address = TSL2561_ADDR_FLOAT, const unsigned long interval_ms = 5000) : tsl(Adafruit_TSL2561_Unified(address)), name(name), intervalMs(interval_ms) {
|
||||
explicit TSL2561(String name, const uint8_t address = TSL2561_ADDR_FLOAT, const unsigned long interval_ms = 5000) : tsl(Adafruit_TSL2561_Unified(address)), name(std::move(name)), intervalMs(interval_ms) {
|
||||
//
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user