mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-10 07:10:42 +00:00
4805072969
- added a modified ThingPulse oled library. - made "sensor_config" "node_config" - made - made "fdrs_functions.h" "fdrs_gateway.h"
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
// FARM DATA RELAY SYSTEM
|
|
//
|
|
// Multifunction ESP8266 Sensor Board by Phil Grant
|
|
//
|
|
// https://github.com/gadjet/Multifunction-ESP8266-Sensor-board
|
|
//
|
|
|
|
#include "fdrs_node_config.h"
|
|
#include <Adafruit_AHT10.h>
|
|
#include <fdrs_node.h>
|
|
|
|
Adafruit_AHT10 aht;
|
|
|
|
const int reedSwitch = 13;
|
|
|
|
void setup() {
|
|
aht.begin();
|
|
|
|
// Init Serial Monitor
|
|
//Serial.begin(115200);
|
|
// initialize the reed switch pin as an input:
|
|
pinMode(reedSwitch, INPUT);
|
|
// initialize the wakeup pin as an input:
|
|
pinMode(16, WAKEUP_PULLUP);
|
|
beginFDRS();
|
|
}
|
|
|
|
|
|
void loop() {
|
|
sensors_event_t humidity, temp;
|
|
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
|
|
// Read the state of the reed switch and send open or closed
|
|
if (digitalRead(reedSwitch) == HIGH) {
|
|
loadFDRS(1.0, MOTION_T);
|
|
}
|
|
else {
|
|
loadFDRS(0.0, MOTION_T);
|
|
}
|
|
loadFDRS((analogRead(A0) * 4.2 * 10 / 1023), VOLTAGE_T);
|
|
loadFDRS(humidity.relative_humidity, HUMIDITY_T);
|
|
loadFDRS(temp.temperature, TEMP_T);
|
|
// Send message via FDRS
|
|
sendFDRS();
|
|
sleepFDRS(15); //15 Min's sleep
|
|
}
|