diff --git a/examples/Sensor_Examples/CapacitiveSoil/CapacitiveSoil.ino b/examples/Sensor_Examples/CapacitiveSoil/CapacitiveSoil.ino new file mode 100644 index 0000000..406f639 --- /dev/null +++ b/examples/Sensor_Examples/CapacitiveSoil/CapacitiveSoil.ino @@ -0,0 +1,21 @@ +// FARM DATA RELAY SYSTEM +// +// CAPACITIVE SOIL MOISTURE SENSOR MODULE +// +// Developed by Timm Bogner (bogner1@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA. +// Connect sensor to the analog pin of the ESP (A0). +// + +#include "fdrs_sensor_config.h" +#include +void setup() { + Serial.begin(115200); + beginFDRS(); + delay(50); //let the sensor warm up +} +void loop() { + uint16_t s = analogRead(0); + loadFDRS(s, SOIL_T); + sendFDRS(); + sleepFDRS(1800); +} diff --git a/examples/Sensor_Examples/CapacitiveSoil/fdrs_sensor_config.h b/examples/Sensor_Examples/CapacitiveSoil/fdrs_sensor_config.h new file mode 100644 index 0000000..f9aea65 --- /dev/null +++ b/examples/Sensor_Examples/CapacitiveSoil/fdrs_sensor_config.h @@ -0,0 +1,33 @@ +// FARM DATA RELAY SYSTEM +// +// Sensor Configuration + +#include + +#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 DEEP_SLEEP +#define POWER_CTRL 14 +#define FDRS_DEBUG + +//SPI Configuration -- Needed only on chipsets with multiple SPI interfaces (ESP32) +#define SPI_SCK 5 +#define SPI_MISO 19 +#define SPI_MOSI 27 + +//LoRa Configuration +#define LORA_SS 18 +#define LORA_RST 14 +#define LORA_DIO0 26 +//433E6 for Asia +//866E6 for Europe +//915E6 for North America +//#define LORA_BAND 915E6 // LoRa Frequency Band +//#define LORA_SF 7 // LoRa Spreading Factor +//#define LORA_TXPWR 17 // LoRa TX power in dBm (+2dBm - +20dBm), default is +17dBm. Lower power = less battery use +//#define LORA_ACK // Uncomment to enable request for LoRa ACKs at cost of increased battery usage +//#define LORA_ACK_TIMEOUT 400 // ms timeout waiting for LoRa ACKs (if enabled). Wouldn't go less than 200ms +//#define LORA_RETRIES 2 // [0 - 3] When ACK enabled, number of sensor node tx retries when ACK not received or invalid CRC diff --git a/examples/Sensor_Examples/FrequencyCounter/FrequencyCounter.ino b/examples/Sensor_Examples/FrequencyCounter/FrequencyCounter.ino new file mode 100644 index 0000000..3dc229c --- /dev/null +++ b/examples/Sensor_Examples/FrequencyCounter/FrequencyCounter.ino @@ -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_sensor_config.h" +#include + + +#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 = 17; +volatile uint16_t Freq1 = 0; +static uint16_t FreqOut1; + +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 +} diff --git a/examples/Sensor_Examples/FrequencyCounter/fdrs_sensor_config.h b/examples/Sensor_Examples/FrequencyCounter/fdrs_sensor_config.h new file mode 100644 index 0000000..734e350 --- /dev/null +++ b/examples/Sensor_Examples/FrequencyCounter/fdrs_sensor_config.h @@ -0,0 +1,33 @@ +// FARM DATA RELAY SYSTEM +// +// Sensor Configuration + +#include + +#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 + +//SPI Configuration -- Needed only on chipsets with multiple SPI interfaces (ESP32) +#define SPI_SCK 5 +#define SPI_MISO 19 +#define SPI_MOSI 27 + +//LoRa Configuration +#define LORA_SS 18 +#define LORA_RST 14 +#define LORA_DIO0 26 +//433E6 for Asia +//866E6 for Europe +//915E6 for North America +//#define LORA_BAND 915E6 // LoRa Frequency Band +//#define LORA_SF 7 // LoRa Spreading Factor +//#define LORA_TXPWR 17 // LoRa TX power in dBm (+2dBm - +20dBm), default is +17dBm. Lower power = less battery use +//#define LORA_ACK // Uncomment to enable request for LoRa ACKs at cost of increased battery usage +//#define LORA_ACK_TIMEOUT 400 // ms timeout waiting for LoRa ACKs (if enabled). Wouldn't go less than 200ms +//#define LORA_RETRIES 2 // [0 - 3] When ACK enabled, number of sensor node tx retries when ACK not received or invalid CRC