Trinkey_QT2040_Enviro_Gadget 2

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
dpuerto
 
Posts: 40
Joined: Wed Feb 01, 2023 12:25 am

Trinkey_QT2040_Enviro_Gadget 2

Post by dpuerto »

Hi,

This project took a backburner. I tried to fire it up. I followed everything I could. I tried to copy the firmware and the project files per the following links:

https://learn.adafruit.com/diy-trinkey- ... -with-u2if
https://learn.adafruit.com/circuitpytho ... 3098088-29 [firmare]
https://learn.adafruit.com/adafruit-scd ... cuitpython

But nothing... Errors trying to read the imports... Worse. I tried to use the second turkey and one of the buttons (RESET) broke off while I was holding it to try and put into my USB port.

I tried to use serial on macOSX and the MU editor. It's not a local Python issue, but now I am in a pinch withthese trinkeys. While it used to read CircuitPython, now the disk reads RPI-RP2... regardless which Trinkey I am using... and I only tried the install on one of them... and Idk what to do about the one that broke... should I attempt a solder (I don't even have these tools yet...) or send it back? That broke wayyy too easy. Think the pressure to press a key on your keyboard or a piano key max.

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dastels »

First, RPI-RP2 is the bootloader drive, ready to have a UF2 file copied to it. Make sure you aren't accidentally holding down the BOOT button when connecting/resetting.

For getting CircuitPython installed see https://learn.adafruit.com/adafruit-tri ... cuitpython.

As for the broken board... how long ago did you buy it, and can you post a clear closeup of where the button should be?

Dave

User avatar
dpuerto
 
Posts: 40
Joined: Wed Feb 01, 2023 12:25 am

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dpuerto »

dastels wrote: Mon May 15, 2023 10:18 pm First, RPI-RP2 is the bootloader drive, ready to have a UF2 file copied to it. Make sure you aren't accidentally holding down the BOOT button when connecting/resetting.

For getting CircuitPython installed see https://learn.adafruit.com/adafruit-tri ... cuitpython.

As for the broken board... how long ago did you buy it, and can you post a clear closeup of where the button should be?

Dave
Thanks Dave.

I followed these directions again. I have the Firmware copied onto the Volume and I have copied CircuitPython a well and the Volume reads CircuitPython. So I copied the /lib/ and other code.py from the .zip that was provided for the trinkey+scd-41 and it's still struggling with the imports... :-\

Traceback (most recent call last):
File "<stdin>", line 6
SyntaxError: invalid syntax


Line 6 is `import board`

I'll upload a photo soon of the broken reset.

User avatar
dpuerto
 
Posts: 40
Joined: Wed Feb 01, 2023 12:25 am

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dpuerto »

Yeah, just keeps saying it can't read the board, but in the Serial reads: Adafruit CircuitPython 8.0.5 on 2023-03-31; Adafruit QT2040 Trinkey with rp2040. I am also using the code from the CircuitPython 8 repo

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dastels »

I have the Firmware copied onto the Volume and I have copied CircuitPython a well
What firmware? CircuitPython IS the firmware.

Code: Select all

Traceback (most recent call last):
File "<stdin>", line 6
SyntaxError: invalid syntax
Hmm. Please post the first dozen lines or so.

Dave

User avatar
dpuerto
 
Posts: 40
Joined: Wed Feb 01, 2023 12:25 am

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dpuerto »

from boot.py:

import usb_cdc
usb_cdc.enable(data=True)

from environmon.py

import time
import board
import usb_cdc
import adafruit_scd4x
from adafruit_bme280 import basic as adafruit_bme280
import neopixel

#--| User Config |-----------------------------------
DATA_FORMAT = "JSON" # data format, CSV or JSON
DATA_RATE = 5 # data read rate in secs
BEAT_COLOR = 0xADAF00 # neopixel heart beat color
BEAT_RATE = 1 # neopixel heart beat rate in secs, 0=none
#----------------------------------------------------

# check that USB CDC data has been enabled
if usb_cdc.data is None:
print("Need to enable USB CDC serial data in boot.py.")
while True:
pass

# setup stuff
i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
scd = adafruit_scd4x.SCD4X(i2c)
scd.start_periodic_measurement()
bme = adafruit_bme280.Adafruit_BME280_I2C(i2c)
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)

###

Also, ls /dev/tty.* via Terminal returns:

/dev/tty.BLTH /dev/tty.URT1
/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbmodem14601

And then running, screen /dev/tty.URT1 14601 shows:

SetTTY (fd 5): ioctl failed: Invalid argument
###

Attached my misfortune
Attachments
unnamed.jpg
unnamed.jpg (434.04 KiB) Viewed 270 times
Last edited by dpuerto on Tue May 16, 2023 7:31 pm, edited 1 time in total.

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dastels »

Let's get that broken switch dealt with. Please email [email protected] with a link to this thread, your order number, and request the replacement of one Trinkey QT2040.

I don't see a problem with that code. What is in code.py (or main.py)?

What are you doing to get the syntax error?

Dave

User avatar
dpuerto
 
Posts: 40
Joined: Wed Feb 01, 2023 12:25 am

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dpuerto »

I contacted them. By the way I have two sensors. One for inside and one for outside, sadly one of them just broke when I was trying to hold the button and insert into my USB. Maybe it can be salvaged.

Here is what I am doing. I believe I followed everything to the letter for the Trinkey and the SCD41 to use in Tandem. I am using MacOSX and Mu editor and terminal to attempt to read the code on the trinkey... but it's having trouble loading the imports starting with import board. I think that the firmwave i downloaded (adafruit-circuitpython-adafruit_qt2040_trinkey-en_US-8.0.5.uf2) is not reading correctly. Idk. I'm new to hardware.

ls /dev/tty.* via Terminal returns:

/dev/tty.BLTH /dev/tty.URT1
/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbmodem14601

And then running, screen /dev/tty.URT1 14601 shows:

SetTTY (fd 5): ioctl failed: Invalid argument

###

In MU Editor:

Adafruit CircuitPython 8.0.5 on 2023-03-31; Adafruit QT2040 Trinkey with rp2040
>>> [D
... Traceback (most recent call last):
File "<stdin>", line 2
SyntaxError: invalid syntax

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dastels »

On MacOS it's usually the usbmodem device. I don't recall ever seeing a URT device.

Can you post everything from the REPL leading up to the complaint about the import?

Where does the code come from that is causing the error?

Dave

User avatar
dpuerto
 
Posts: 40
Joined: Wed Feb 01, 2023 12:25 am

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dpuerto »

I levied the port number from the /dev/tty.usbmodem, but the URT device is what appears and disappears when I insert and remove the trinkey from the usb port.

I went through all the steps again (leading up to the direct reading with U2IF)

and this is what it returns:

Traceback (most recent call last):
File "enviromon.py", line 6, in <module>
import board
File "/Library/Python/3.8/site-packages/board.py", line 22, in <module>
from adafruit_blinka.agnostic import board_id, detector
File "/Library/Python/3.8/site-packages/adafruit_blinka/agnostic/__init__.py", line 21, in <module>
chip_id = detector.chip.id
File "/Library/Python/3.8/site-packages/adafruit_platformdetect/chip.py", line 138, in id
raise RuntimeError(
RuntimeError: BLINKA_U2IF environment variable set, but no compatible device found


I've been unsuccessful using the u2if_trinkey_qt2040_rp2040.uf2 firmware recommended in the instructions when inserting in bootmode... So I've flash nuked and used adafruit-circuitpython-adafruit_qt2040_trinkey-en_US-8.0.5.uf2 and the Volume reads as CIRCUITPY, so I continue with the procedures. All my python packages appear to be installed correctly... everytime I run through the install procedure it says that the dependencies are already satisfied... I followed the homebrew install instructions for the MacOSX also.

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dastels »

It looks like the code is trying to run on your mac, not the RP2040.

Dave

User avatar
dpuerto
 
Posts: 40
Joined: Wed Feb 01, 2023 12:25 am

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dpuerto »

This could be. Maybe I am just unfamiliar with the process? I accessed the volume in Terminal, and then I typed python3 environm.py //// I am thinking about I would run any application from the command line?

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dastels »

python3 environm.py loads and runs (or tries to) environm.py on your Mac, not the RP2040. Python3 (i.e. CPython) isn't CircuitPython.

Read the CircuitPython guide: https://learn.adafruit.com/welcome-to-circuitpython.

Dave

User avatar
dpuerto
 
Posts: 40
Joined: Wed Feb 01, 2023 12:25 am

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dpuerto »

ok, I think you are right. Back to using the Mu editor, I was able to follow the Neo pixel example and flash the red light, and then changed the RGB values and was able to achieve yellow and green so it's working. When I replaced the code.py with the environmon.py code it says that "Need to enable USB CDC serial data in boot.py."

So I am googling this but this is my boot.py:

`import usb_cdc
usb_cdc.enable(console=True, data=True)`

User avatar
dastels
 
Posts: 15660
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trinkey_QT2040_Enviro_Gadget 2

Post by dastels »

Note that CircuitPython requires *either* code.py or main.py on the CIRCUITPY drive. Whichever of those you have there will be loaded and executed.

Dave

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

Return to “Trinket ATTiny, Trinket M0”