-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd2e3b3
commit 2c1b378
Showing
3 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import time | ||
from pimoroni_yukon import Yukon | ||
|
||
""" | ||
read the internal sensors of Yukon. | ||
""" | ||
|
||
# Constants | ||
SLEEP = 0.5 # The time to sleep between each reading | ||
|
||
# Variables | ||
yukon = Yukon() # A new Yukon object | ||
|
||
# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) | ||
try: | ||
# Loop until the BOOT/USER button is pressed | ||
while not yukon.is_boot_pressed(): | ||
|
||
# Read Yukon's voltage sensors | ||
voltage_in = yukon.read_input_voltage() | ||
voltage_out = yukon.read_output_voltage() | ||
|
||
# Read Yukon's current sensor, but only if the input voltage | ||
# is high enough to turn it on, otherwise set the value to zero | ||
current = yukon.read_current() if voltage_in > 2.5 else 0.0 | ||
|
||
# Read Yukon's temperature sensor | ||
temperature = yukon.read_temperature() | ||
|
||
# Print out the pin states in a nice format | ||
print(f"Vin = {voltage_in} V", end=", ") | ||
print(f"Vout = {voltage_out} V", end=", ") | ||
print(f"Cur = {current} A", end=", ") | ||
print(f"Temp = {temperature} °C") | ||
|
||
time.sleep(SLEEP) # Sleep for a number of seconds | ||
|
||
finally: | ||
# Put the board back into a safe state, regardless of how the program may have ended | ||
yukon.reset() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters