Hi, I'm working with a Witty Pi 4 and Raspberry Pi 4 Model B. I'm new to working with microcontrollers and Pi's, so please excuse any weird terminology.
I'm wondering how I can access the voltage reading from the Witty Pi in live time and say, print it to a Node.js server. Is this possible? Please help<3
The input voltage is stored in two I2C registers with index 1 and 2. This information can be found in the list on page 38 in the user manual.
Witty Pi 4 emulates one I2C device and connects it to Raspberry Pi's I2C bus #1. The I2C device has address 0x08.
If you read out the value of I2C register #1 and #2, you can caculate the input voltage. For example, assume register #1 has value 0x09 (9) and register #2 has value 0x19 (25), then the input voltage is 9+25/100=9.25V
In the utilities.sh file, you can find the get_input_voltage() function, which gets the input value in this way. You can take it as an example: https://github.com/uugear/Witty-Pi-4/blob/main/Software/wittypi/utilities.sh#L526-L531
@admin thank you so much! this worked perfectly for my uses 🙂
Here's a full example too: https://gist.github.com/mmoollllee/46aa20417576cd3eebb4d3fba16bc4e0