After a bit of head scratching, I realised I'd need to charge the capacitor from another pin via a diode or else when the pin goes low again, the charge will be lost back to the MCU. I was also worried that the act of reading the capacitor using the analogRead() function would also discharge the device and it took a bit of trial and error to select a capacitor that was big enough such that it did not discharge too quickly. In an ideal world it would not discharge at all, until it rains, of course.
The other thing that caused slight confusion was the 'sharp' saw tooth pattern on the 'scope until I realised that the same thing was happening - the 'scope probe was also absorbing charge from the capacitor:
The two low flat spots in the graph above show where I tested the rain gauge. It works!Since the capacitor selected is 10 micro Farads, the energy wasted can be calculated:
... and the average power, and average current = 3.2 uA ....... Nothing to worry about! It's probably more like 1.0 uA due to the fact that the capacitor does not discharge to zero unless it rains.
GOAT INDUSTRIES
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.