Farm-Data-Relay-System/examples/Sensor_Examples/TippingBucket/TippingBucket.ino

39 lines
826 B
Arduino
Raw Normal View History

2022-06-18 00:56:39 +00:00
// FARM DATA RELAY SYSTEM
//
// TIPPING BUCKET RAINFALL SENSOR MODULE
//
2022-07-05 14:02:01 +00:00
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
2022-06-18 00:56:39 +00:00
#define REED_PIN 2
2022-07-05 14:02:01 +00:00
#include "sensor_setup.h"
#include <fdrs_sensor.h>
2022-06-18 00:56:39 +00:00
unsigned int theCount = 0;
unsigned long lastTrigger = 0;
boolean clicked = false;
// Checks if motion was detected, sets LED HIGH and starts a timer
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("CLICK.");
Serial.println(theCount);
clicked = false;
loadFDRS(theCount, RAINFALL_T);
sendFDRS();
}
}