Cleaned up library base structure
* keywords.txt (for syntax highlighting), library.properties (for a proper description added * moved Universal_Sensor_beta to the examples directory * moved Sensors, FDRS_Sensor and FDRS_Gateway to resources folder. They contain documentation which needs to be kept (to be discussed where to put that later on) but are fully redundant as they are just duplicates of the different sensors / gateways in the examples folder.
29
keywords.txt
Normal file
@ -0,0 +1,29 @@
|
||||
##########################################################
|
||||
# Syntax Coloring Map For Farm-Data-Relay-System
|
||||
##########################################################
|
||||
|
||||
##########################################################
|
||||
# Datatypes (KEYWORD1)
|
||||
##########################################################
|
||||
|
||||
DataReading KEYWORD1
|
||||
|
||||
##########################################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
##########################################################
|
||||
|
||||
beginFDRS KEYWORD2
|
||||
loadFDRS KEYWORD2
|
||||
sendFDRS KEYWORD2
|
||||
sleepFDRS KEYWORD2
|
||||
DBG KEYWORD2
|
||||
getLoRa KEYWORD2
|
||||
sendESPNOW KEYWORD2
|
||||
sendSerial KEYWORD2
|
||||
sendMQTT KEYWORD2
|
||||
bufferESPNOW KEYWORD2
|
||||
bufferSerial KEYWORD2
|
||||
bufferMQTT KEYWORD2
|
||||
bufferLoRa KEYWORD2
|
||||
transmitLoRa KEYWORD2
|
||||
getSerial KEYWORD2
|
10
library.properties
Normal file
@ -0,0 +1,10 @@
|
||||
name=Farm-Data-Relay-System
|
||||
version=2.0.1
|
||||
author=Timm Bogner <timmbogner@gmail.com>
|
||||
maintainer=Timm Bogner <timmbogner@gmail.com>
|
||||
sentence=Farm-Data-Relay-System - a infrastructure and cloud-less network
|
||||
paragraph=FDRS is a highly configurable cloud-agnostic network utilizing LoRa and ESPNow. Easily define nodes as sensors or routers and easily configure the way different protocols are forwarded.
|
||||
category=Communication
|
||||
url=https://github.com/timmbogner/Farm-Data-Relay-System
|
||||
architectures=*
|
||||
#includes=fdrs_globals.h,fdrs_sensor.h
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 228 KiB |
Before Width: | Height: | Size: 238 KiB After Width: | Height: | Size: 238 KiB |
Before Width: | Height: | Size: 241 KiB After Width: | Height: | Size: 241 KiB |
Before Width: | Height: | Size: 221 KiB After Width: | Height: | Size: 221 KiB |
@ -1,29 +1,29 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// AHT20 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <Adafruit_AHTX0.h>
|
||||
#include <fdrs_sensor.h>
|
||||
|
||||
Adafruit_AHTX0 aht;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
beginFDRS();
|
||||
if (! aht.begin()) {
|
||||
Serial.println("Could not find AHT? Check wiring");
|
||||
while (1) delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
sensors_event_t humidity, temp;
|
||||
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
|
||||
loadFDRS(temp.temperature, TEMP_T);
|
||||
loadFDRS(humidity.relative_humidity, HUMIDITY_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(60); //Sleep time in seconds
|
||||
}
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// AHT20 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <Adafruit_AHTX0.h>
|
||||
#include <fdrs_sensor.h>
|
||||
|
||||
Adafruit_AHTX0 aht;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
beginFDRS();
|
||||
if (! aht.begin()) {
|
||||
Serial.println("Could not find AHT? Check wiring");
|
||||
while (1) delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
sensors_event_t humidity, temp;
|
||||
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
|
||||
loadFDRS(temp.temperature, TEMP_T);
|
||||
loadFDRS(humidity.relative_humidity, HUMIDITY_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(60); //Sleep time in seconds
|
||||
}
|
@ -1,28 +1,28 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// BME280 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (bogner1@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA.
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <fdrs_sensor.h>
|
||||
|
||||
Adafruit_BME280 bme;
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(115200);
|
||||
beginFDRS();
|
||||
while (!bme.begin(0x76)) {
|
||||
//Serial.println("BME not initializing!");
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
loadFDRS(bme.readTemperature(), TEMP_T);
|
||||
loadFDRS(bme.readHumidity(), HUMIDITY_T);
|
||||
loadFDRS(bme.readPressure() / 100.0F, PRESSURE_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(60); //Sleep time in seconds
|
||||
}
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// BME280 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (bogner1@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA.
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <fdrs_sensor.h>
|
||||
|
||||
Adafruit_BME280 bme;
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(115200);
|
||||
beginFDRS();
|
||||
while (!bme.begin(0x76)) {
|
||||
//Serial.println("BME not initializing!");
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
loadFDRS(bme.readTemperature(), TEMP_T);
|
||||
loadFDRS(bme.readHumidity(), HUMIDITY_T);
|
||||
loadFDRS(bme.readPressure() / 100.0F, PRESSURE_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(60); //Sleep time in seconds
|
||||
}
|
@ -1,28 +1,28 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// BMP280 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
// Connect sensor SDA and SCL pins to those of the ESP.
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include <fdrs_sensor.h>
|
||||
|
||||
Adafruit_BMP280 bmp;
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(115200);
|
||||
beginFDRS();
|
||||
while (!bmp.begin(0x76)) {
|
||||
//Serial.println("BMP not initializing!");
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
loadFDRS(bmp.readTemperature(), TEMP_T);
|
||||
loadFDRS(bmp.readPressure() / 100.0F, PRESSURE_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(60); //Sleep time in seconds
|
||||
}
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// BMP280 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
// Connect sensor SDA and SCL pins to those of the ESP.
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include <fdrs_sensor.h>
|
||||
|
||||
Adafruit_BMP280 bmp;
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(115200);
|
||||
beginFDRS();
|
||||
while (!bmp.begin(0x76)) {
|
||||
//Serial.println("BMP not initializing!");
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
loadFDRS(bmp.readTemperature(), TEMP_T);
|
||||
loadFDRS(bmp.readPressure() / 100.0F, PRESSURE_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(60); //Sleep time in seconds
|
||||
}
|
@ -1,113 +1,113 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// LILYGO HIGROW SENSOR MODULE
|
||||
//
|
||||
|
||||
|
||||
#define I2C_SDA 25
|
||||
#define I2C_SCL 26
|
||||
#define DHT12_PIN 16
|
||||
#define BAT_ADC 33
|
||||
#define SALT_PIN 34
|
||||
#define SOIL_PIN 32
|
||||
#define BOOT_PIN 0
|
||||
#define USER_BUTTON 35
|
||||
#define DS18B20_PIN 21
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <fdrs_sensor.h>
|
||||
#include <BH1750.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
BH1750 lightMeter(0x23); //0x23
|
||||
Adafruit_BME280 bmp; //0x77
|
||||
RTC_DATA_ATTR int the_count = 0;
|
||||
|
||||
void setup() {
|
||||
|
||||
//Init Sensors
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
while (!bmp.begin()) {
|
||||
//Serial.println("bmp");
|
||||
delay(10);
|
||||
}
|
||||
|
||||
if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
|
||||
Serial.println(F("BH1750 Advanced begin"));
|
||||
} else {
|
||||
Serial.println(F("Error initialising BH1750"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loadData() {
|
||||
float s_battery = readBattery();
|
||||
float bme_temp = bmp.readTemperature();
|
||||
float bme_pressure = (bmp.readPressure() / 100.0F);
|
||||
//float bme_altitude = bmp.readAltitude(1013.25);
|
||||
float bme_humidity = bmp.readHumidity();
|
||||
float s_soil = readSoil();
|
||||
float s_salt = readSalt();
|
||||
while (! lightMeter.measurementReady()) {
|
||||
delay(10);
|
||||
}
|
||||
float lux = lightMeter.readLightLevel();
|
||||
the_count++;
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Temp: " + String(bme_temp));
|
||||
Serial.println("Humidity: " + String(bme_humidity));
|
||||
Serial.println("Light: " + String(lux));
|
||||
Serial.println("Pressure: " + String(bme_pressure));
|
||||
Serial.println("Salt: " + String(s_salt));
|
||||
Serial.println("Soil: " + String(s_soil));
|
||||
Serial.println("Voltage: " + String(s_battery));
|
||||
Serial.println("Count: " + String(the_count));
|
||||
|
||||
loadFDRS(bme_temp, TEMP_T);
|
||||
|
||||
loadFDRS(bme_humidity, HUMIDITY_T);
|
||||
|
||||
|
||||
loadFDRS(lux, LIGHT_T);
|
||||
loadFDRS(bme_pressure, PRESSURE_T);
|
||||
loadFDRS(s_salt, SOILR_T);
|
||||
loadFDRS(s_soil, SOIL_T);
|
||||
loadFDRS(s_battery, VOLTAGE_T);
|
||||
loadFDRS(float(the_count), IT_T);
|
||||
|
||||
}
|
||||
|
||||
uint32_t readSalt() //Soil Electrodes: This code came from the LilyGo documentation.
|
||||
{
|
||||
uint8_t samples = 120;
|
||||
uint32_t humi = 0;
|
||||
uint16_t array[120];
|
||||
for (int i = 0; i < samples; i++) {
|
||||
array[i] = analogRead(SALT_PIN);
|
||||
delay(2);
|
||||
}
|
||||
std::sort(array, array + samples);
|
||||
for (int i = 0; i < samples; i++) {
|
||||
if (i == 0 || i == samples - 1)continue;
|
||||
humi += array[i];
|
||||
}
|
||||
humi /= samples - 2;
|
||||
return humi;
|
||||
}
|
||||
|
||||
uint16_t readSoil() //Soil Capacitance: This code came from the LilyGo documentation.
|
||||
{
|
||||
uint16_t soil = analogRead(SOIL_PIN);
|
||||
return map(soil, 0, 4095, 100, 0);
|
||||
}
|
||||
|
||||
float readBattery() //Battery Voltage: This code came from the LilyGo documentation.
|
||||
{
|
||||
int vref = 1100;
|
||||
uint16_t volt = analogRead(BAT_ADC);
|
||||
float battery_voltage = ((float)volt / 4095.0) * 2.0 * 3.3 * (vref);
|
||||
return battery_voltage;
|
||||
}
|
||||
void loop() {
|
||||
}
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// LILYGO HIGROW SENSOR MODULE
|
||||
//
|
||||
|
||||
|
||||
#define I2C_SDA 25
|
||||
#define I2C_SCL 26
|
||||
#define DHT12_PIN 16
|
||||
#define BAT_ADC 33
|
||||
#define SALT_PIN 34
|
||||
#define SOIL_PIN 32
|
||||
#define BOOT_PIN 0
|
||||
#define USER_BUTTON 35
|
||||
#define DS18B20_PIN 21
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <fdrs_sensor.h>
|
||||
#include <BH1750.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
BH1750 lightMeter(0x23); //0x23
|
||||
Adafruit_BME280 bmp; //0x77
|
||||
RTC_DATA_ATTR int the_count = 0;
|
||||
|
||||
void setup() {
|
||||
|
||||
//Init Sensors
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
while (!bmp.begin()) {
|
||||
//Serial.println("bmp");
|
||||
delay(10);
|
||||
}
|
||||
|
||||
if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
|
||||
Serial.println(F("BH1750 Advanced begin"));
|
||||
} else {
|
||||
Serial.println(F("Error initialising BH1750"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loadData() {
|
||||
float s_battery = readBattery();
|
||||
float bme_temp = bmp.readTemperature();
|
||||
float bme_pressure = (bmp.readPressure() / 100.0F);
|
||||
//float bme_altitude = bmp.readAltitude(1013.25);
|
||||
float bme_humidity = bmp.readHumidity();
|
||||
float s_soil = readSoil();
|
||||
float s_salt = readSalt();
|
||||
while (! lightMeter.measurementReady()) {
|
||||
delay(10);
|
||||
}
|
||||
float lux = lightMeter.readLightLevel();
|
||||
the_count++;
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Temp: " + String(bme_temp));
|
||||
Serial.println("Humidity: " + String(bme_humidity));
|
||||
Serial.println("Light: " + String(lux));
|
||||
Serial.println("Pressure: " + String(bme_pressure));
|
||||
Serial.println("Salt: " + String(s_salt));
|
||||
Serial.println("Soil: " + String(s_soil));
|
||||
Serial.println("Voltage: " + String(s_battery));
|
||||
Serial.println("Count: " + String(the_count));
|
||||
|
||||
loadFDRS(bme_temp, TEMP_T);
|
||||
|
||||
loadFDRS(bme_humidity, HUMIDITY_T);
|
||||
|
||||
|
||||
loadFDRS(lux, LIGHT_T);
|
||||
loadFDRS(bme_pressure, PRESSURE_T);
|
||||
loadFDRS(s_salt, SOILR_T);
|
||||
loadFDRS(s_soil, SOIL_T);
|
||||
loadFDRS(s_battery, VOLTAGE_T);
|
||||
loadFDRS(float(the_count), IT_T);
|
||||
|
||||
}
|
||||
|
||||
uint32_t readSalt() //Soil Electrodes: This code came from the LilyGo documentation.
|
||||
{
|
||||
uint8_t samples = 120;
|
||||
uint32_t humi = 0;
|
||||
uint16_t array[120];
|
||||
for (int i = 0; i < samples; i++) {
|
||||
array[i] = analogRead(SALT_PIN);
|
||||
delay(2);
|
||||
}
|
||||
std::sort(array, array + samples);
|
||||
for (int i = 0; i < samples; i++) {
|
||||
if (i == 0 || i == samples - 1)continue;
|
||||
humi += array[i];
|
||||
}
|
||||
humi /= samples - 2;
|
||||
return humi;
|
||||
}
|
||||
|
||||
uint16_t readSoil() //Soil Capacitance: This code came from the LilyGo documentation.
|
||||
{
|
||||
uint16_t soil = analogRead(SOIL_PIN);
|
||||
return map(soil, 0, 4095, 100, 0);
|
||||
}
|
||||
|
||||
float readBattery() //Battery Voltage: This code came from the LilyGo documentation.
|
||||
{
|
||||
int vref = 1100;
|
||||
uint16_t volt = analogRead(BAT_ADC);
|
||||
float battery_voltage = ((float)volt / 4095.0) * 2.0 * 3.3 * (vref);
|
||||
return battery_voltage;
|
||||
}
|
||||
void loop() {
|
||||
}
|
@ -1,45 +1,45 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Multifunction ESP8266 Sensor Board by Phil Grant
|
||||
//
|
||||
// https://github.com/gadjet/Multifunction-ESP8266-Sensor-board
|
||||
//
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <Adafruit_AHT10.h>
|
||||
#include <fdrs_sensor.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
|
||||
}
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Multifunction ESP8266 Sensor Board by Phil Grant
|
||||
//
|
||||
// https://github.com/gadjet/Multifunction-ESP8266-Sensor-board
|
||||
//
|
||||
|
||||
#include "sensor_setup.h"
|
||||
#include <Adafruit_AHT10.h>
|
||||
#include <fdrs_sensor.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
|
||||
}
|