This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Socket Feature Availability | |
CircuitPython CircuitPython | |
CPython ESP32SPI ESP32-S2 | |
TCP Server Yes Not Impl. Yes | |
TCP Client Yes Yes Yes | |
UDP Server Yes Not Impl. Yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# server code: | |
# https://github.com/adafruit/circuitpython/blob/main/tests/circuitpython-manual/socketpool/client/host-server.py | |
import board | |
from digitalio import DigitalInOut | |
from adafruit_esp32spi import adafruit_esp32spi | |
import adafruit_esp32spi.adafruit_esp32spi_socket as socket | |
import adafruit_requests as requests | |
from secrets import secrets |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wifi | |
import socketpool | |
import struct | |
import time | |
import sys | |
from secrets import secrets | |
NTP_TO_UNIX_EPOCH = 2208988800 # 1970-01-01 00:00:00 | |
packet = bytearray(48) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if 'ESP32S2' in os.uname().machine: | |
print("MAC", ":".join('%x' % x for x in wifi.radio.mac_address)) | |
# don't proceed w/o any Wi-Fi APs | |
print("Scanning WiFi...") | |
while True: | |
try: | |
for network in wifi.radio.start_scanning_networks(): | |
print("{0:02X}:{1:02X}:{2:02X}:{3:02X}:{4:02X}:{5:02X}".format(*network.bssid), | |
network.channel, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import board | |
import busio | |
import sys | |
import os | |
from digitalio import DigitalInOut | |
import ipaddress | |
import wifi | |
import socketpool | |
import ssl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void customWiFiConnect(ssid, pass) { | |
int WiFiStatusNum; | |
unsigned long start; | |
WiFiStatusNum = getWiFiStatus(); | |
if ( WiFiStatusNum != WL_CONNECTED ) { | |
Serial.println("Restarting WiFi..."); | |
WiFi.begin(ssid, pass); | |
start = millis(); | |
while ( WiFiStatusNum != WL_CONNECTED ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: 2020 anecdata | |
# | |
# SPDX-License-Identifier: MIT | |
import microcontroller | |
import board | |
for pin in dir(microcontroller.pin): | |
if isinstance(getattr(microcontroller.pin, pin), microcontroller.Pin): | |
print("".join(("microcontroller.pin.", pin, "\t")), end=" ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ESP32S2 pins: | |
# strapping pins* | |
# | |
# 0* wpu | |
# 2 amber LED on Cucumber | |
# 8 antitipated I2C SDA on production UMFeatherS2 | |
# 9 antitipated I2C SCL on production UMFeatherS2 | |
# 13 blue LED on UMFeatherS2 | |
# 14 LED on Bast | |
# 15 I2C SDA on Bast |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# variation on https://github.com/gmeader/pyportal/blob/master/bug_demo.py | |
import adafruit_sdcard | |
import busio | |
import digitalio | |
import board | |
import storage | |
import os | |
# Connect to the card and mount the filesystem. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import board | |
import displayio | |
from vectorio import Rectangle, Circle, Polygon, VectorShape | |
import time | |
import random | |
import gc | |
# Make the display context | |
SPLASHMAX = 2000 | |
splash = displayio.Group(max_size=SPLASHMAX) |