Difference between revisions of "QT Py (SAMD based)"

From Land Boards Wiki
Jump to navigation Jump to search
 
(33 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[File:tindie-mediums.png|link=https://www.tindie.com/products/27066/]]
 +
 +
[[FILE:QTPy49_P18254-720px.jpg]]
 +
 +
<video type="youtube">kf08ITtFjvE</video>
 +
 
[[File:QT_Py_4600-06.jpg]]
 
[[File:QT_Py_4600-06.jpg]]
  
Line 5: Line 11:
 
* [https://www.adafruit.com/product/4600 Adafruit QT Py SAMD21 Product Page]
 
* [https://www.adafruit.com/product/4600 Adafruit QT Py SAMD21 Product Page]
 
* [https://www.seeedstudio.com/Seeeduino-XIAO-Arduino-Microcontroller-SAMD21-Cortex-M0+-p-4426.html?queryID=3273c05f7923d5ee5cbc677ce4892180&objectID=4426&indexName=bazaar_retailer_products Seeeduino XIAO]
 
* [https://www.seeedstudio.com/Seeeduino-XIAO-Arduino-Microcontroller-SAMD21-Cortex-M0+-p-4426.html?queryID=3273c05f7923d5ee5cbc677ce4892180&objectID=4426&indexName=bazaar_retailer_products Seeeduino XIAO]
 +
* [[QTPy49|QTPy49 Breakout card]]
  
 
== Features ==
 
== Features ==
Line 27: Line 34:
 
** Hardware I2S
 
** Hardware I2S
 
** 6 x Capacitive Touch with no additional components required
 
** 6 x Capacitive Touch with no additional components required
* 3.3V regulator with [https://www.diodes.com/assets/Datasheets/AP2112.pdf 600mA peak output] AP2112
+
* 3.3V regulator with [https://www.diodes.com/assets/Datasheets/AP2112.pdf AP2112, 600mA peak output]
 
* Reset switch for starting your project code over or entering bootloader mode
 
* Reset switch for starting your project code over or entering bootloader mode
 
* USB Type C connector
 
* USB Type C connector
Line 36: Line 43:
 
** Can't use castellated pins if Flash on bottom is installed
 
** Can't use castellated pins if Flash on bottom is installed
 
** [https://www.adafruit.com/product/4763 GD25Q16]
 
** [https://www.adafruit.com/product/4763 GD25Q16]
** Access the SPI flash in Arduino on SPI1 and chip select pin 17
+
* Access the SPI flash in Arduino on SPI1 and chip select pin 17
** In CircuitPython, a '[https://circuitpython.org/board/qtpy_m0_haxpress/ haxpress]' version of the runtime will need to be installed, so it knows to look for the larger filesystem
+
* In CircuitPython, a '[https://circuitpython.org/board/qtpy_m0_haxpress/ haxpress]' version of the runtime will need to be installed, so it knows to look for the larger filesystem
 
** There is more hardware support in the haxpress CircuitPython build because Adafruit added more code to the internal flash instead of using it for a filesystem
 
** There is more hardware support in the haxpress CircuitPython build because Adafruit added more code to the internal flash instead of using it for a filesystem
*** Built-in modules available: adafruit_pixelbuf, analogio, audiobusio, audiocore, audioio, board, busio, digitalio, displayio, errno, fontio, math, microcontroller, neopixel_write, nvm, onewireio, os, paralleldisplay, pulseio, pwmio, rainbowio, random, rotaryio, rtc, storage, struct, supervisor, terminalio, time, touchio, traceback, usb_cdc, usb_hid, usb_midi
+
** Built-in modules available: adafruit_pixelbuf, analogio, audiobusio, audiocore, audioio, board, busio, digitalio, displayio, errno, fontio, math, microcontroller, neopixel_write, nvm, onewireio, os, paralleldisplay, pulseio, pwmio, rainbowio, random, rotaryio, rtc, storage, struct, supervisor, terminalio, time, touchio, traceback, usb_cdc, usb_hid, usb_midi
 
 
== Links ==
 
 
 
* [https://circuitpython.org/board/qtpy_m0/ Adafruit QT Py page]
 
* [https://learn.adafruit.com/adafruit-qt-py Adafruit Learning System for QT Py]
 
  
 
== Pins ==
 
== Pins ==
  
 
=== Adafruit SAMD Pinout ===
 
=== Adafruit SAMD Pinout ===
 +
 +
(Click on image for larger file)
  
 
[[file:adafruit_products_Adafruit_QT_Py_SAMD21_pinout.png|link=https://cdn-learn.adafruit.com/assets/assets/000/110/643/original/adafruit_products_Adafruit_QT_Py_SAMD21_pinout.png?1649443234]]
 
[[file:adafruit_products_Adafruit_QT_Py_SAMD21_pinout.png|link=https://cdn-learn.adafruit.com/assets/assets/000/110/643/original/adafruit_products_Adafruit_QT_Py_SAMD21_pinout.png?1649443234]]
(Click on image for larger file)
 
  
 
=== Seeed Studio SAMD Pinout ===
 
=== Seeed Studio SAMD Pinout ===
Line 155: Line 158:
 
* PWM output
 
* PWM output
  
=== NeoPixel ===
+
=== NeoPixel (Adafruit SAMD) ===
  
 +
* The XAIO does not have a NeoPixel on-board
 +
* The Adafruit QT Py SAMD board does not have an individual
 +
* [https://github.com/land-boards/lb-Arduino-Code/tree/master/LBCards/QTPy49/QTPy_SAMD_Demos/Blink NeoPixel Blink sketch (Arduino)]
 +
* [https://github.com/land-boards/lb-Arduino-Code/tree/master/LBCards/QTPy49/QTPy_SAMD_Demos/NEOPIXEL_QTPy_SAMD__Demo Neopixel sketch (Arduino)]
 
* Connected to digital pin 11 for signal  
 
* Connected to digital pin 11 for signal  
 
* Set pin 12 low for low power usage
 
* Set pin 12 low for low power usage
 
* By default pin 12 is set high by Arduino/CircuitPython
 
* By default pin 12 is set high by Arduino/CircuitPython
* Code example
+
* Python code example
  
 
<pre>
 
<pre>
Line 171: Line 178:
 
pixels.fill((255, 0, 0))  # Note double parens
 
pixels.fill((255, 0, 0))  # Note double parens
 
</pre>
 
</pre>
 +
 +
=== LED (XAIO) ===
 +
 +
* On-board LED
  
 
== Programming ==
 
== Programming ==
  
* C/C++ or CircuitPython
+
* The SAMD on the QT Py and XIAO cards can be programmed using
 +
** C/C++
 +
** CircuitPython
 +
** MicroPython
  
 
=== C/C++ ===
 
=== C/C++ ===
  
* [https://learn.adafruit.com/adafruit-qt-py/arduino-ide-setup Arduino IDE Setup]
+
* Different Arduino installs for QT Py and XIAO
** Requires Arduino IDE version 1.8 or higher
 
** Add https://adafruit.github.io/arduino-board-index/package_adafruit_index.json to Preferences Additional Boards Manager URLs
 
** [https://learn.adafruit.com/adafruit-qt-py/using-with-arduino-ide Add Adafruit SAMD Boards in Boards Manager]
 
  
=== CircuitPython/MicroPython ===
+
==== C/C++ QT Py ====
  
==== CircuitPython for SAMD ====
+
* [https://learn.adafruit.com/adafruit-qt-py/arduino-ide-setup Arduino QT Py IDE Setup]
 +
* Requires Arduino IDE version 1.8 or higher
 +
* Add to Preferences Additional Boards Manager URLs
 +
<pre>
 +
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
 +
</pre>
 +
* [https://learn.adafruit.com/adafruit-qt-py/using-with-arduino-ide Add Adafruit SAMD Boards in Boards Manager]
  
 +
==== C/C++ Seeeduino XIAO ====
 +
 +
* [https://wiki.seeedstudio.com/Seeeduino-XIAO-by-Nanase/ Seeeduino XIAO Get Started By Nanase]
 +
* [https://wiki.seeedstudio.com/Seeeduino-XIAO/ Arduino XIAO Setup]
 +
* Add to Preferences Additional Boards Manager URLs
 +
<pre>
 +
https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json
 +
</pre>
 +
* Tools-> Board-> Boards Manager..., search for "Seeeduino XIAO"
 +
* Tools-> Board, find "Seeeduino XIAO M0"
 +
* Select the serial device of the Arduino board from the Tools | Serial Port menu
 +
 +
=== CircuitPython ===
 +
 +
* [https://circuitpython.readthedocs.io/en/latest/README.html CircuitPython] is a derivative of MicroPython
 +
* CircuitPython looks for a code file on the board to run
 +
** There are four options: code.txt, code.py, main.txt and main.py
 +
** CircuitPython looks for those files, in that order, and then runs the first one it finds
 +
* [https://codewith.mu/ Mu code editor]
 +
** [https://codewith.mu/en/download Mu editor download]
 +
* [https://thonny.org/ Thonny Python Development Environment]
 +
 +
==== Adafruit CircuitPython ====
 +
 +
* [https://circuitpython.org/board/qtpy_m0/ Adafruit QT Py CircuitPython page]
 +
* [https://learn.adafruit.com/adafruit-qt-py Adafruit Learning System for QT Py]
 
* Adafruit CircuitPython 7.3.0 on 2021-01-21
 
* Adafruit CircuitPython 7.3.0 on 2021-01-21
** [https://circuitpython.readthedocs.io/en/latest/README.html CircuitPython] is a derivative of MicroPython
+
** [https://circuitpython.org/board/qtpy_m0/ QT Py CircuitPython Download]
** CircuitPython looks for a code file on the board to run
+
** [https://circuitpython.org/board/qtpy_m0_haxpress/ QT Py Haxpress] used with 2MB Flash EEPROM
*** There are four options: code.txt, code.py, main.txt and main.py
 
*** CircuitPython looks for those files, in that order, and then runs the first one it finds
 
 
** [https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/Welcome_to_CircuitPython/QT_Py_blink.py QT_Py_blink.py]
 
** [https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/Welcome_to_CircuitPython/QT_Py_blink.py QT_Py_blink.py]
** [https://circuitpython.org/board/qtpy_m0_haxpress/ QT Py Haxpress] used with 2MB Flash EEPROM
 
* [https://codewith.mu/ Mu code editor]
 
 
* Free memory
 
* Free memory
 
** Reports 17,776 bytes of free space
 
** Reports 17,776 bytes of free space
Line 206: Line 245:
 
* Save the contents of CIRCUITPY, just in case
 
* Save the contents of CIRCUITPY, just in case
 
* '''Double-click the reset button''' to show the BOOT drive
 
* '''Double-click the reset button''' to show the BOOT drive
* Drag the update-bootloader .uf2 file to the BOOT drive
+
* Drag the update-bootloader.uf2 file to the BOOT drive
 
* Wait a few tens of seconds for the bootloader to update; the BOOT drive will reappear
 
* Wait a few tens of seconds for the bootloader to update; the BOOT drive will reappear
 
* Check INFO_UF2.TXT to verify that the bootloader version has been updated. Then you will need to reload CircuitPython.
 
* Check INFO_UF2.TXT to verify that the bootloader version has been updated. Then you will need to reload CircuitPython.
 
* [http://adafru.it/mpy-update Update mpy files]
 
* [http://adafru.it/mpy-update Update mpy files]
 +
 +
==== SeeedStudio CircuitPython for SAMD ====
 +
 +
* [https://wiki.seeedstudio.com/Seeeduino-XIAO/ Getting Started with Seeeduino XIAO]
 +
* [https://wiki.seeedstudio.com/Seeeduino-XIAO-CircuitPython/ CircuitPython on Seeeduino XIAO]
 +
** [https://circuitpython.org/board/seeeduino_xiao/ Seeeduino XIAO CircuitPython  Download]
  
 
==== Land Boards CircuitPython Code ====
 
==== Land Boards CircuitPython Code ====
Line 282: Line 327:
 
* [[QTPy49]]
 
* [[QTPy49]]
  
[[FILE:QTPy49_FRONT_REV1.png]]
+
[[FILE:QTPY_P18242-720pxV.jpg]]
  
 
== Videos ==
 
== Videos ==

Latest revision as of 19:29, 24 July 2022

Tindie-mediums.png

QTPy49 P18254-720px.jpg

QT Py 4600-06.jpg

Two Manufacturers (SAMD21)

Features

  • ATSAMD21E18 32-bit Cortex M0+ version
    • 48 MHz, 32-bit processor
    • 256KB Flash
    • 32 KB RAM
  • Native USB supported by every OS
    • Can be used in Arduino or CircuitPython as USB serial console, MIDI, Keyboard/Mouse HID, even a little disk drive for storing Python scripts.
  • Built in RGB NeoPixel LED
  • 11 GPIO pins:
    • True analog output on one I/O pin
      • Can be used to play 10-bit quality audio clips in Arduino
        • CircuitPython does not have storage for audio clips
    • 9 x 12-bit analog inputs (SDA/SCL do not have analog inputs)
    • 1 x Optional AREF on A1
    • 9 x PWM outputs (A0 is analog out, A1 is not PWM capable)
    • Hardware I2C port with STEMMA QT plug-n-play connector
    • Hardware UART
    • Hardware SPI
    • Hardware I2S
    • 6 x Capacitive Touch with no additional components required
  • 3.3V regulator with AP2112, 600mA peak output
  • Reset switch for starting your project code over or entering bootloader mode
  • USB Type C connector

Optional External Flash (Adafruit QT Py Only)

  • Optional 2 MB SOIC-8 SPI Flash chip on bottom
    • Can't use castellated pins if Flash on bottom is installed
    • GD25Q16
  • Access the SPI flash in Arduino on SPI1 and chip select pin 17
  • In CircuitPython, a 'haxpress' version of the runtime will need to be installed, so it knows to look for the larger filesystem
    • There is more hardware support in the haxpress CircuitPython build because Adafruit added more code to the internal flash instead of using it for a filesystem
    • Built-in modules available: adafruit_pixelbuf, analogio, audiobusio, audiocore, audioio, board, busio, digitalio, displayio, errno, fontio, math, microcontroller, neopixel_write, nvm, onewireio, os, paralleldisplay, pulseio, pwmio, rainbowio, random, rotaryio, rtc, storage, struct, supervisor, terminalio, time, touchio, traceback, usb_cdc, usb_hid, usb_midi

Pins

Adafruit SAMD Pinout

(Click on image for larger file)

Adafruit products Adafruit QT Py SAMD21 pinout.png

Seeed Studio SAMD Pinout

Seeeduino-XIAO-pin-out.jpg

3V

  • Regulated output from the onboard regulator. You can draw 500mA

5V

  • 5v out from the USB port.
  • Voltage input
    • Requires external diode
      • Schottky, signal, power
      • Between external power source and this pin
      • Cannot power the USB port by supplying 5V to this pin
        • There is a protection diode that prevents the 5V from reaching the USB connector.
        • This is to protect host computer USB ports, etc.

A0 / D0 - Digital/analog GPIO pin 0

  • Digital I/O 0
  • Analog In 0
  • True analog output with 10 bit precision
  • Does not have PWM
  • Capacitive touch input.

A1 / D1 - Digital/analog GPIO pin 1

  • Digital I/O 1
  • Analog In 1
  • Capacitive touch input
  • AREF pin.

A2 / D2 - Digital/analog GPIO pin 2

  • Digital I/O 2
  • Analog In 2
  • PWM
  • Capacitive touch input.

A3 / D3 - Digital/analog GPIO pin 3

  • Digital I/O 3
  • Analog In 3
  • PWM output
  • Capacitive touch input.

SDA / D4

  • Digital I/O 4
  • I2C SDA pin
  • PWM output
  • No analog on this pin
  • No pull up on this pin
  • When using with I2C requires an external 2.2K-10K pullup to 3.3V.

SCL / D5

  • Digital I/O 5
  • I2C SCL
  • No analog on this pin
  • No pull up on this pin
  • When using with I2C requires an external 2.2K-10K pullup to 3.3V.

TX / A6 / D6

  • Digital I/O 6
  • Transmit (output) for Serial1
  • Analog 6
  • PWM output
  • Capacitive touch input

RX / A7 / D7

  • Digital I/O 7
  • Receive (input) for Serial1
  • Analog 7
  • PWM output
  • Capacitive touch input

SCK / A8 / D8

  • Digital I/O 8
  • SPI SCK pin
  • Analog 8
  • PWM output

MISO / A9 / D9

  • Digital I/O 8
  • SPI MISO pin
  • Analog 8
  • PWM output

MOSI / A10 / D10

  • Digital I/O 10
  • SPI MOSI pin
  • Analog 10
  • PWM output

NeoPixel (Adafruit SAMD)

  • The XAIO does not have a NeoPixel on-board
  • The Adafruit QT Py SAMD board does not have an individual
  • NeoPixel Blink sketch (Arduino)
  • Neopixel sketch (Arduino)
  • Connected to digital pin 11 for signal
  • Set pin 12 low for low power usage
  • By default pin 12 is set high by Arduino/CircuitPython
  • Python code example
import board
import neopixel

pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)
# fill((rVal, gVal, bVal))
# rVal, gVal, bVal = red/green/blue values (0-255)
pixels.fill((255, 0, 0))  # Note double parens

LED (XAIO)

  • On-board LED

Programming

  • The SAMD on the QT Py and XIAO cards can be programmed using
    • C/C++
    • CircuitPython
    • MicroPython

C/C++

  • Different Arduino installs for QT Py and XIAO

C/C++ QT Py

  • Arduino QT Py IDE Setup
  • Requires Arduino IDE version 1.8 or higher
  • Add to Preferences Additional Boards Manager URLs
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json

C/C++ Seeeduino XIAO

https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json
  • Tools-> Board-> Boards Manager..., search for "Seeeduino XIAO"
  • Tools-> Board, find "Seeeduino XIAO M0"
  • Select the serial device of the Arduino board from the Tools | Serial Port menu

CircuitPython

Adafruit CircuitPython

import gc
gc.mem_free()
Updating CircuitPython
  • Save the contents of CIRCUITPY, just in case
  • Double-click the reset button to show the BOOT drive
  • Drag the update-bootloader.uf2 file to the BOOT drive
  • Wait a few tens of seconds for the bootloader to update; the BOOT drive will reappear
  • Check INFO_UF2.TXT to verify that the bootloader version has been updated. Then you will need to reload CircuitPython.
  • Update mpy files

SeeedStudio CircuitPython for SAMD

Land Boards CircuitPython Code

I2CIO-8 (MCP23008) Drivers
SWLEDX8-I2C (MCP23017) Drivers
PROTO16-I2C (MCP23017) Drivers

Digital I/O Example

import board
import digitalio
import time

led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT

while True:
    led.value = True
    time.sleep(0.1)
    led.value = False
    time.sleep(0.5)

Flash EEPROM 2 MB

QT Py 4600-07.jpg

QT Py Breakout Board

QT Py Breakout P18212-720px.jpg

  • Built onto GRID49 card
  • Socket for QT Py
  • QT Py pins brought to header strips
  • 3.3V power distribution on 2x8 header

Pins (CCW direction)

  • S12 = A0
  • R12 = A1
  • Q12 = A2
  • P12 = A3
  • N12 = SDA
  • M12 = SCL
  • L12 = TX
  • L1 = RX
  • M1 = SCK
  • N1 = MI
  • P1 = MO
  • Q1 = 3.3V
  • R1 = GND
  • S1 = 5V
  • A6=B6=C6=D6=E6=F6=G6=H6 = GND
  • A7=B7=C7=D7=E7=F7=G7=H7 = 3.3V

QTPy49 Board

QTPY P18242-720pxV.jpg

Videos