Posts

Showing posts from 2025

ESP32S3 (MicroPython) + MAX98357 I2S Audio Amplifier to play tones

Image
This post exercise on ESP32-S3-DevKitC-1 running MicroPython v1.24.1, to play tones using MAX98357 I2S Audio Amplifier. Connection between MAX98357 and ESP32-S3-DevKitC-1: MAX98357 ESP32-S3-DevKitC-1 ================================== VCC 3V3 GND GND MAX98357_LRC GPIO17 MAX98357_BCLK GPIO16 MAX98357_DIN GPIO15 MAX98357_GAIN GND mpy_s3_max98357.py , a simple MicroPython to play single tone on MAX98357 I2S Audio Amplifier. """ ESP32-S3-DevKitC-1 running MicroPython v1.24.1 Play single tone output to MAX98357. """ import math import array import time from machine import I2S, Pin print("Start") MAX98357_LRC = 17 MAX98357_BCLK = 16 MAX98357_DIN =15 i2s = I2S(0, sck=Pin(MAX98357_BCLK), ws=Pin(MAX98357_LRC), sd=Pin(MAX98357_DIN), mode=I2S.TX, bits=16, format=I2S.MONO, rate=44100, ibuf=44100, ) pr...

ESP32S3/MicroPython display bmp on ili9341 LCD

Image
Last post introduced setup and basic of ESP32-S3-DevKitC-1 running MicroPython v1.24.1 using 3.2" 320x240 IPS LCD (ILI9341 SPI) with Cap. Touch (FT6336U) and Micro SD Slot . This post further exercise to load 240x240 RGB888/RGB565 bmp from device/SD, display on ILI9341 LCD. Remark for ESP32-S3-DevKitC-1: For ESP32-S3-DevKitC-1 with Octal SPI flash/PSRAM memory, use the "spiram-oct" variant such as ESP32_GENERIC_S3-SPIRAM_OCT-20241129-v1.24.1.bin (ref:  https://micropython.org/download/ESP32_GENERIC_S3/ ). If use a in-correct firmware such as ESP32_GENERIC_S3-20241129-v1.24.1.bin, "MemoryError: memory allocation failed" will be raised. For boards with Octal SPI flash/PSRAM memory embedded ESP32-S3-WROOM-1/1U modules, and boards with ESP32-S3-WROOM-2 modules, the pins GPIO35, GPIO36 and GPIO37 are used for the internal communication between ESP32-S3 and SPI flash/PSRAM memory, thus not available for external use. (ref:  https://docs.espressif.c...

ILI9341/FT6336U/SD on ESP32S3/MicroPython

Image
Exercise of MicroPython v1.24.1 running on  ESP32-S3-DevKitC-1 , display on  3.2" 320x240 IPS LCD (ILI9341 SPI) with Cap. Touch (FT6336U) and Micro SD Slot . In the exercises, all the three parts of the display module have been tested: ILI9341 SPI LCD, FT6336U cap. touch, and MicroSD card slot. Connection: ESP32-S3-DevKitC-1 ILI9341 SPI display module +-----USB--UART-----+ |GND           GND | GND |GND           5V0 | |IO19 IO14| LCD_CS |IO20 IO13| LCD_RST |IO21 IO12| LCD_RS |IO47 IO11| SDI(MOSI) |IO48 IO10| SCK |IO45 IO9 | LED |IO0 IO46| |IO35 IO3 | |IO36 IO8 | SDO(MISO) |IO37 IO18| SD_CS |IO38 IO17| |IO39 IO16| |IO40 IO15| |IO41 IO7 | CTP_SCL |IO42 IO6 | CTP_RST |IO2 IO5 | CTP_SDA |IO1 IO4 | CTP_INT |IO44 RST | |IO43 3V3 | |GND 3V3 | VCC +-------------------+ Libraries: In the exercise...

CircuitPython on Pico 2 + Touch LCD, act as a HID mouse.

Image
Refer to the cpy_pico2_st7796_BusDisplay_FT6336.py exercise in last post " Use ST7796 SPI LCD on CircuitPython/Raspberry Pi Pico 2, by instancing BusDisplay object using custom init_sequence ", It simple read touch reported by adafruit_focaltouch and display a cursor on screen, no any actual function. In this exercise I will add a simple handler to detect touch action such as touch-down, touch-up, and touch-move, and finally report to PC as HID mouse function. Connection, refer to last post " Use ST7796 SPI LCD on CircuitPython/Raspberry Pi Pico 2, by instancing BusDisplay object using custom init_sequence ". To install libraries for following exercise using circup: circup install adafruit_display_text adafruit_focaltouch adafruit_hid adafruit_button Exercise Code: cpy_pico2_st7796_BusDisplay_FT6336_handler.py Before we report HID mouse function, we have to detect touch action touch-down, touch-up, and touch-move. In this code, a ...

Control onboard LED of Raspberry Pi Pico 2/2W using MicroPython/CircuitPython

Image
The onboard LED on Raspberry Pi Pico and Pico 2 is connected to GPIO25. On Pico W and Pico 2 W, it's connected to the wireless chip. Following are exercise to control the onboard LED using MicroPython/CircuitPython, tested on Pico 2 and Pico 2 W. mpy_rp2_led.py """ MicroPython on Raspberry Pi Pico 2/2W to control onboard LED """ import os, sys import time #import board #from digitalio import DigitalInOut, Direction sys_info_text = sys.implementation[0] + " " + os.uname()[3] +\ "\nrun on " + os.uname()[4] print("=======================================") print(sys_info_text) print("=======================================") led = machine.Pin("LED", machine.Pin.OUT) print("led:", led) # Control onboard led using led.on() and led.off() while True: led.on() time.sleep(0.5) led.off() time.sleep(0.5) """ # Toggle onboard led using led.togg...

Use ST7796 SPI LCD on CircuitPython/Raspberry Pi Pico 2, by instancing BusDisplay object using custom init_sequence.

Image
Currently, it's no ST7796 driver for CircuitPython. So I create ST7796 display by instancing object of busdisplay.BusDisplay with custom init_sequence(ST7796_INIT_SEQUENCE). Tested on WaveShare "3.5 inch 320×480 Capacitive Touch LCD", embedded with ST7796S driver chip and FT6336U capacitive touch control chip , with Raspberry Pi Pico 2 running CircuitPython 9.2.4. For the init_sequence, I reference the MicroPython demo of Working with Raspberry Pi Pico in WaveShare wiki , with a little bit modification. Exactly  ONE bit: (D6 MX/Column Address Order) on MADCTL (36h), to flip left/right. (refer ST7796S Datasheet ) In following exercises, various various function of the ST7796 display module was tested, include: - Display area, color test. (cpy_pico2_st7796_BusDisplay.py) - Touch function of FT6336U capacitive touch drive.(cpy_pico2_st7796_BusDisplay_FT6336.py). - display bmp image (from CIRCUITPY device/SD) using adafruit_imageload. (cpy_pi...