Posts

Showing posts from August, 2022

Pyboard/MicroPython display on SSD1315 I2C OLED using SSD1306 driver

Image
This video show how Pyboard PYBv1.1 ( flashed with MicroPython v1.19.1 ) display on 0.96 inch 128x64 SSD1315 I2C OLED using micropython-ssd1306 driver. The post " Raspberry Pi Pico/MicroPython exercise using SSD1306 I2C OLED " show how to manual install ssd1306 driver to MicroPython device. This video show another approach in Thonny to install  micropython-ssd1306 driver . This is a fork of the driver for SSD1306 displays which is hosted in the Micropython package . The purpose of this fork is to make the driver available on PyPi and thus installable via the upip package manager. But it haven't implemented rotate() function. Exercise code mpyPYB_i2c_scanner.py Show I2C info and scan I2C devices import sys import os import machine print("====================================") print(sys.implementation[0], os.uname()[3], "\nrun on", os.uname()[4]) print("====================================") print

0.96 inch 128x64 SSD1315 I2C OLED (SSD1306 compatible)

Image
 My display module - 0.96" 128x64 SSD1315 I2C OLED The OLED module on the right hand side with marking NFP1315-51A is my new bought 0.96" 128x64 I2C OLED. The seller claim that it's new version with SSD1315 driver, pins order start from GND, VCC, SCL, SDA. (The old version start from VCC, GND,SCL, SDA). He state that it's software compatible with SSD1306. On the left hand side is old one, have the same pins order but no 1315 marking. I can't confirm which driver it used, may be SSD1315 also. Anyway, many post in Internet state that SSD1315 can be driven using SSD1306 driver. Next post I have exercise of Pyboard running MicroPython display on both using SSD1306 driver . More exercises: ~  Xiao ESP32C3 display on SSD1306 128x64 OLED (I2C & SPI) using U8g2 Library (arduino-esp32) ~  Display on SSD1306/SSD1315 OLED with Uno R4 WiFi & Nano 33 BLE using U8g2 library ~  Display on SSD1306/SSD1315 OLED with Uno R4 WiFi & Nano 33 BLE using Adafruit

Flash Pyboard MicroPython firmware using dft-util on Raspberry Pi OS

Image
This video show steps to flash/update MicroPython firmware to Pyboard PYBv1.1 using dft-util on Raspberry Pi OS 32-bit buster. dfu-util (Device Firmware Upgrade Utilities) is used to flash firmware to Pyboard. To install dfu-util using apt: $ sudo apt install dfu-util To list dfu devices: $ sudo dfu-util -l Download firmware To download MicroPython firmware, visit: https://micropython.org/download/ To download .dfu file for Pyboard v1.1. Enter bootloader mode If your Pyboard is flashed MicroPython, you can force it into bootloader mode in REPL >>> import machine >>> machine.bootloader() or "First, disconnect everything from your pyboard. Then connect the DFU pin with the 3.3V pin (they're right next to each other) to put the board into DFU (Device Firmware Update) mode. Now connect the pyboard to your computer via USB." ~  https://github.com/micropython/micropython/wiki/Pyboard-Firmware-Update#preparation Flas

MicroPython Pyboard PYBv1.1

Image
my dev.board - Pyboard PYBv1.1 It's a modified version of MicroPython Pyboard, PYBv1.1, with extra modification: - BOOT0 button for enter DFU mode, such that you no need to use a wire to connect P1 and 3V3. - SWD connetor - PWR LED ~  Flash/update Pyboard MicroPython firmware using dft-util on Raspberry Pi OS ~  Pyboard/MicroPython display on SSD1315 I2C OLED using SSD1306 driver

Install MicroPython ported packages in Thonny

Image
Last post show how to install MicroPython packages using upip , it's another approach to install MicroPython ported packages in Thonny Python IDE with MicroPython Interpreter selected.

Install MicroPython ported packages using upip, with network connection (on ESP32-C3)

Image
upip package manager can be used to install a distribution package on a MicroPython port with networking capabilities. In ESP32 ports, we have to connect to WiFi network before run upip to install package. It's a simple script to connect WiFi network and return to REPL, such that you can run upip in REPL Shell. doConnect.py """ Just a simple MicroPython script to connect to WiFi network, such that you can return to REPL with network connected. """ import network import time sta_if = network.WLAN(network.STA_IF) sta_if.active(True) if sta_if.isconnected(): sta_if.disconnect() time.sleep(1) sta_if.connect('ssid', 'password') This video show how to connect to WiFi network and install micropython-pystone_lowmem package using upip, run on ESP32-C3/MicroPython v1.19.1. (micropython-pystone_lowmem is a benchmark tool ported to MicroPython.) Alternatively, you can install packages in Thonny Python IDE .

Free eBook - Connecting to the Internet with Raspberry Pi Pico W

Image
Free ebook: Connecting to the Internet with Raspberry Pi Pico W - Getting Raspberry Pi Pico W online with C/C++ or MicroPython .

CircuitPython/ESP32-C3 + 1.8" 128x160 TFT ST7735 SPI

Image
This video demo the following exercise code tested on NodeMCU ESP-C3-32S-Kit running CircuitPython 7.3.2. to display on  1.8 inch 128x160 ST7735 SPI TFT . Libraries needed: - adafruit_st7735r.mpy - adafruit_display_text folder - adafruit_display_shapes folder (if you don't know how to download and install CircuitPython Library, read HERE ) Connection: VCC 3V3 GND GND CS IO1 RESET IO2 A0 IO6 SDA IO7 SCK IO8 LED 3V3 ST7735 SPI TFT +------------ +----------------| VCC | +--------------| GND | | +---| CS | | +-|---| RESET | | +-|-|---| A0 | | +-|-|-|---| SDA | | +-|-|-|-|---| SCK +-|--|-|-|-|-|---| LED | | | | | | | +-------------- | | | | | | | | | | | | | | NodeMCU ESP-C3-32S-Kit | | | | | | | +------------------+ | | | | | | | | | | | | | | | +---| IO1 | | | | | | +-----| IO2 | | | | | | | |

MicroPython/ESP32-C3 + 1.8" 128x160 TFT ST7735 SPI, using boochow/MicroPython-ST7735 library.

Image
boochow/MicroPython-ST7735 is a modified version of GuyCarver's ST7735.py ST7735 TFT LCD driver , for micropython-esp32. This video show steps to prepare boochow/MicroPython-ST7735 driver and font files. Tested on  Espressif ESP32-C3-DevKitM-1 running MicroPython v1.19.1, to display on  1.8 inch 128x160 ST7735 SPI TFT . Connection VCC 3V3 GND GND CS 4 RESET 5 A0 9 SDA 7 SCK 6 LED 3V3 Exercise graphicstest.py , modified to match our connection. from ST7735 import TFT from sysfont import sysfont from machine import SPI,Pin import time import math tft_CS = 4 tft_RESET=5 tft_A0=9 tft_SDA=7 tft_SCK=6 spi = SPI(1, baudrate=20000000, polarity=0, phase=0, miso=None) tft=TFT(spi,tft_A0,tft_RESET,tft_CS) tft.initr() tft.rgb(True) def testlines(color): tft.fill(TFT.BLACK) for x in range(0, tft.size()[0], 6): tft.line((0,0),(x, tft.size()[1] - 1), color) for y in range(0, tft.size()[1], 6): tft.line((0,0),(tf

Free online ebook: C++ for Python Programmers

Image
A free online book for Python Programmers to learn C++:  C++ for Python Programmers

ESP32C3/MicroPython - the default SPI pins

Image
To list the default SPI pins in MicroPython: >>> import machine >>> spi=machine.SPI(1) >>> print(spi) SPI(id=1, baudrate=500000, polarity=0, phase=0, bits=8, firstbit=0, sck=6, mosi=7, miso=2) >>> Tested on ESP32C3:

ESP32-C3 (arduino-esp32) display on ST7735 SPI TFT using Adafruit ST7735 and ST7789 Library

Image
This video show how  Espressif ESP32-C3-DevKitM-1 (arduino-esp32) display on 1.8" 128x160 ST7735 SPI TFT , using Adafruit ST7735 and ST7789 Library. Install Library In Arduino IDE, open Library Manager to install "Adafruit ST7735 and ST7789 Library by Adafruit" and other library dependencies. Connection ST7735 SPI         ESP32-C3-DevKitM-1 ------------------------------ VCC           3V3 GND GND CS 10 RESET 9 A0           8 SDA 6 SCK 4 LED 3V3 Run Example Open and run Examples > Adafruit ST7735 and ST7789 Library > graphicstest

1.8 inch 128x160 ST7735 SPI TFT

Image
 My display module - 1.8 inch 128x160 ST7735 SPI TFT ~ product page: LCD wiki - 1.8inch SPI Module ST7735S SKU:MSP1803 Exercise: ~  ESP32-C3 (arduino-esp32) display on ST7735 SPI TFT using Adafruit ST7735 and ST7789 Library ~  128x160 TFT/ST7735 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library ~  MicroPython/ESP32-C3 + 1.8" 128x160 TFT ST7735 SPI, using boochow/MicroPython-ST7735 library ~  CircuitPython/ESP32-C3 + 1.8" 128x160 TFT ST7735 SPI

Install Arduino IDE 1.8.19 on Raspberry Pi OS 32-bit buster, and setup arduino-esp32

Image
Install Arduino IDE 1.8.19 on Raspberry Pi OS 32-bit buster Visit https://www.arduino.cc/en/software , download Linux ARM 32 bits, and extract the downloaded file. My usual practice rename extracted folder to arduino and move to Home Folder. Open Terminal, switch to the arduino folder, run install.sh as su: $ sudo ./install.sh Setup arduino-esp32 In Arduino IDE, MENU > Preferences Add the release link to Additional Boards Manager URLs. Stable release link: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json or Development release link: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json Open Boards manager, search and install "esp32 by Espressif Systems". Done. Now you can program ESP32/C3/S2/S3 in Arduino Framework. ref: ~ Github espressif/arduino-esp32 ~ Arduino-ESP32 doc > Getting Started > Installing ESP32C3_info.ino, exercise cod

Rust online Playground

Image
 The online Rust Playground:  https://play.rust-lang.org/

Pico/MicroPython display on two OLED as one FrameBuffer

Image
Exercises run on Raspberry Pi Pico /MicroPython v1.19.1, display on two OLED ( 1.3 inch 128x64 SH1106 I2C OLED and  0.91 inch 128x32 SSD1306 I2C OLED ) as one FrameBuffer. To install the driver os the OLEDs, refer to: - Raspberry Pi Pico/MicroPython exercise using SH1106 I2C OLED - Raspberry Pi Pico/MicroPython exercise using SSD1306 I2C OLED mpyPico_dualdisplay_one_framebuf.py floating icon across displays """ MicroPython/Raspberry Pi Pico exercise Two display as one FrameBuffer 1.3 inch 128x64 SH1106 I2C OLED I2C(0): scl=9 sda=8 0.91 inch 128x32 SSD1306 I2C OLED I2C(1): scl=7 sda=6 """ import sys import os import time import sh1106 import ssd1306 import framebuf SH1106_WIDTH=128 SH1106_HEIGHT=64 SSD1306_WIDTH=128 SSD1306_HEIGHT=32 print("====================================") print(sys.implementation[0], os.uname()[3], "\nrun on", os.uname()[4]) print("========================

Raspberry Pi Pico/MicroPython exercise using SSD1306 I2C OLED

Image
Exercise on Raspberry Pi Pico running MicroPython v1.19.1, to display on 0.91 inch 128x32 SSD1306 I2C OLED . For mpy_i2c_scanner.py to verify I2C pins and address, used in above video, refer to last post " MicroPython I2C Scanner ". visit https://github.com/micropython/micropython/tree/master/drivers/display , copy and upload ssd1306.py to MicroPython device. Exercise code: mpyPico_SSD1306_hello.py """ MicroPython/Raspberry Pi Pico exercise display on 0.91" 128x32 SSD1306 I2C OLED. And,catch exception of OSError. """ import sys import os import time import ssd1306 DISP_WIDTH=128 DISP_HEIGHT=32 print("====================================") print(sys.implementation[0], os.uname()[3], "\nrun on", os.uname()[4]) print("====================================") oled_i2c = machine.I2C(1) print("Default I2C(1):", oled_i2c) try: oled_ssd1306 = ssd1306.SSD1306_I2C(DISP_WIDTH, DISP_HEIGH

0.91 inch 128x32 SSD1306 I2C OLED

Image
 0.91" 128x32 SSD1306 I2C OLED MicroPython Exercise: ~  Raspberry Pi Pico/MicroPython exercise using SSD1306 I2C OLED ~  Pico/MicroPython display on two OLED as one FrameBuffer CircuitPython Exercises: ~  ESP32-S3-Zero/CircuitPython Display on 128x64 SSD1306 I2C OLED

Raspberry Pi Pico/MicroPython exercise using SH1106 I2C OLED

Image
Exercise on Raspberry Pi Pico running MicroPython v1.19.1, to display on  1.3 inch 128x64 SH1106 I2C OLED . For mpy_i2c_scanner.py, used in above video, refer to last post " MicroPython I2C Scanner ". Visit  https://github.com/raspberrypi/pico-micropython-examples/tree/master/i2c/1106oled , Copy and upload sh1106.py to MicroPython device. Copy and run the example i2c_1106oled_using_defaults.py. i2c_1106oled_using_defaults_2.py , my modified exercise. # Display Image & text on I2C driven SH1106 OLED display from machine import I2C, ADC from sh1106 import SH1106_I2C import framebuf import time WIDTH = 128 # oled display width HEIGHT = 64 # oled display height i2c = I2C(0) # Init I2C using I2C0 defaults, SCL=Pin(GP9), SDA=Pin(GP8), freq=400000 print("I2C Address : "+hex(i2c.scan()[0]).upper()) # Display devi