Skip to content

Instantly share code, notes, and snippets.

View thinkier's full-sized avatar

thinkier

  • Victorian Government
  • Melbourne, Australia
View GitHub Profile
@thinkier
thinkier / picow_garden.py
Last active December 6, 2024 01:36
Self-watering planter box w/ Bluetooth LE monitoring
import machine
from micropython import const
import struct
from machine import Pin, ADC, WDT
import asyncio
import aioble
import bluetooth
import time
@thinkier
thinkier / picow_garden.ino
Last active December 18, 2024 10:02
Self-watering planter with MQTT analytics
#include <WiFi.h>
#include <MQTT.h>
#include <ArduinoJson.h>
#include "arduino_secrets.h"
#include <algorithm>
WiFiClient net;
MQTTClient client;
#define PIN_PUMP 12
@thinkier
thinkier / pico_w_https.ino
Created November 15, 2024 07:26
PoC code to connect securely to a domain signed by LetsEncrypt.
#include <WiFi.h>
#include "__private_key_material.h"
// ISRG Root X2 (ECDSA P-384)
const char* ANCHOR_CA = R"EOF(
-----BEGIN CERTIFICATE-----
MIICGzCCAaGgAwIBAgIQQdKd0XLq7qeAwSxs6S+HUjAKBggqhkjOPQQDAzBPMQsw
CQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2gg
R3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBYMjAeFw0yMDA5MDQwMDAwMDBaFw00
MDA5MTcxNjAwMDBaME8xCzAJBgNVBAYTAlVTMSkwJwYDVQQKEyBJbnRlcm5ldCBT
@thinkier
thinkier / matter_iaq_hum_temp_sensor.ino
Last active November 8, 2024 13:39
An amalgamation of 3 examples for Arduino Nano Matter & SGP30. Reports Indoor Air Quality, Humidity & Temperature.
/*
This is an amalgamation of 3 examples made by the following people:
Author:
- Hai Nguyen (Silicon Labs)
- Tamas Jozsi (Silicon Labs)
- Ciara Jekel (Sparkfun Electronics)
*/
#include <Wire.h>
#include <Matter.h>
@thinkier
thinkier / TempHumProbe.ino
Last active November 4, 2024 07:23
Test script for reporting temperature and humidity to a central using an Arduino Nano 33 BLE Sense Rev2
#include <ArduinoBLE.h>
#include <Arduino_HS300x.h>
BLEService envSvc("181A");
BLEShortCharacteristic tempChar("2A6E", BLERead | BLENotify);
BLEUnsignedShortCharacteristic humChar("2A6F", BLERead | BLENotify);
void setup() {
Serial.begin(9600);
@thinkier
thinkier / StallGuard.ino
Last active January 24, 2025 11:23
Test script for the steppers of BTT SKR Pico. Derived from janelia-arduino/TMC2209's example of the same name.
#include <TMC2209.h>
// This example will not work on Arduino boards without HardwareSerial ports,
// such as the Uno, Nano, and Mini.
//
// See this reference for more details:
// https://www.arduino.cc/reference/en/language/functions/communication/serial/
HardwareSerial & serial_stream = Serial2;
@thinkier
thinkier / main.py
Created September 16, 2024 09:38
quick and dirty temperature logger
from picographics import PicoGraphics, DISPLAY_PICO_EXPLORER, PEN_RGB332
from pimoroni_i2c import PimoroniI2C
from breakout_bme68x import BreakoutBME68X
from pimoroni import Button
from time import ticks_ms
from math import floor
display = PicoGraphics(display=DISPLAY_PICO_EXPLORER, pen_type=PEN_RGB332)
black_pen = display.create_pen(0, 0, 0)
white_pen = display.create_pen(255, 255, 255)
@thinkier
thinkier / nano_matter_lightbulb_colour_decomissioning.ino
Created May 21, 2024 11:52
Arduino Nano Matter (Community Preview) sketch with colour-changing LED controls & an option to decomission the Matter accessory.
/*
Matter color lightbulb example for the Nano Matter
The example shows the basic usage of the Arduino Matter API.
The example lets users control the onboard RGB LED on the Nano Matter as a Matter lightbulb.
It's possible to switch the LED on/off, adjust the brightness and the color as well.
The device has to be commissioned to a Matter hub first.
Compatible boards:
@thinkier
thinkier / UUIDv7.swift
Last active February 19, 2024 23:35
Swift script to generate UUID version 7 in accordance with draft-ietf-uuidrev-rfc4122bis-14. Can generate about 4k/ms on a Release profile on my A16 Bionic.
/// License: Public Domain, or MIT License where Public Domain is not available
import Foundation
extension UUID {
/// Implementation of UUIDv7 generator based on the specifications in draft-ietf-uuidrev-rfc4122bis-14
///
/// UUIDv7 is generated without using any additional methods of Monotonicity Guarantees. (Section 6.2) As such, the UUID is accurate to the millisecond only.
///
// Field and Bit Layout:
@thinkier
thinkier / PrusaConnectUploader.sh
Last active October 2, 2023 12:47
Upload a libcamera-jpeg snapshot to Prusa Connect using this shell script and curl!
#!/bin/bash
TOKEN='YOUR_TOKEN_HERE'
FINGERPRINT=$(hostname | sha1sum)
IMAGE_PATH='/tmp/snapshot.jpg'
libcamera-jpeg -n --rotation 180 -o "$IMAGE_PATH"
curl -X PUT \
-H "Token: $TOKEN" \
-H "Fingerprint: $FINGERPRINT" \