Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensor Data #65

Open
emersonsc opened this issue Feb 14, 2023 · 2 comments
Open

Sensor Data #65

emersonsc opened this issue Feb 14, 2023 · 2 comments

Comments

@emersonsc
Copy link

Im trying to display the Temp and humidity data using the sensors built in to the Clue, but i tried using the code bellow, but i get an error:
Traceback (most recent call last):
File "code.py", line 7, in
File "adafruit_clue.py", line 930, in
File "adafruit_clue.py", line 195, in init
ValueError: P5 in use

# Write your code here :-)
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import board
from adafruit_pybadger import pybadger
from adafruit_clue import clue
from adafruit_bmp280 import bmp280

temperature = clue.temperature
humidity = clue.humidity

pybadger.badge_background(
    background_color=pybadger.YELLOW,
    rectangle_color=pybadger.BLUE,
    rectangle_drop=0.2,
    rectangle_height=0.6,
)

pybadger.badge_line(
    text="Stingers of Steel", color=pybadger.BLUE, scale=2, padding_above=2
)
pybadger.badge_line(text="Emerson C.", color=pybadger.YELLOW, scale=4, padding_above=4)
pybadger.badge_line(
    text="Mentor / Mechanic", color=pybadger.YELLOW, scale=2, padding_above=2
)
pybadger.badge_line(
    text="Temp: {:.1f} C".format(temperature), color=pybadger.YELLOW, scale=2, padding_above=2
)
pybadger.badge_line(
    text="Humi: {:.1f} %".format(humidity), color=pybadger.YELLOW, scale=2, padding_above=2
)
pybadger.badge_line(
    text="6642", color=pybadger.BLUE, scale=4, padding_above=10
)

display = board.DISPLAY
display.rotation = 180

pybadger.show_custom_badge()

while True:
    
    if pybadger.button.a:
        pybadger.show_qr_code("https://www.facebook.com/stingers6642")
        pybadger.pixels.fill(pybadger.BLUE)
    if pybadger.button.b:
        pybadger.show_custom_badge()
        pybadger.pixels.fill(pybadger.YELLOW)

@emersonsc
Copy link
Author

Is this project dead?

@caternuson
Copy link
Contributor

Only import pybadger here:

from adafruit_pybadger import pybadger
from adafruit_clue import clue

The PyBadge library will auto detect what board is being used and then import any additional libraries as needed.

The second import from the CLUE library is causing hardware that has already been initialized by the PyBadge library (via the first import) to try to be initialized a second time, but the hardware is already in use. That is what is causing the error.

See examples:
https://github.com/adafruit/Adafruit_CircuitPython_PyBadger/blob/main/examples/pybadger_clue_custom_badge.py
https://github.com/adafruit/Adafruit_CircuitPython_PyBadger/blob/main/examples/pybadger_clue_custom_image_badge.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants