Skip to content

Instantly share code, notes, and snippets.

@anecdata
anecdata / code.py
Last active April 24, 2024 03:29
Multi-TLS-client (WIZapalooza): Espressif-based wifi Feather MCU + WIZnet W5100S, W5500, W6100
# SPDX-FileCopyrightText: 2024 anecdata
#
# SPDX-License-Identifier: MIT
# Multi-TLS-client: Espressif-based Feather MCU + WIZnet Ethernets
# CircuitPython: https://github.com/adafruit/circuitpython/pull/8954
# WIZnet library: https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k/tree/core-compatible-socket-type-numbers
import time
import os
@anecdata
anecdata / code.py
Last active March 27, 2024 05:10
Dual-TLS-Client (ESP32-S3 + WIZnet 5500)
# SPDX-FileCopyrightText: 2024 anecdata
#
# SPDX-License-Identifier: MIT
# Adafruit CircuitPython 9.0.0-beta.2-21-gc91b20fd96 on 2024-03-05; Adafruit Feather ESP32-S3 TFT with ESP32S3
# https://github.com/adafruit/circuitpython/pull/8954
# https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k/tree/core-compatible-socket-type-numbers
import time
import os
@anecdata
anecdata / code.py
Last active November 18, 2023 00:52
CircuitPython asyncio with task added later
#3 no gather, and add a task later
import board
import digitalio
import asyncio
import adafruit_ticks
led_pins = [board.A0, board.A1, board.A2, board.A3]
extra_led_pin = board.D24
async def do_led(pin):
@anecdata
anecdata / code.py
Created November 14, 2023 16:22
CircuitPython asyncio w/ Requests iter_content()
import random
import board
import wifi
import socketpool
import ssl
import neopixel
import asyncio
import adafruit_requests
# Choose your own URL adventure...
@anecdata
anecdata / code.py
Created November 5, 2023 01:31
CAN Bus Sender & Receiver test code
import struct
import time
import board
import busio
import digitalio
try:
import canio
NATIVE = True
except ImportError:
NATIVE = False
@anecdata
anecdata / reset.py
Last active October 30, 2023 20:22
CircuitPython reset to RunMode from REPL (interactive)
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT
import microcontroller
import sys
mode = {"0": microcontroller.RunMode.NORMAL,
"1": microcontroller.RunMode.SAFE_MODE,
"2": microcontroller.RunMode.UF2,
@anecdata
anecdata / repl.py
Last active November 14, 2023 04:14
repl.py
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: Unlicense
import time
import supervisor
import microcontroller
import os
import sys
@anecdata
anecdata / espnow_receiver.py
Last active August 6, 2025 00:02
CircuitPython example for Espressif ESP-NOW protocol
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT
import time
import traceback
import supervisor
import os
import rtc
import espnow
@anecdata
anecdata / safemode.py
Last active September 7, 2025 02:45
CircuitPython 8 safemode.py
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT
import json
import microcontroller
import supervisor
from ⚙️ import *
@anecdata
anecdata / reliability.md
Last active August 18, 2024 16:52
Developing for Reliability in CircuitPython
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT

try / except all the things (even the main loop)

with all the things (where available and appropriate)

manage volatile memory: