Pin configuration and library error

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Pin configuration and library error

Post by dkanday »

Hi there,

I am trying to configure the Adafruit Clue to work with my microcontroller and print an output based on the digital input being received by the digital IO on Clue. When I start writing up the code I keep getting an error when I add -from adafruit_clue import clue to my code. The error: File"adafruit_clue.py", line x in <module> Import Error: no module named 'neopixel'.
I went into the drive and made sure that the library includes the 2 files: adafruit_clue.py and clue.py in it. What could be the reason for that.
Also I am trying to configure an IO pin how can I know what is the IO pin associated with the pinout on the Clue? Is there a Schematics file available online?

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Pin configuration and library error

Post by mikeysklar »

@dkanday,

The CLUE schematics are available in multiple formats through the download page (Fritzing, Eagle, JPG, etc.)

https://learn.adafruit.com/adafruit-clue/downloads

Make sure you have the neopixel and adafruit_clue libraries placed in the folder of your CIRCUITPY/lib folder. You can use the MPY version to save a bit of space. You do not need to use .py or .mpy extension in the code 'import' process just calling import adafruit_clue is sufficient.

https://circuitpython.org/libraries

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

mikeysklar wrote:@dkanday,

The CLUE schematics are available in multiple formats through the download page (Fritzing, Eagle, JPG, etc.)

https://learn.adafruit.com/adafruit-clue/downloads

Make sure you have the neopixel and adafruit_clue libraries placed in the folder of your CIRCUITPY/lib folder. You can use the MPY version to save a bit of space. You do not need to use .py or .mpy extension in the code 'import' process just calling import adafruit_clue is sufficient.

https://circuitpython.org/libraries

I tried adding the library in the CIRCUITPY/lib folder and still gives me the error. Also when I add this line of code from the example:
"from adafruit_clue import clue" I get the following error on the clue file "adafruit_clue.py, line 956 in <module> "
file "adafruit_clue.py, line 206, in__init__ TypeError: function missing required positional argument #3
Code done running.

Why do I still get this error when I have the library added. I am using the library Bundle v6.x. Do I need to try Bundle v7.x? or there something that I am missing?

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

I have added the following library in the lib folder and below is the snippet of the code
:
import time
import random
import board
from digitalio import DigitalInOut, Direction
import pulseio
from adafruit_clue import clue
from adafruit_esp32spi import adafruit_esp32spi
Attachments
circuitpython_lib folder.png
circuitpython_lib folder.png (59.65 KiB) Viewed 1747 times

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

Also I am getting an error message that in "DigitalInOut" is not defined. But this is defined in the "from digitalio import DigitalInOut, Direction" library which is built into the circuit python library file. the snippet of the code is from the circuitpython example esp32spi_gpio.py. Is there a special library file I would need to add to the code.py for using the IOs?

import time
import random
import board
from digitalio import DigitalInOut, Direction
import pulseio
from adafruit_esp32spi import adafruit_esp32spi


# ESP32SPI Digital and Analog Pin Reads & Writes

# This example targets a Feather M4 or ItsyBitsy M4 as the CircuitPython MCU,
# along with either an ESP32 Feather or ESP32 Breakout as Wi-Fi co-processor.
# You may need to choose different pins for other targets.


def esp_reset_all():
# esp.reset() will reset the ESP32 using its RST pin
# side effect is re-initializing ESP32 pin modes and debug output
esp.reset()
time.sleep(1)
# (re-)set NINA serial debug on ESP32 TX
esp.set_esp_debug(True) # False, True
# (re-)set digital pin modes
esp_init_pin_modes(ESP_D_R_PIN, ESP_D_W_PIN)


def esp_init_pin_modes(din, dout):
# ESP32 Digital Input
esp.set_pin_mode(din, 0x0)

# ESP32 Digital Output (no output on pins 34-39)
esp.set_pin_mode(dout, 0x1)


# M4 R/W Pin Assignments
M4_D_W_PIN = DigitalInOut(board.A1) # digital write to ESP_D_R_PIN
M4_D_W_PIN.direction = Direction.OUTPUT
M4_A_R_PIN = pulseio.PulseIn(board.A0, maxlen=64) # PWM read from ESP_A_W_PIN
M4_A_R_PIN.pause()

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Pin configuration and library error

Post by mikeysklar »

These library related errors sounds like you might have a mismatch between your CircuitPython version and our currently library release.

Can you confirm that you are running CircuitPython 6.3.0 on your CLUE and the library bundle 20210608 drop?

https://circuitpython.org/board/clue_nrf52840_express/
https://circuitpython.org/libraries

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

Hello,
I think I was able to reflash and get all the libraries in it correctly. Can you let me know how to change the font size? is there an example? I was looking for it but couldn't find one.
Thanks for all the help!

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

Sorry. I am still having the same issue. when I add the line "from adafruit_clue import clue". I start getting all the errors. Is there something which can cause that?

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

For reference. This is the code and the clue error message(attached in the image):
import board, displayio, terminalio
from adafruit_display_text import label
display = board.DISPLAY
import time
import board
import displayio
import adafruit_clue
from analogio import AnalogIn
from adafruit_clue import clue
#text_scale=5

display = board.DISPLAY
#text_area = label.Label(terminalio.FONT, text="Climbing", color=0x0000FF, scale=5)
#display.show(text_area)
#text_area.y = 20
analog_in = AnalogIn(board.A4)

def get_voltage(pin):
return (pin.value * 3.3) / 65536
# x=((get_voltage(analog_in)/3.3)*1000))

clue_display = clue.simple_text_display(text_scale=3, colors=(clue.WHITE,))

clue_display[0].text = "Speed&"
clue_display[1].text = "m/s"

while True:
print ("Climbing")
print((get_voltage(analog_in)/3.3)*1000, "m/s")
time.sleep(0.1)# Write your code here :-)
Attachments
circuitpython_lib folder.png
circuitpython_lib folder.png (80.3 KiB) Viewed 1717 times

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

I have downloaded the libraries again and still see the same issue. I downloaded the Bundle Version 6.x library dated 20210608
Attachments
IMG_7377 (2).jpg
IMG_7377 (2).jpg (642.7 KiB) Viewed 1717 times

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Pin configuration and library error

Post by mikeysklar »

Do you have multiple adafruit_clue libraries in your /lib folder? It looks like the error you are seeing is based on adafruit_clue.py, but your screenshot abvoe shows that you have adafruit_clue.mpy in place. Can you make sure that adafruit_clue.py is deleted from /lib and the mpy is the current one. It really doesn't matter which you use mpy or py, but if one is an old version we want that out of the way.

The boot_out.txt should be able to verify your CircuitPython release version. Let's confirm that it is 6.3.0.

What scripts are you running? We provide a few examples here:

https://learn.adafruit.com/adafruit-clu ... thon-demos

I'd like you to start with one of these. Maybe Spirit Level for simplicity.

Code: Select all

# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
"""CLUE Spirit Level Demo"""
import board
import displayio
from adafruit_display_shapes.circle import Circle
from adafruit_clue import clue

display = board.DISPLAY
clue_group = displayio.Group(max_size=4)

outer_circle = Circle(120, 120, 119, outline=clue.WHITE)
middle_circle = Circle(120, 120, 75, outline=clue.YELLOW)
inner_circle = Circle(120, 120, 35, outline=clue.GREEN)
clue_group.append(outer_circle)
clue_group.append(middle_circle)
clue_group.append(inner_circle)

x, y, _ = clue.acceleration
bubble_group = displayio.Group(max_size=1)
level_bubble = Circle(int(x + 120), int(y + 120), 20, fill=clue.RED, outline=clue.RED)
bubble_group.append(level_bubble)

clue_group.append(bubble_group)
display.show(clue_group)

while True:
    x, y, _ = clue.acceleration
    bubble_group.x = int(x * -10)
    bubble_group.y = int(y * -10)

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

Hi,

Thanks for the suggestion. I tried to reset the device and loaded the beta version of the library v7.x and also CircuitPython 7.0.0-alpha.3 version on the clue and was able to run the temp and humidity code without any issue. Before that I tried v6.x library couple of time by resetting the device but that did not work.
Maybe a library issue in v6.x?

Thanks a ton for all the help and suggestion :)
Last edited by dkanday on Thu Jun 10, 2021 12:01 pm, edited 1 time in total.

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

mikeysklar wrote:Do you have multiple adafruit_clue libraries in your /lib folder? It looks like the error you are seeing is based on adafruit_clue.py, but your screenshot abvoe shows that you have adafruit_clue.mpy in place. Can you make sure that adafruit_clue.py is deleted from /lib and the mpy is the current one. It really doesn't matter which you use mpy or py, but if one is an old version we want that out of the way.
{Dkanday} I deleted all the existing libraries from lib folder and reloaded one at a time, just to be sure that I am not adding some incorrect file

The boot_out.txt should be able to verify your CircuitPython release version. Let's confirm that it is 6.3.0.
{Dkanday} I verified that it was initially v6.3.0

What scripts are you running?
{Dkanday} I used this code to begin with : https://learn.adafruit.com/circuitpytho ... -analog-in
and later on used the temp and humidity example and started editing the code from there.

We provide a few examples here:

https://learn.adafruit.com/adafruit-clu ... thon-demos

I'd like you to start with one of these. Maybe Spirit Level for simplicity.

Code: Select all

# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
"""CLUE Spirit Level Demo"""
import board
import displayio
from adafruit_display_shapes.circle import Circle
from adafruit_clue import clue

display = board.DISPLAY
clue_group = displayio.Group(max_size=4)

outer_circle = Circle(120, 120, 119, outline=clue.WHITE)
middle_circle = Circle(120, 120, 75, outline=clue.YELLOW)
inner_circle = Circle(120, 120, 35, outline=clue.GREEN)
clue_group.append(outer_circle)
clue_group.append(middle_circle)
clue_group.append(inner_circle)

x, y, _ = clue.acceleration
bubble_group = displayio.Group(max_size=1)
level_bubble = Circle(int(x + 120), int(y + 120), 20, fill=clue.RED, outline=clue.RED)
bubble_group.append(level_bubble)

clue_group.append(bubble_group)
display.show(clue_group)

while True:
    x, y, _ = clue.acceleration
    bubble_group.x = int(x * -10)
    bubble_group.y = int(y * -10)

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Pin configuration and library error

Post by mikeysklar »

Probably a library mismatch between 6.3.0 and 7.x. Not an issue on your side necessarily as the libraries are always being updated while the stable releases slowly get out of date from the next alpha/beta drops. Glad you are running.

User avatar
dkanday
 
Posts: 60
Joined: Mon Jun 07, 2021 4:49 pm

Re: Pin configuration and library error

Post by dkanday »

mikeysklar wrote:Probably a library mismatch between 6.3.0 and 7.x. Not an issue on your side necessarily as the libraries are always being updated while the stable releases slowly get out of date from the next alpha/beta drops. Glad you are running.
I feel there is a library mismatch between 6.3.0 and library bundle 6.x.

The newer beta library release 7.x works with CircuitPython 7.0.0-alpha.3

Locked
Please be positive and constructive with your questions and comments.

Return to “CLUE Board”