Posts

Showing posts from September, 2024

Raspberry Pi Pico 2 (RP2350)/MicroPython display on two OLED, SSD1306 I2C and SPI.

Image
In previous I exercised on Raspberry Pi Pico 2 /MicroPython to display on I2C SSD1306 OLED and SPI SSD1306 OLED . In this post display on both I2C and SPI SSD1306 OLED. Remark: when I test the code, base on MicroPython v1.24.0-preview.321 on Raspberry Pi Pico 2 normal RP2350 and RP2350-RISCV version. It's found something strange when running on  RP2350-RISCV version. Check the video at 4:30. - The MicroPython running in a loop, without time.sleep(). - If "Stop" on Thonny IDE clicked to stop from running, the Pico 2 will disconnected, and REPL fail. - ----- Have to reboot the Pico to re-connect. It should be a MicroPython issue, not SSD1306 issue. Connection: Connection between Raspberry Pi Pico 2 and I2C/SPI SSD1306 OLED I2C SSD1306 - SCL GP5 - SDA GP4 SPI SSD1306 - D/C GP13 - RST GP12 - SDA GP11 (mosi) - SCL GP10 (sck) - VCC 3V3 - GND GND GP9 (dummy cs) - No connection GP8 (miso) - No connection Exercise Code: To ins...

Install Pillow(PIL) for Python in Windows 11/Thonny

Image
To install Pillow (or PIL) in Windows 11, simple enter the command in Terminal: pip install Pillow To install in Thonny, > Click on Tools > Manager packages... > Search "pillow" and install it. Remark: ~ Both the Python Slideshow code and the images in the video are generated by Copilot .

Ask Copilot to create a Python/Tkinter Image Slideshow

Image
It's my first try  asking Copilot to create a Python/Tkinter Image Slideshow, test on Windows 11 . I just enter the prompt in Copilot and submit. I even typo the word of "create". Please creaate a Python/tkinter program to display all jpg images in current folder in slideshow. coPython_slideshow.py , the Python code created. I just change the code of geometry() and resize() to match with my images. from tkinter import * from PIL import ImageTk, Image import os # Get a list of all .jpg files in the current folder image_files = [filename for filename in os.listdir() if filename.lower().endswith(".jpg")] # Initialize the Tkinter window root = Tk() root.title("Image Slideshow") root.geometry( "800x800" ) # Set your desired window size # Load the images and create PhotoImage objects image_list = [] for filename in image_files: img = Image.open(filename).resize(( 400, 400 )) # Resize the images as needed image_list.appen...

Raspberry Pi Pico 2/MicroPython display on SPI SSD1306 OLED

Image
Last post show how to install MicroPython ssd1306 driver on Raspberry Pi Pico 2 in Thonny, and display on 0.96 inch 128x64 SSD1315 I2C OLED (SSD1306 compatible) . Here is how to using the ssd1306 driver, display on 0.96 inch 128x64 SSD1306 SPI OLED . Connection: SPI SSD1306 OLED     Raspberry Pi Pico 2 ======================================== - D/C      GP13 - RST      GP12 - SDA      GP11 (mosi) - SCL      GP10 (sck) - VCC      3V3 - GND      GND      GP9 (dummy cs) - No connection      GP8 (miso) - No connection Notice that my SPI SSD1306 OLED is 6 pins version, no cs on board. But it's required in ssd1306 driver, so I have to assign dummy GP9 for it. Also GP8 is the SPI MISO, not use in this case. Exercise Code: mpyPico2_SSD1306_spi_hello.py , a simple exercise to say Hello. """ MicroPython/Raspb...

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=machin...

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.bootloade...

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 Exercises: ~  MicroPython code to list available I2C/SPI and default GPIO assigned ~  I2C OLED (SSD1306/SSD1315) screen with Raspberry Pi Pico 2 (RP2350) using MicroPython ~  Raspberry Pi Pico 2/MicroPython display on SPI SSD1306 OLED ~  Raspberry Pi Pico 2 (RP2350)/MicroPython display on two OLED, SSD1306 I2C and SPI . ~  Multi SSD1306 OLED, on Raspberry Pi Pico 2/MicroPython ~  Raspberry Pi Pico 2/MicroPython display on 1.54" 240x240 ST7789 SPI IPS ~  Raspberry Pi Pico 2/MicroPython read bmp images and draw on ST7789 display pixel-by-pixel ~  Raspberry Pi Pico 2/MicroPython display bmp images on 240x240 ST7789 SPI Display CircuitPython Exercises: ~  Circuit...

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 (...