Skip to content

Instantly share code, notes, and snippets.

def get_vsys():
# Pico W voltage read function by darconeous on reddit:
# https://www.reddit.com/r/raspberrypipico/comments/xalach/comment/ipigfzu/
conversion_factor = 3 * 3.3 / 65535
import network
from machine import Pin, ADC
wlan = network.WLAN(network.STA_IF)
wlan_active = wlan.active()
try:
@helgibbons
helgibbons / bike_lights.py
Last active October 26, 2023 11:09
Bike lights 2022
import plasma
from plasma import plasma2040
import time
# Random functions! We'll be using randrange for picking integers from a range, and uniform for floats.
from random import randrange, uniform
from pimoroni import RGBLED, Button
from machine import Pin
led = RGBLED(plasma2040.LED_R, plasma2040.LED_G, plasma2040.LED_B)
led.set_rgb(0, 0, 0)
@helgibbons
helgibbons / carbon_intensity.py
Last active March 14, 2023 13:42
Get regional Carbon Intensity data ( https://www.carbonintensity.org.uk/ ) and display it on Inky Frame
"""
This example connects to the Carbon Intensity API to give you a regional forecast of how
your (UK) electricity is being generated and its carbon impact.
Carbon Intensity API only reports data from the UK National Grid.
Find out more about what the numbers mean at:
https://carbonintensity.org.uk/
Make sure to uncomment the correct size for your display!
@helgibbons
helgibbons / enviroplus_into_adafruitio.py
Last active February 23, 2024 14:53
Enviro + into adafruit.io
import time
from machine import Pin, ADC, UART
from picographics import PicoGraphics, DISPLAY_ENVIRO_PLUS
from pimoroni import RGBLED, Button
from breakout_bme68x import BreakoutBME68X, STATUS_HEATER_STABLE
from pimoroni_i2c import PimoroniI2C
from breakout_ltr559 import BreakoutLTR559
from pms5003 import PMS5003
import WIFI_CONFIG
from network_manager import NetworkManager
@helgibbons
helgibbons / http.py
Last active November 4, 2022 15:16
Enviro Luftdaten/Sensor Community example
from enviro.helpers import get_config, connect_to_wifi
from enviro import logging
import urequests, ujson, os
import machine
import ubinascii
def upload_readings():
if not connect_to_wifi():
logging.error(f" - cannot upload readings, wifi connection failed")
@helgibbons
helgibbons / battery.py
Last active April 14, 2024 13:12
Inky Frame battery example
# This example reads Inky Frame's system voltage
# and estimates how much charge is left in the battery
# Save this code as main.py if you want it to run automatically!
from machine import ADC, Pin
import time
from picographics import PicoGraphics, DISPLAY_INKY_FRAME
# these are our reference voltages for a full/empty battery, in volts
@helgibbons
helgibbons / bme68x_badger.py
Last active July 15, 2022 08:50
Weather station for Badger 2040
import badger2040
import time
from breakout_bme68x import BreakoutBME68X
from pimoroni_i2c import PimoroniI2C
display = badger2040.Badger2040()
WIDTH = badger2040.WIDTH
HEIGHT = badger2040.HEIGHT
@helgibbons
helgibbons / weather-hat-mqtt.py
Last active August 28, 2023 22:22
Weather HAT - MQTT for Home Assistant
#!/usr/bin/env python3
from time import sleep
import weatherhat
import json
import paho.mqtt.client as mqtt
import paho.mqtt.publish as publish
sensor = weatherhat.WeatherHAT()
@helgibbons
helgibbons / adafruit-io-w-MQTT-4-HA.py
Created February 10, 2022 15:06
Weather HAT adafruit.io example that also posts data into Home Assistant
#!/usr/bin/env python3
from time import sleep
import weatherhat
from Adafruit_IO import Client, Feed, Dashboard, RequestError, AdafruitIOError
import json
import paho.mqtt.client as mqtt
import paho.mqtt.publish as publish
sensor = weatherhat.WeatherHAT()