Farm-Data-Relay-System/examples/Sensor_Examples/MESB_fdrs/MESB_fdrs.ino
Timm Bogner 4805072969 more shuffling
- added a modified ThingPulse oled library.
- made "sensor_config" "node_config"
- made - made "fdrs_functions.h" "fdrs_gateway.h"
2023-01-25 19:28:18 -06:00

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
}