Notifications
Clear all
Topic starter
I've been playing around some with the Witty Pi 5 and have been very happy with it! I was looking for a handy way to read the temperature sensor and RTC from Python. I didn't see anything made specifically for this purpose, so I went ahead and created this module for doing so easily. It also can read & write the other registers. I figured I'd share it here.
You can install it via
pip install wittypi5
and then use it like this:
from wittypi5 import WittyPi5, Register
wp5 = WittyPi5()
wp5.open()
# Status readings
print(f"Firmware: {wp5.firmware_version}")
print(f"V_USB: {wp5.v_usb} V, V_IN: {wp5.v_in} V")
print(f"Last startup: {wp5.action_reason_startup.name}")
print(f"Last shutdown: {wp5.action_reason_shutdown.name}")
# RTC and temperature
print(f"RTC: {wp5.datetime}"). # returns a datetime object
print(f"Temperature: {wp5.temp_c:.2f}°C ({wp5.temp_f:.2f}°F)"). # returns temperature as a float
# Sync RTC with system time
wp5.sync_rtc_with_local(). # takes datetime.now() and write that to the RTC
# Raw register access
state = wp5.read_register(Register.RASPBERRY_PI_STATE)
# Config (read/write)
wp5.config_led_on_time = 100 # LED on for 100 ms
wp5.close()
It uses the smb2 Python library to read & write the registers directly over I2C, rather than calling CLI commands & parsing them.
Source code at: https://github.com/joshburnett/wittypi5
Hope other people find it useful. 😊
Posted : 01/03/2026 4:07 am
uugear reacted
Thanks for sharing 🙂
Posted : 01/03/2026 9:40 am
