-
Notifications
You must be signed in to change notification settings - Fork 0
/
Greenhouse.ino
49 lines (40 loc) · 1.31 KB
/
Greenhouse.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <forcedClimate.h>
#include "MqttClient.hpp"
#include "ClimateManager.hpp"
#include "PlantManager.hpp"
WiFiClient espClient;
MqttClient client("KraanBast2.4", "Snip238!", "192.168.178.81", "/raspberrypi/hassio", espClient);
ForcedClimate climateSensor = ForcedClimate();
ClimateManager climateManager = ClimateManager(climateSensor, client, CLM_10MIN);
PlantManager plantManager = PlantManager(D5, client);
void callback(char* topic, byte* payload, unsigned int length) {
static String message;
for (int i = 0; i < length; i++) {
message.concat((char)payload[i]);
}
client.notifyListeners(message, topic);
message = "";
}
void setup(){
Wire.begin();
Serial.begin(115200);
climateSensor.begin();
plantManager.begin();
client.setupWifi();
client.setupConnections();
climateSensor.takeForcedMeasurement();
Serial.print("Temperature: ");
Serial.print(climateSensor.getTemperatureCelcius());
Serial.print(", Humidity: ");
Serial.print(climateSensor.getRelativeHumidity());
Serial.print(" and Pressure: ");
Serial.print(climateSensor.getPressure());
Serial.println();
}
void loop(){
client(); // Handle incoming messages
climateManager();
plantManager();
}