Clear all

[Solved / Archived] Witty Pi 4 - how to use voltage reading

4 Posts
3 Users
Posts: 2
New Member
Topic starter

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

Posted : 10/04/2024 10:10 pm
Topic Tags
Posts: 338
Member Admin

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 file, you can find the get_input_voltage() function, which gets the input value in this way. You can take it as an example:


Posted : 11/04/2024 10:28 am
Posts: 2
New Member
Topic starter

@admin thank you so much! this worked perfectly for my uses 🙂

Posted : 14/04/2024 5:21 am
Posts: 33
Eminent Member

Here's a full example too:

Posted : 20/04/2024 10:36 am
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.