Davis wind vane, anemometer and rain gauge I2C slave interface with the rp2040 (raspberry pi pico).
While hooking my Davis wind vane, anemometer and rain gauge to another-weather-station-project built with a raspberry pi zero, I stumbled into these issues:
- wind vane is analog, so an ADC is needed
- anemometer and rain gauge needs interrupt-driven GPIOs to properly handle the "clicks" from the sensor, and the raspberry hasn't a decent IRQ handling
So what? Since I2C is already used for other sensors (temp, pm25, whatever) why no "convert" the Davis stuff to I2C ? Here enters the pico, which is also an execuse to play with the pico-sdk.
Since the whole system will be running from battery, I tried to reduce the power consumption of the pico, which normally draws ~23mA. By reducing clock speeds to 12Mhz (who needs 133Mhz???) for both ADC and CPU this little gadget now consumes a little less than 6mA which is ok for me, without having to dig into sleep modes.
Initial experiments with sleep gave me some issues with I2C because the I2C interrupts where disabled. At same time unmasking them caused the pico to not really sleep because of the I2C bus activity (there're other sensors on it). So the solution was to add another wire to signal the pico to wake up, perform I2C exchanges and send back to sleep... too complicated, that's why I choose to lower the clocks and disable not needed ones.
Please note that I'm neither a C/C++ dev nor an embedded developer, just playing around.
Davis anemometer on arduino Davis wind sensor schematics, example arduino code
Pico Examples Examples for several things, including I2C slave, sleep, etc
Pico Extras Libs not yet in SDK, like sleep, clocks stuff, etc
Davis derived variables application note Several derived variables, including how they calculate rain rate