Skip to content

Instantly share code, notes, and snippets.

View aallan's full-sized avatar

Alasdair Allan aallan

View GitHub Profile
# Author: Alasdair Allan <[email protected]>
# SPDX-License-Identifier: MIT
# Simple RESTful web server for the Pimoroni WeatherHAT + Sensor Kit
# https://shop.pimoroni.com/products/weather-hat?variant=39672186765395
# WeatherHAT Python Library
# https://github.com/pimoroni/weatherhat-python
# Calling GET endpoints, e.g.
@aallan
aallan / bmp280.py
Last active September 17, 2024 08:17
Vindriktning webserver for Raspberry Pi Pico W written in MicroPython
from micropython import const
from ustruct import unpack as unp
# Author David Stenwall (david at stenwall.io)
# See https://github.com/dafvid/micropython-bmp280
# SPDX-License-Identifier: MIT
# Power Modes
BMP280_POWER_SLEEP = const(0)
BMP280_POWER_FORCED = const(1)
@aallan
aallan / watch_code.py
Last active September 19, 2024 16:59
Example MicroPython watch code for the RP2040 1.28-inch TFT display watch board
# Digital Watch Face
#
# Author: Tony Goodhew (28th January 2023)
# Updates: Toby Roberts, Andrew Scheller & Alasdair Allan (March 2023)
#
# Original code taken from https://www.instructables.com/Digital-Watch-Display-MicroPython/
from machine import Pin,I2C,SPI,PWM
import framebuf
import time
@aallan
aallan / lcd_imc_test.py
Created March 13, 2023 11:35
Micropython example code for the RP2040 1.28-inch TFT display watch board
'''
I2C_SDA -> 6
I2C_SDA -> 7
DC -> 8
CS -> 9
SCK -> 10
DIN -> 11
RST -> 12
BL -> 25
BAT_ADC -> 29
@aallan
aallan / hello_world.py
Last active October 18, 2024 06:04
Hello World example for the RP2040 1.28-inch TFT display watch board
"""
"Hello World!"
For https://www.tindie.com/products/adz1122/pi-pico-rp2040-128-inch-tft-display-watch-board/
Using GC9A01 Display Driver for MicroPython (https://github.com/russhughes/gc9a01_mpy)
DISPLAY
=======
Pin
@aallan
aallan / webserver.py
Created February 2, 2023 16:35
A webserver on a Raspberry Pi Pico W controlling the onboard LED.
import network
import socket
import time
from machine import Pin
led = Pin("LED", Pin.OUT)
ssid = 'SSID'
password = 'PASSWORD'
import rp2
import time
import network
import urequests as requests
# Connect to wireless network
SSID = 'NETWORK NAME'
PASSWORD = 'NETWORK PASSWORD'
rp2.country('GB')
import network
import socket
import time
import struct
from machine import Pin
NTP_DELTA = 2208988800
host = "pool.ntp.org"
@aallan
aallan / ap_webserver.py
Created July 7, 2022 13:43
Running a web server on an wireless Access Point for Raspberry Pi Pico W in MicroPython
import socket
import network
import machine
ssid = 'MicroPython-AP'
password = '123456789'
led = machine.Pin("LED",machine.Pin.OUT)
ap = network.WLAN(network.AP_IF)
@aallan
aallan / async_webserver.py
Created July 4, 2022 15:38
An asynchronous webserver written in MicroPython to turn an LED on/off on a Raspberry Pi Pico W
import network
import socket
import time
from machine import Pin
import uasyncio as asyncio
led = Pin(15, Pin.OUT)
onboard = Pin("LED", Pin.OUT, value=0)