Posts

Showing posts from September, 2024

MicroPython code to list available I2C/SPI and default GPIO assigned

Image
Simple MicroPython code to list available I2C/SPI and default GPIO assigned. Tested on  Raspberry Pi Pico 2 (RP2350) running micropython v1.24.0-preview.201. mpy_list_i2c_spi.py """ MicroPython to list available I2C/SPI and default GPIO assigned """ import sys, os import machine print("====================================") print(sys.implementation[0], os.uname()[3], "\nrun on", os.uname()[4]) print("====================================") print("List available I2C and SPI\n") print("Available I2C and default GPIO assigned:") n = 0 while True: try: i2c = machine.I2C(n) print(i2c) n = n+1 except ValueError as exc: print("ValueError:", exc) break print() print("Available SPI and default GPIO assigned:") n = 0 while True: try: spi = machine.SPI(n) print(spi) n = n+1 except ValueError as exc: pr

I2C OLED (SSD1306/SSD1315) screen with Raspberry Pi Pico 2 (RP2350) using MicroPython

Image
This video show steps to install ssd1306@micropython-lib OLED driver on Raspberry Pi Pico 2 (RP2350)  running MicroPython v1.24.0-preview.201 to display with 0.96 inch 128x64 SSD1315 I2C OLED (SSD1306 compatible) and 0.91 inch 128x32 SSD1306 I2C OLED . Also compare with another driver micropython-ssd1306@PyPI. Connection:      I2C OLED Pico      ====================      SDA GP4      SCL GP5      VCC 3V3      GND GND Exercise code: mpy_i2c_scanner.py , I2C devices scanner. import machine import os print(os.uname()) print() # How many hardware I2C supported # and show the I2C info print("number of I2C supported:") print("========================") i=0 while True: try: print(machine.I2C(i)) except ValueError as e: print(e) break i += 1 print() #Using machine.SoftI2C #scl = machine.Pin(9, mode=machine.Pin.OUT, pull=machine.Pin.PULL_UP) #sda = machine.Pin(8, mode=machine.Pin.OUT, pull=machine.Pin.PUL

Hello Raspberry Pi Pico 2 (RP2350): first try MicroPython and CircuitPython

Image
First try MicroPython/CircuitPython on  Raspberry Pi Pico 2 (RP2350) . It's empty in fresh new Raspberry Pi Pico 2, it will power-up in Bootloader mode and RP2350 driver will appear as storage.  Download firmware: MicroPython: - Visit https://micropython.org/download/RPI_PICO2/ to download MicroPython firmware for Pico2. Both normal RP2350 and RP2350-RISCV version are available. CircuitPython: - Visit https://circuitpython.org/board/raspberry_pi_pico2/ to download CircuitPython firmware for Pico 2 by Raspberry Pi. To install MicroPython or CircuitPython firmware, simple drag the downloaded firmware (.uf2) to RP2350 driver. To enter Bootloader mode: Using BOOTSEL button: Push and hold the BOOTSEL button as you plug your Pico 2 into your computer. Using code: If your Pico 2 have already been flashed MicroPython or CircuitPython, you can make it reboot in Boot load mode using code. In MicroPython: import machine machine.bootloader() In Ci

my dev. board: Raspberry Pi Pico 2 (RP2350)

Image
My dev. board: Raspberry Pi Pico 2 (RP2350) Pinout: Links: ~  Raspberry Pi Documentation > Pico-series Microcontrollers Related Posts: ~  Hello Raspberry Pi Pico 2 (RP2350): first try MicroPython and CircuitPython ~  MicroPython code to list available I2C/SPI and default GPIO assigned ~  I2C OLED (SSD1306/SSD1315) screen with Raspberry Pi Pico 2 (RP2350) using MicroPython

Flash ESP-AT firmware to XIAO ESP32C3

Image
ESP-AT is a project based on ESP-IDF. It makes an ESP32-C3 board work as a slave, and an MCU as a host. The host MCU sends AT commands to the ESP32-C3 chip and receives AT responses back. ESP-AT provides a wide range of AT commands with different functions, such as Wi-Fi commands, TCP/IP commands, Bluetooth LE commands, Bluetooth commands, MQTT commands, HTTP commands, and Ethernet commands. (ref:  https://docs.espressif.com/projects/esp-at/en/latest/esp32c3/Get_Started/What_is_ESP-AT.html ) This video show steps to flash ESP-AT firmware to XIAO ESP32C3 using esptool in Windows 11. Then, Raspberry Pi Pico is used as USB-to-serial bridge to send and receive command with XIAO ESP32C3. Connection: In my test on XIAO ESP32C3: Download/Log output port is already established internally on the board, via USB connector. You only need to provide USB cable between the board and PC. For AT command/response port , I use TX/RX pins only: - GPIO6 (RX)