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

From Land Boards Wiki
Jump to navigation Jump to search
Line 31: Line 31:
 
[[file:adafruit_products_qtpy-rp2040-pins.png]]
 
[[file:adafruit_products_qtpy-rp2040-pins.png]]
  
=== 3V ===
+
==== 3V ====
  
 
* Regulated output from the onboard regulator. You can draw 500mA
 
* Regulated output from the onboard regulator. You can draw 500mA
  
=== 5V ===
+
==== 5V ====
  
 
* 5v out from the USB port.  
 
* 5v out from the USB port.  
Line 46: Line 46:
 
**** This is to protect host computer USB ports, etc.
 
**** This is to protect host computer USB ports, etc.
  
=== A0 / D0 - Digital/analog GPIO pin 0 ===
+
==== A0 / D0 - Digital/analog GPIO pin 0 ====
  
 
* Digital I/O 0
 
* Digital I/O 0
Line 54: Line 54:
 
* Capacitive touch input.
 
* Capacitive touch input.
  
=== A1 / D1 - Digital/analog GPIO pin 1 ===
+
==== A1 / D1 - Digital/analog GPIO pin 1 ====
  
 
* Digital I/O 1
 
* Digital I/O 1
Line 61: Line 61:
 
* AREF pin.
 
* AREF pin.
  
=== A2 / D2 - Digital/analog GPIO pin 2 ===
+
==== A2 / D2 - Digital/analog GPIO pin 2 ====
  
 
* Digital I/O 2
 
* Digital I/O 2
Line 68: Line 68:
 
* Capacitive touch input.
 
* Capacitive touch input.
  
=== A3 / D3 - Digital/analog GPIO pin 3 ===
+
==== A3 / D3 - Digital/analog GPIO pin 3 ====
  
 
* Digital I/O 3
 
* Digital I/O 3
Line 75: Line 75:
 
* Capacitive touch input.
 
* Capacitive touch input.
  
=== SDA / D4 ===
+
==== SDA / D4 ====
  
 
* Digital I/O 4
 
* Digital I/O 4
Line 84: Line 84:
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.  
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.  
  
=== SCL / D5 ===
+
==== SCL / D5 ====
  
 
* Digital I/O 5
 
* Digital I/O 5
Line 92: Line 92:
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.  
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.  
  
=== TX / A6 / D6 ===
+
==== TX / A6 / D6 ====
  
 
* Digital I/O 6
 
* Digital I/O 6
Line 100: Line 100:
 
* Capacitive touch input
 
* Capacitive touch input
  
=== RX / A7 / D7 ===
+
==== RX / A7 / D7 ====
  
 
* Digital I/O 7
 
* Digital I/O 7
Line 108: Line 108:
 
* Capacitive touch input
 
* Capacitive touch input
  
=== SCK / A8 / D8 ===
+
==== SCK / A8 / D8 ====
  
 
* Digital I/O 8
 
* Digital I/O 8
Line 115: Line 115:
 
* PWM output
 
* PWM output
  
=== MISO / A9 / D9 ===
+
==== MISO / A9 / D9 ====
  
 
* Digital I/O 8
 
* Digital I/O 8
Line 122: Line 122:
 
* PWM output
 
* PWM output
  
=== MOSI / A10 / D10 ===
+
==== MOSI / A10 / D10 ====
  
 
* Digital I/O 10
 
* Digital I/O 10
Line 133: Line 133:
 
[[file:seeed-xinpin-rp2040.jpg]]
 
[[file:seeed-xinpin-rp2040.jpg]]
  
=== 3V ===
+
==== 3V ====
  
 
* Regulated output from the onboard regulator. You can draw 500mA
 
* Regulated output from the onboard regulator. You can draw 500mA
  
=== 5V ===
+
==== 5V ====
  
 
* 5v out from the USB port.  
 
* 5v out from the USB port.  
Line 148: Line 148:
 
**** This is to protect host computer USB ports, etc.
 
**** This is to protect host computer USB ports, etc.
  
=== A0 / D0 - Digital/analog GPIO pin 0 ===
+
==== A0 / D0 - Digital/analog GPIO pin 0 ====
  
 
* Digital I/O 0
 
* Digital I/O 0
Line 156: Line 156:
 
* Capacitive touch input.
 
* Capacitive touch input.
  
=== A1 / D1 - Digital/analog GPIO pin 1 ===
+
==== A1 / D1 - Digital/analog GPIO pin 1 ====
  
 
* Digital I/O 1
 
* Digital I/O 1
Line 163: Line 163:
 
* AREF pin.
 
* AREF pin.
  
=== A2 / D2 - Digital/analog GPIO pin 2 ===
+
==== A2 / D2 - Digital/analog GPIO pin 2 ====
  
 
* Digital I/O 2
 
* Digital I/O 2
Line 170: Line 170:
 
* Capacitive touch input.
 
* Capacitive touch input.
  
=== A3 / D3 - Digital/analog GPIO pin 3 ===
+
==== A3 / D3 - Digital/analog GPIO pin 3 ====
  
 
* Digital I/O 3
 
* Digital I/O 3
Line 177: Line 177:
 
* Capacitive touch input.
 
* Capacitive touch input.
  
=== SDA / D4 ===
+
==== SDA / D4 ====
  
 
* Digital I/O 4
 
* Digital I/O 4
Line 186: Line 186:
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.  
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.  
  
=== SCL / D5 ===
+
==== SCL / D5 ====
  
 
* Digital I/O 5
 
* Digital I/O 5
Line 194: Line 194:
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.  
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.  
  
=== TX / A6 / D6 ===
+
==== TX / A6 / D6 ====
  
 
* Digital I/O 6
 
* Digital I/O 6
Line 202: Line 202:
 
* Capacitive touch input
 
* Capacitive touch input
  
=== RX / A7 / D7 ===
+
==== RX / A7 / D7 ====
  
 
* Digital I/O 7
 
* Digital I/O 7
Line 210: Line 210:
 
* Capacitive touch input
 
* Capacitive touch input
  
=== SCK / A8 / D8 ===
+
==== SCK / A8 / D8 ====
  
 
* Digital I/O 8
 
* Digital I/O 8
Line 217: Line 217:
 
* PWM output
 
* PWM output
  
=== MISO / A9 / D9 ===
+
==== MISO / A9 / D9 ====
  
 
* Digital I/O 8
 
* Digital I/O 8
Line 224: Line 224:
 
* PWM output
 
* PWM output
  
=== MOSI / A10 / D10 ===
+
==== MOSI / A10 / D10 ====
  
 
* Digital I/O 10
 
* Digital I/O 10

Revision as of 23:09, 10 June 2022

XIAO-RP2040.PNG

RP2040 QT Py

QT Py RP2040.PNG

  • Adafruit QT Py RP2040 Product page or Seeed XIAO RP2040 Product page
  • USB Type C connector
  • RP2040 32-bit Cortex M0+ dual-core
  • Runs at ~125 MHz
  • 264 KB RAM
  • 8 MB SPI FLASH chip for storing files and CircuitPython/MicroPython code storage (Adafruit), 2 MB SPI Flash (Seeedstudio)
    • No EEPROM
  • Can be used with MicroPython or CircuitPython
  • Built-in RGB NeoPixel LED
  • 13 GPIO pins (11 breakout pads and two QT pads):
    • Four 12 bit ADCs (one more than Pico)
    • Two I2C ports (one on the QT connector, one on the breakout pads)
    • SPI and UART peripherals, in standard QT Py locations,
    • PWM outputs on every IO pin - for servos, LEDs, etc
    • There are 6 GPIO in consecutive order for PIO compatibility
  • 3.3V logic and power 600 mA
  • Both Reset button and Bootloader select buttons for quick restarts (no unplugging-replugging to relaunch code)

Pins (RP2040 version)

Adafruit RP2040

Adafruit products qtpy-rp2040-pins.png

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

Seeeduino RP2040

Seeed-xinpin-rp2040.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

  • 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
  • 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

Programming

  • C/C++
  • CircuitPython
  • MicroPython

C/C++

Seeeduino RP2040

CircuitPython/MicroPython

Install CircuitPython on QT Py RP2040

>>> import gc
>>> gc.mem_free()
208128
>>> import time
>>> gc.mem_free()
207952

CircuitPython

CircuitPython for RP2040

  • Adafruit CircuitPython 7.3.0 on 2021-01-21
    • 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
    • QT_Py_blink.py
    • QT Py Haxpress used with 2MB Flash EEPROM
  • Mu code editor
  • Free memory
    • Reports 17,776 bytes of free space
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

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

QTPy49 FRONT REV1.png

Videos