Loom 4 v4.5
Arduino library for Internet of Things Rapid Prototyping in environmental sensing
Loading...
Searching...
No Matches
Loom_TippingBucket.h
1#include <Wire.h>
2#include <deque>
3
4#include "Module.h"
5#include "Loom_Manager.h"
6#include "../Loom_Hypnos/Loom_Hypnos.h"
7
8#define COUNTER_ADDRESS 0x32 // I2C Counter address
9#define ONE_HOUR_UNIX 3600 // Number of seconds in one hour of unix time
10
11enum COUNTER_TYPE{
12 I2C,
13 MANUAL
14};
15
22 protected:
23 void power_up() override {};
24 void power_down() override {};
25
26 void initialize() override;
27 void package() override;
28 void measure() override;
29 public:
30
31 /* Constructor for an I2C based tipping bucket*/
32 Loom_TippingBucket(Manager& man, COUNTER_TYPE type, float inchesPerTip = 0.01);
33
34 /* Set an instance of the Hypnos inside the tipping bucket class so we can read RTC data*/
35 void setHypnosInstance(Loom_Hypnos& hypnos) { this->hypnosInst = &hypnos; };
36
37 /* Increase the tip count variable by one */
38 void incrementCount() { tipCount++; };
39 private:
40 Manager* manInst = nullptr; // Instance of the manager
41 unsigned long tipCount = 0; // The number of tips accumulated by the counter
42
43 /* Hourly Tips Tracker*/
44 Loom_Hypnos* hypnosInst = nullptr; // Instance of the hypnos for using RTC
45 unsigned long hourlyTips = 0; // Number of tips recorded in the last hour
46 const float inchesPerTip; //
47 std::deque<uint32_t> times; // Track the UNIX times of each log to be able to determine when we want to shift our double ended queue
48 std::deque<unsigned long> tips; // Track the number of total tips per each sample
49 unsigned long lastTipCount = 0;
50
51 float tipsToInches(unsigned long tips); // Convert the number of tips of a bucket to inches of rainfall
52};
Definition: Loom_Hypnos.h:70
Definition: Loom_TippingBucket.h:21
Definition: Loom_Manager.h:18
Definition: Module.h:30