Skip to content

Instantly share code, notes, and snippets.

@anecdata
anecdata / code.py
Last active September 11, 2025 19:33
CircuitPython asyncio on RP2350B with 2 busio UARTS + 6 PIO UARTs
# SPDX-FileCopyrightText: 2025 anecdata
# SPDX-License-Identifier: MIT
import time
import random
import storage
import board
import busio
import asyncio
import adafruit_pio_uart
@anecdata
anecdata / code.py
Created September 7, 2025 04:36
CircuitPython PIO UART pin finder
# PIO UART pin finder
# modified from an old SPI pin finder, probably _somewhere_ in the Adafruit docs
# PIO UART doesn't require sequential pins, and pins don't have to be associated with a particular peripheral
# But... ValueError: Cannot use GPIO0..15 together with GPIO32..47
import board
import busio
from microcontroller import Pin
import adafruit_pio_uart
@anecdata
anecdata / code.py
Created August 30, 2025 05:27
CircuitPython Wi-Fi + Ethernet with PoE
# SPDX-FileCopyrightText: 2025 anecdata
# SPDX-License-Identifier: MIT
# Pimoroni Pico Plus 2W
# connected via Adafruit Proto Doubler PiCowbell to
# WIZnet W5500-EVB-Pico2 with WIZPOE-P1
# https://fosstodon.org/@anecdata/115115735846073971
# code is a simplified version of https://gist.github.com/anecdata/456524f8e38c207931afd0dedf6bec89
import time
@anecdata
anecdata / code.py
Last active September 11, 2025 19:25
CircuitPython asyncio TCP multi-server multi-client
import time
import random
import os
import wifi
import socketpool
import asyncio
NUM_CLIENTS = 4
NUM_SERVERS = 2
@anecdata
anecdata / code.py
Last active August 18, 2025 16:02
CircuitPython ESP-NOW Sender + async ESP-NOW Receiver with Ethernet Requests
# SPDX-FileCopyrightText: 2025 anecdata
# SPDX-License-Identifier: MIT
# async ESP-NOW Receiver with Ethernet Requests
import time
import traceback
import board
import busio
import digitalio
import espnow
@anecdata
anecdata / spit.py
Last active July 30, 2025 05:19
CircuitPython SPITarget pin finder
# SPITarget pin finder
# e.g., SPITarget(sck=board.D12, mosi=board.D13, miso=board.D11, ss=board.D10)
# modified from an old SPI pin finder, probably _somewhere_ in the Adafruit docs
import board
import busio
from microcontroller import Pin
from spitarget import SPITarget
@anecdata
anecdata / code.py
Last active July 29, 2025 02:07
SSIDNet™️
# SPDX-FileCopyrightText: 2025 anecdata
# SPDX-License-Identifier: MIT
# SSIDNet™️ message sender
import time
import random
import math
import binascii
import traceback
@anecdata
anecdata / interfaces.txt
Last active July 29, 2025 18:40
CircuitPython data communication interfaces
EOM
@anecdata
anecdata / code.py
Created June 20, 2025 18:36
CircuitPython i2ctarget with large transaction payloads
# atmel-samd i2ctarget (only reads):
import time
import binascii
import board
import busio
from i2ctarget import I2CTarget
I2C_ADDRESS = 0x40
@anecdata
anecdata / code.py
Last active November 26, 2024 06:23
bitmaptools.rotozoom-ed bitmap_label
import board
import terminalio
import displayio
import bitmaptools
import math
from adafruit_display_text import bitmap_label
text_area = bitmap_label.Label(terminalio.FONT, x=25, y=25, text="Hello world")
roto_text_area = displayio.Bitmap(100, 100, 2)
bitmaptools.rotozoom(roto_text_area, text_area.bitmap, angle=math.pi/4)