Greenhouse: door + windows pins
This commit is contained in:
parent
fa4e266bc5
commit
1732fce143
@ -6,16 +6,14 @@
|
||||
#include "sensors.h"
|
||||
#include "../../patrix/mqtt.h"
|
||||
|
||||
bool light = false;
|
||||
|
||||
void httpStatus(AsyncWebServerRequest* request) {
|
||||
JsonDocument json;
|
||||
json["illuminance"] = greenhouseTSL.getIlluminance();;
|
||||
json["temperature"] = greenhouseDHT22.getTemperature();
|
||||
json["relative"] = greenhouseDHT22.getRelative();
|
||||
json["absolute"] = greenhouseDHT22.getAbsolute();
|
||||
json["door"] = false;
|
||||
json["windows"] = false;
|
||||
json["door"] = door;
|
||||
json["windows"] = windows;
|
||||
json["light"] = light;
|
||||
|
||||
AsyncResponseStream* stream = request->beginResponseStream("application/json");
|
||||
|
||||
@ -2,18 +2,36 @@
|
||||
|
||||
#include "sensors.h"
|
||||
|
||||
#define DHT22_GPIO D5
|
||||
#define DOOR_GPIO D0
|
||||
#define WINDOWS_GPIO D6
|
||||
#define LIGHT_GPIO D7
|
||||
|
||||
bool door = false;
|
||||
|
||||
bool windows = false;
|
||||
|
||||
bool light = false;
|
||||
|
||||
TSL2561 greenhouseTSL("greenhouse");
|
||||
|
||||
DHT22Sensor greenhouseDHT22("greenhouse", D5);
|
||||
DHT22Sensor greenhouseDHT22("greenhouse", DHT22_GPIO);
|
||||
|
||||
void sensorsSetup() {
|
||||
pinMode(DOOR_GPIO, INPUT_PULLUP);
|
||||
pinMode(WINDOWS_GPIO, INPUT_PULLUP);
|
||||
pinMode(LIGHT_GPIO, OUTPUT);
|
||||
digitalWrite(LIGHT_GPIO, light ? LOW : HIGH);
|
||||
greenhouseTSL.setup();
|
||||
greenhouseDHT22.setup();
|
||||
}
|
||||
|
||||
void sensorsLoop() {
|
||||
door = digitalRead(DOOR_GPIO) == LOW;
|
||||
windows = digitalRead(WINDOWS_GPIO) == LOW;
|
||||
digitalWrite(LIGHT_GPIO, light ? LOW : HIGH);
|
||||
greenhouseTSL.loop();
|
||||
greenhouseDHT22.loop();
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -6,6 +6,12 @@
|
||||
#include "patrix/DHT22.h"
|
||||
#include "patrix/tsl2561.h"
|
||||
|
||||
extern boolean door;
|
||||
|
||||
extern boolean windows;
|
||||
|
||||
extern boolean light;
|
||||
|
||||
extern TSL2561 greenhouseTSL;
|
||||
|
||||
extern DHT22Sensor greenhouseDHT22;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user