I am trying to work around the limitations of the ATmega32u4's external interrupts to data log.
Remotely gather data on water flow over 1 month period using no more than two 8,000mAH LiPo Batteries. Arduino counts number of pulses for 1 second and writes to the SD card with a timestamp. No data is written when flow is zero. The monitored system will have several hours of no flow, where the sensor can "sleep" to conserve power. The first 8-10 seconds of the flow data after flow is detected is critical with the next 30min to 4 hours of flow less critical.
What's Worked So Far:
- With an arduino micro (ATmega32u4), Adafruit SD breakout, hall effect flow sensor, and two LiPo 8,000mAH batteries I am able to log flow data for about 6 days before the batteries die. Pin 7 (Int4) is used monitor flow and count pulses every second, logging to SD card while water is flowing.
- Insufficient battery life (too much power consumption).
- Timestamp reference is based on when the arduino was compiled. The Micro is compiled, then unplugged from laptop, transported to monitoring site and plugged into sensor/battery.
- Sensor consumes 25mA at idle state (plan to replace sensor with 8uA version).
What's been tried so far:
- Moved the sensor to Pin 2 (Int0) and direct powered sensor from battery to allow the arduino to enter power down state and wake to record on flow start.
- Added ChronoDot for time stamp accuracy but this means the sensor has to move back to Pin 7(Int4) because the RTC uses Pins 2&3 (SCL and SDA). Int4 only works when arduino is awake or in "Idle" mode (Pin Change); or a "LOW" state when in power down mode. Sensor does not pull Pin 7 "LOW" long enough for wakeup from power down mode.
- Added a second arduino to act as a trigger to the first arduino. Arduino #1 has the SD Card, RTC, input from arduino #2, and sensor input. Arduino #2 has only a sensor input attached to Int0 and output to Arduino #1. Thinking is that Arduino #2 wakes when flow starts, setting Pin 4 to low which Pin 7 on Arduino #1 senses and wakes up Arduino #1. Arduino #2 would fall back asleep waiting for flow start again, while Arduino #1 records pulses from sensor on an open digital pin while there is flow. I can get Arduino #2 to wake up Arduino #1 but, I have not been able to get Arduino #1 to record data (i.e. count pulses) after it wakes up.
- Am I on the right track by using the second Arduino as a "Watchdog"... or is there another way?
- Assuming the second Arduino is the path forward, how do I record the data on the first arduino? I've seen code examples that count "pulses" without an interrupt, but they are geared toward button presses, which tend to be slow events. I don't see how that would work here. Seems like I could miss pulse counts do to speed, or the program would hang if sensor stops on a "High" signal.