Battery Monitor Sample
This sample demonstrates measuring battery Voltage.
- 1.Download the sample code from https://github.com/Turta-io/RCDriverHAT/blob/master/Samples/Python/Battery_Monitor.py
- 2.Copy the sample code to a folder on the Raspberry Pi.
- 3.Open terminal, and then go to the folder you copied the sample.
- 4.Run the sample with the following command:
#This sample demonstrates measuring battery Voltage.
#Install RC Driver HAT library with "pip3 install turta-rcdriverhat"
from time import sleep
from turta_rcdriverhat import Turta_RCDriver
rc = Turta_RCDriver.RCDriver()
#Activate fan at 50% speed
#Read battery Voltage
voltage = rc.read_voltage()
#Print the reading
print("Battery...: " + str(voltage) + "V")
#Exit on CTRL+C
When you run the sample, it prints the Voltage applied to the power in port. The example output should be like this:
To stop the Python script, just press CTRL + C.