push lib
This commit is contained in:
@ -0,0 +1,29 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// AHT20 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <Adafruit_AHTX0.h>
|
||||
#include <fdrs_node.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
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,28 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// BME280 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <fdrs_node.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
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +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 "fdrs_node_config.h"
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include <fdrs_node.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
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,26 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// CAPACITIVE SOIL MOISTURE SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
// Connect the sensor to an analog pin of your MCU.
|
||||
//
|
||||
|
||||
#define SOIL_PIN 36 // Ignored on ESP8266
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
delay(50); //let the sensor warm up
|
||||
}
|
||||
void loop() {
|
||||
#ifdef ESP8266
|
||||
uint16_t s = analogRead(0);
|
||||
#else
|
||||
uint16_t s = analogRead(SOIL_PIN);
|
||||
#endif
|
||||
loadFDRS(s, SOIL_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(60 * 5);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 21 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
//#define USE_ESPNOW
|
||||
#define USE_LORA
|
||||
|
||||
//#define USE_LR // Enables 802.11LR on ESP32 ESP-NOW devices
|
||||
|
||||
//#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 // ESP32 SX1276 (TTGO)
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
#define LORA_BUSY 33
|
||||
//#define USE_SX126X
|
||||
|
||||
//#define CUSTOM_SPI
|
||||
#define LORA_SPI_SCK 5
|
||||
#define LORA_SPI_MISO 19
|
||||
#define LORA_SPI_MOSI 27
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
||||
|
||||
//#define USE_OLED
|
||||
#define OLED_HEADER "FDRS"
|
||||
#define OLED_SDA 4
|
||||
#define OLED_SCL 15
|
||||
#define OLED_RST 16
|
@ -0,0 +1,42 @@
|
||||
// Example testing sketch for various DHT humidity/temperature sensors
|
||||
// Written by ladyada, public domain
|
||||
|
||||
// Modified by Timm Bogner for Farm Data Relay System -- Untested because I don't have a DHT sensor onhand.
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
#include "DHT.h"
|
||||
|
||||
#define DHTPIN 2 // Digital pin connected to the DHT sensor
|
||||
|
||||
// Uncomment whatever type you're using!
|
||||
//#define DHTTYPE DHT11 // DHT 11
|
||||
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
|
||||
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
|
||||
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
DBG("DHTxx Sketch!");
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Wait a few seconds between measurements.
|
||||
// Reading temperature or humidity takes about 250 milliseconds!
|
||||
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
|
||||
float h = dht.readHumidity();
|
||||
// Read temperature as Celsius (the default)
|
||||
float t = dht.readTemperature();
|
||||
|
||||
// Check if any reads failed and exit early (to try again).
|
||||
if (isnan(h) || isnan(t)) {
|
||||
DBG("Failed to read from DHT sensor!");
|
||||
return;
|
||||
}
|
||||
loadFDRS(h, HUMIDITY_T);
|
||||
loadFDRS(t, TEMP_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(10); //Sleep time in seconds
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,27 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// DS18B20 SENSOR MODULE
|
||||
//
|
||||
|
||||
#define ONE_WIRE_BUS 13 //Pin that the DS18B20 is connected to
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
#include <OneWire.h>
|
||||
#include <DallasTemperature.h>
|
||||
|
||||
OneWire oneWire(ONE_WIRE_BUS);
|
||||
DallasTemperature sensors(&oneWire);
|
||||
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
sensors.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
sensors.requestTemperatures(); // Send the command to get temperatures
|
||||
float tempC = sensors.getTempCByIndex(0);
|
||||
loadFDRS(tempC, TEMP_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(60);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,51 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Gypsum-based Soil Moisture Sensor
|
||||
//
|
||||
// Uses a Ezsbc.com Dev board, a Kisssys moisture sensor board, and a DS3231 RTC.
|
||||
// Deep sleep current is less than 20µA.
|
||||
// https://www.printables.com/model/176752-gypson-water-sensor
|
||||
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
|
||||
|
||||
#define BUTTON_PIN_BITMASK 0x100000000 // 2^32 in hex the pin that is connected to SQW
|
||||
#define CLOCK_INTERRUPT_PIN 32 // yep same pin
|
||||
|
||||
|
||||
const int FreqIn1 = 5;
|
||||
volatile uint16_t Freq1 = 0;
|
||||
static uint16_t FreqOut1;
|
||||
|
||||
ICACHE_RAM_ATTR void SensorInt1() {
|
||||
// If the pin is Rising, increment counter
|
||||
Freq1++;
|
||||
};
|
||||
|
||||
|
||||
void readFrequency() {
|
||||
// for one second we count the pulses and get our moisture reading in pps
|
||||
attachInterrupt(FreqIn1, SensorInt1, RISING);
|
||||
delay(1000); // delay in ms is 1 seconds-- not the most accurate way to do this but more than accurate enough for our low frequency and 10 second read
|
||||
FreqOut1 = Freq1; // our frequency * 10
|
||||
detachInterrupt(FreqIn1); // only reading once so turn off the interrupt
|
||||
|
||||
}
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
pinMode(FreqIn1, INPUT);
|
||||
Freq1 = 0;
|
||||
delay(50);
|
||||
readFrequency();
|
||||
//DBG("Frequency = " + String(FreqOut1));
|
||||
loadFDRS(FreqOut1, SOIL_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(1800); //Sleep time in seconds
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// nuttin honey
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 23 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
#define POWER_CTRL 22
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,172 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Generic GPS Sensor
|
||||
//
|
||||
// Developed by Sascha Juch (sascha.juch@gmail.com).
|
||||
// Reads in GPS data from serial and sends latitude, longitude and altitude to a gateway.
|
||||
//
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
|
||||
#define SERIAL1_RX 13 // TX pin of GPS sensor
|
||||
#define SERIAL1_TX 12 // RX pin of GPS sensor
|
||||
#define MAX_NMEA_LENGTH 82 //maximum allowed length of a NMEA 0183 sentences.
|
||||
|
||||
char currentNMEALine[MAX_NMEA_LENGTH];
|
||||
|
||||
void setup() {
|
||||
// ToDo: This works well on a board with a second hardware serial port like the ESP32. But what if there is no hardware serial on the device?
|
||||
// Unfortunately I do not have a GPS (standalone) sensor atm with which I could test. Help and advice appreciated.
|
||||
Serial1.begin(9600, SERIAL_8N1, SERIAL1_RX, SERIAL1_TX);
|
||||
|
||||
beginFDRS();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// read in line by line of the NMEA input and get rid of trailing whitespaces
|
||||
Serial1.readBytesUntil('\n', currentNMEALine, MAX_NMEA_LENGTH);
|
||||
trimwhitespace(currentNMEALine);
|
||||
|
||||
// we are only interested in GPGGA (U-Blox M6N) or GNGGA (U-Blox M8N)lines.
|
||||
if (startsWith(currentNMEALine, "$GNGGA") || startsWith(currentNMEALine, "$GPGGA")) {
|
||||
|
||||
DBG(currentNMEALine);
|
||||
|
||||
// just in case someone needs UTC, quality or #satelites, just uncomment and do what you have to do with them. :)
|
||||
//char * gpsUTC = getNthValueOf(currentNMEALine, ',', 1);
|
||||
char * gpsLatitude = getNthValueOf(currentNMEALine, ',', 2);
|
||||
char * gpsLatitudeOrientation = getNthValueOf(currentNMEALine, ',', 3);
|
||||
char * gpsLongitude = getNthValueOf(currentNMEALine, ',', 4);
|
||||
char * gpsLongitudeOrientation = getNthValueOf(currentNMEALine, ',', 5);
|
||||
//char * gpsQuality = getNthValueOf(currentNMEALine, ',', 6);
|
||||
char * gpsAltitude = getNthValueOf(currentNMEALine, ',', 7);
|
||||
//char * gpsNoOfSatelites = getNthValueOf(currentNMEALine, ',', 9);
|
||||
|
||||
// convert latitude and altitude to decimal degree values (as used in most maps programs)
|
||||
// negative values mean "S" or "W", positive values mean "N" and "E"
|
||||
float latitude = convertGpsCoordinates(atof(gpsLatitude), gpsLatitudeOrientation);
|
||||
float longitude = convertGpsCoordinates(atof(gpsLongitude), gpsLongitudeOrientation);
|
||||
|
||||
float altitude = atof(gpsAltitude);
|
||||
|
||||
/*
|
||||
loadFDRS(latitude, HUMIDITY_T);
|
||||
loadFDRS(longitude, TEMP_T);
|
||||
loadFDRS(altitude, TEMP2_T);
|
||||
*/
|
||||
|
||||
// extended sensor types - not officially atm!
|
||||
loadFDRS(latitude, LATITUDE_T);
|
||||
loadFDRS(longitude, LONGITUDE_T);
|
||||
loadFDRS(altitude, ALTITUDE_T);
|
||||
if(sendFDRS()){
|
||||
DBG("Big Success!");
|
||||
} else {
|
||||
DBG("Nope, not so much.");
|
||||
}
|
||||
sleepFDRS(10); //Sleep time in seconds
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// cudos for the trimming function go to: https://stackoverflow.com/questions/122616/how-do-i-trim-leading-trailing-whitespace-in-a-standard-way
|
||||
// Thanks! That was a time saver. :)
|
||||
// Note: This function returns a pointer to a substring of the original string.
|
||||
// If the given string was allocated dynamically, the caller must not overwrite
|
||||
// that pointer with the returned value, since the original pointer must be
|
||||
// deallocated using the same allocator with which it was allocated. The return
|
||||
// value must NOT be deallocated using free() etc.
|
||||
char *trimwhitespace(char *str)
|
||||
{
|
||||
char *end;
|
||||
|
||||
// Trim leading space
|
||||
while(isspace((unsigned char)*str)) str++;
|
||||
|
||||
if(*str == 0) // All spaces?
|
||||
return str;
|
||||
|
||||
// Trim trailing space
|
||||
end = str + strlen(str) - 1;
|
||||
while(end > str && isspace((unsigned char)*end)) end--;
|
||||
|
||||
// Write new null terminator character
|
||||
end[1] = '\0';
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
// check, if a given char* fullString starts with a given char* startString.
|
||||
// If that's the case, return true, false otherwise
|
||||
bool startsWith(const char *fullString, const char *startString)
|
||||
{
|
||||
if (strncmp(fullString, startString, strlen(startString)) == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Cudos for the substr function go to: https://www.techiedelight.com/implement-substr-function-c/
|
||||
// Thanks! That helped a lot :)
|
||||
// Following function extracts characters present in `src`
|
||||
// between `m` and `n` (excluding `n`)
|
||||
char* substr(const char *src, int m, int n)
|
||||
{
|
||||
// get the length of the destination string
|
||||
int len = n - m;
|
||||
|
||||
// allocate (len + 1) chars for destination (+1 for extra null character)
|
||||
char *dest = (char*)malloc(sizeof(char) * (len + 1));
|
||||
|
||||
// extracts characters between m'th and n'th index from source string
|
||||
// and copy them into the destination string
|
||||
for (int i = m; i < n && (*(src + i) != '\0'); i++)
|
||||
{
|
||||
*dest = *(src + i);
|
||||
dest++;
|
||||
}
|
||||
|
||||
// null-terminate the destination string
|
||||
*dest = '\0';
|
||||
|
||||
// return the destination string
|
||||
return dest - len;
|
||||
}
|
||||
|
||||
// returns the value of the n-th occurance within a delimiter-separated string
|
||||
char * getNthValueOf (char *inputString, const char delimiter, uint8_t index) {
|
||||
uint8_t i = 0;
|
||||
uint8_t currentIndex = 0;
|
||||
uint8_t startOfValue = 0;
|
||||
uint8_t endOfValue = 0;
|
||||
|
||||
while (i < strlen(inputString) && inputString[i] && currentIndex < index) {
|
||||
if (inputString[i] == delimiter) {
|
||||
currentIndex++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
startOfValue = i;
|
||||
|
||||
while (i < strlen(inputString) && inputString[i] && currentIndex <= index) {
|
||||
if (inputString[i] == delimiter) {
|
||||
currentIndex++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
endOfValue = i;
|
||||
|
||||
char* valueAtIndex = substr(inputString, startOfValue, endOfValue-1);
|
||||
|
||||
return valueAtIndex;
|
||||
}
|
||||
|
||||
// convert NMEA0183 degrees minutes coordinates to decimal degrees
|
||||
float convertGpsCoordinates(float degreesMinutes, char* orientation) {
|
||||
double gpsMinutes = fmod((double)degreesMinutes, 100.0);
|
||||
uint8_t gpsDegrees = degreesMinutes / 100;
|
||||
double decimalDegrees = gpsDegrees + ( gpsMinutes / 60 );
|
||||
if (strcmp(orientation, "W") == 0 || strcmp(orientation, "S") == 0) {
|
||||
decimalDegrees = 0 - decimalDegrees;
|
||||
}
|
||||
return decimalDegrees;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x03 //Address of the nearest gateway
|
||||
|
||||
//#define USE_ESPNOW
|
||||
#define USE_LORA
|
||||
//#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 // ESP32 SX1276 (TTGO)
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
#define LORA_BUSY 33
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
||||
|
||||
#define USE_OLED
|
||||
#define OLED_HEADER "FDRS"
|
||||
#define OLED_SDA 4
|
||||
#define OLED_SCL 15
|
||||
#define OLED_RST 16
|
@ -0,0 +1,117 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Gypsum-based Soil Moisture Sensor
|
||||
//
|
||||
// Uses a Ezsbc.com Dev board, a Kisssys moisture sensor board, and a DS3231 RTC.
|
||||
// Deep sleep current is less than 20µA.
|
||||
// https://www.printables.com/model/176752-gypson-water-sensor
|
||||
|
||||
#define DEBUG
|
||||
#define CREDENTIALS
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
#include <RTClib.h>
|
||||
RTC_DS3231 rtc;
|
||||
|
||||
#define BUTTON_PIN_BITMASK 0x100000000 // 2^32 in hex the pin that is connected to SQW
|
||||
#define CLOCK_INTERRUPT_PIN 32 // yep same pin
|
||||
//#define SupplyPin 33 // power to DS3231
|
||||
#define BatteryReadPin 35 // read battey voltage on this pin
|
||||
|
||||
|
||||
const int FreqIn1 = 18; // gpio32
|
||||
const int FreqPower = 19;
|
||||
const int RTCPower = 25;
|
||||
volatile uint16_t Freq1 = 0;
|
||||
static uint16_t FreqOut1;
|
||||
|
||||
void SensorInt1() {
|
||||
// If the pin is Rising, increment counter
|
||||
Freq1++;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
DBG(__FILE__);
|
||||
pinMode(FreqIn1, INPUT);
|
||||
pinMode(CLOCK_INTERRUPT_PIN, INPUT_PULLUP); // On deep sleep the pin needs and external 330k pullup
|
||||
pinMode(RTCPower, OUTPUT); // for the SQW pin to stay high when RTC power is removed
|
||||
digitalWrite(RTCPower, HIGH); // DS3231 needs the SQW pullup removed on the board to
|
||||
pinMode(FreqPower, OUTPUT); // lower the deepsleep current by 60ua's
|
||||
digitalWrite(FreqPower, HIGH);
|
||||
|
||||
Freq1 = 0;
|
||||
delay(50);
|
||||
|
||||
Wire.begin(13, 14); // moved from 21 22 normal I2C pins because it allows me to set these pins to input later
|
||||
if (!rtc.begin()) {
|
||||
DBG("Couldn't find RTC!");
|
||||
Serial.flush();
|
||||
while (1) delay(10);
|
||||
}
|
||||
|
||||
if (rtc.lostPower()) {
|
||||
// this will adjust to the date and time at compilation
|
||||
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
|
||||
}
|
||||
|
||||
rtc.disable32K(); // Don't use this so we shut it down on the board
|
||||
// set alarm 1, 2 flag to false (so alarm 1, 2 didn't happen so far)
|
||||
// if not done, this easily leads to problems, as both register aren't reset on reboot/recompile
|
||||
rtc.clearAlarm(1);
|
||||
rtc.clearAlarm(2);
|
||||
|
||||
// stop oscillating signals at SQW Pin
|
||||
// otherwise setAlarm1 will fail
|
||||
rtc.writeSqwPinMode(DS3231_OFF);
|
||||
|
||||
// turn off alarm 2 (in case it isn't off already)
|
||||
// again, this isn't done at reboot, so a previously set alarm could easily go overlooked
|
||||
rtc.disableAlarm(2);
|
||||
|
||||
|
||||
// for one second we count the pulses and get our moisture reading in pps
|
||||
attachInterrupt(FreqIn1, SensorInt1, RISING);
|
||||
delay(1000); // delay in ms is 1 seconds-- not the most accurate way to do this but more than accurate enough for our low frequency and 10 second read
|
||||
FreqOut1 = Freq1; // our frequency * 10
|
||||
detachInterrupt(FreqIn1); // only reading once so turn off the interrupt
|
||||
|
||||
|
||||
if (rtc.alarmFired(1)) {
|
||||
rtc.clearAlarm(1);
|
||||
Serial.println("Alarm cleared");
|
||||
}
|
||||
|
||||
float supply = analogRead(BatteryReadPin) * .001833;
|
||||
DBG("WaterSensor 1 = " + String(FreqOut1));
|
||||
DBG("Supply Voltage = " + String(supply));
|
||||
|
||||
loadFDRS(FreqOut1, SOIL_T);
|
||||
loadFDRS(supply, VOLTAGE_T);
|
||||
sendFDRS();
|
||||
// Lowers SQW int pin32 every 10 seconds
|
||||
rtc.setAlarm1(DateTime(0, 0, 0, 00, 00, 10), DS3231_A1_Second); //DateTime (year,month,day,hour,min,sec)
|
||||
|
||||
esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK, ESP_EXT1_WAKEUP_ALL_LOW);
|
||||
|
||||
char date[10] = "hh:mm:ss";
|
||||
rtc.now().toString(date);
|
||||
Serial.println(date); // Print the time
|
||||
Serial.println("Going to sleep soon");
|
||||
|
||||
// prepare for low current shutdown
|
||||
digitalWrite(FreqPower, LOW);
|
||||
digitalWrite(RTCPower, LOW);
|
||||
pinMode(13, INPUT);
|
||||
pinMode(14, INPUT);
|
||||
|
||||
esp_deep_sleep_start();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// nuttin honey
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,117 @@
|
||||
// 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 "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
#include <BH1750.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
BH1750 lightMeter(0x23); //0x23
|
||||
Adafruit_BME280 bme; //0x77
|
||||
RTC_DATA_ATTR int the_count = 0;
|
||||
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
|
||||
//Init Sensors
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
// while (!bme.begin()) {
|
||||
// Serial.println("bme");
|
||||
// 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 = bme.readTemperature();
|
||||
// float bme_pressure = (bme.readPressure() / 100.0F);
|
||||
//float bme_altitude = bme.readAltitude(1013.25);
|
||||
// float bme_humidity = bme.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
|
||||
{
|
||||
uint16_t soil = analogRead(SOIL_PIN);
|
||||
return soil;
|
||||
}
|
||||
|
||||
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() {
|
||||
loadData();
|
||||
sendFDRS();
|
||||
sleepFDRS(30);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
#define POWER_CTRL 4
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,45 @@
|
||||
// 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
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,28 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// MLX90614 INFRARED TEMPERATURE SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <Adafruit_MLX90614.h>
|
||||
#include <fdrs_node.h>
|
||||
|
||||
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
|
||||
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
delay(250);
|
||||
DBG("Adafruit MLX90614 test");
|
||||
if (!mlx.begin()) {
|
||||
DBG("Error connecting to MLX sensor. Check wiring.");
|
||||
while (1);
|
||||
};
|
||||
}
|
||||
|
||||
void loop() {
|
||||
loadFDRS(mlx.readAmbientTempC(), TEMP_T);
|
||||
loadFDRS(mlx.readObjectTempC(), TEMP2_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(60); //Sleep time in seconds
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,19 @@
|
||||
# FDRS Sensors
|
||||
Out of date- Needs improvement.
|
||||
| Sensor Name | Maker/Datasheet | Library |
|
||||
| --- | --- | --- |
|
||||
| AHT20 | [ASAIR](http://www.aosong.com/userfiles/files/media/Data%20Sheet%20AHT20.pdf) | [Adafruit](https://github.com/adafruit/Adafruit_AHTX0) |
|
||||
| BME280 | [Bosch](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme280-ds002.pdf) | [Adafruit](https://github.com/adafruit/Adafruit_BME280_Library) |
|
||||
| BMP280 | [Bosch](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf) | [Adafruit](https://github.com/adafruit/Adafruit_BMP280_Library) |
|
||||
| DHT22 | [Aosong](https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf) |[adafruit](https://github.com/adafruit/DHT-sensor-library) |
|
||||
| DS18B20 | [Dallas](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf) | [milesburton](https://github.com/adafruit/Adafruit_AHTX0) |
|
||||
| LilyGo HiGrow | [TTGO](http://www.lilygo.cn/prod_view.aspx?TypeId=50033&Id=1172) |
|
||||
| Multifunction ESP8266 Sensor Board | [Phil Grant](https://github.com/gadjet/Multifunction-ESP8266-Sensor-board) |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
I would like to use this spot as a showcase for open source PCB designs. If **you** have designed a sensor module that runs on either ESP8266 or ESP32, please contact me at timmbogner@gmail.com. I will make a custom sensor sketch, along with a link and description available here.
|
@ -0,0 +1,24 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// SENSIRION SHT20 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
// If you are using the sensor for air monitoring, change SOIL_T to HUMIDITY_T.
|
||||
//
|
||||
#include "DFRobot_SHT20.h"
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
|
||||
DFRobot_SHT20 sht20(&Wire, SHT20_I2C_ADDR);
|
||||
|
||||
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
sht20.initSHT20();
|
||||
}
|
||||
void loop() {
|
||||
loadFDRS(sht20.readHumidity(), SOIL_T);
|
||||
loadFDRS(sht20.readTemperature(), TEMP_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(300); //Sleep time in seconds
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 11 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,67 @@
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_TSL2561_U.h>
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
|
||||
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*
|
||||
Configures the gain and integration time for the TSL2561
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void configureSensor(void)
|
||||
{
|
||||
/* You can also manually set the gain or enable auto-gain support */
|
||||
// tsl.setGain(TSL2561_GAIN_1X); /* No gain ... use in bright light to avoid sensor saturation */
|
||||
// tsl.setGain(TSL2561_GAIN_16X); /* 16x gain ... use in low light to boost sensitivity */
|
||||
tsl.enableAutoRange(true); /* Auto-gain ... switches automatically between 1x and 16x */
|
||||
|
||||
/* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */
|
||||
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); /* fast but low resolution */
|
||||
// tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS); /* medium resolution and speed */
|
||||
// tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS); /* 16-bit data but slowest conversions */
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*
|
||||
Arduino setup function (automatically called at startup)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void setup(void)
|
||||
{
|
||||
beginFDRS();
|
||||
/* Initialise the sensor */
|
||||
//use tsl.begin() to default to Wire,
|
||||
//tsl.begin(&Wire2) directs api to use Wire2, etc.
|
||||
if(!tsl.begin())
|
||||
{
|
||||
DBG("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
|
||||
while(1);
|
||||
}
|
||||
configureSensor();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sensors_event_t event;
|
||||
tsl.getEvent(&event);
|
||||
if (event.light)
|
||||
{
|
||||
DBG(String(event.light) + " lux");
|
||||
loadFDRS(float(event.light), LIGHT_T);
|
||||
sendFDRS();
|
||||
sleepFDRS(10); //Sleep time in seconds
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If event.light = 0 lux the sensor is probably saturated
|
||||
and no reliable data could be generated! */
|
||||
Serial.println("Sensor overload");
|
||||
}
|
||||
delay(250);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
@ -0,0 +1,37 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// TIPPING BUCKET RAINFALL SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
||||
|
||||
#define REED_PIN 2
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
|
||||
unsigned int theCount = 0;
|
||||
unsigned long lastTrigger = 0;
|
||||
boolean clicked = false;
|
||||
|
||||
ICACHE_RAM_ATTR void detectsMovement() {
|
||||
clicked = true;
|
||||
lastTrigger = millis();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
pinMode(REED_PIN, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(REED_PIN), detectsMovement, FALLING);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (clicked && millis() - lastTrigger > 100) {
|
||||
theCount++;
|
||||
Serial.print("DINK.");
|
||||
Serial.println(theCount);
|
||||
clicked = false;
|
||||
loadFDRS(theCount, RAINFALL_T);
|
||||
sendFDRS();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
Reference in New Issue
Block a user