Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import time
import usb
ftdi_eval = {
'tty': "/dev/ttyUSB3",
@agners
agners / cp2102n-qfn20-gpio-ctrlep.py
Created May 28, 2021 17:31
Control CP2102N GPIO by using pyusb
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Stefan Agner
import os
import sys
import time
import usb
CP210X_VENDOR_SPECIFIC = 0xFF
@agners
agners / esp32-c3.yaml
Last active January 2, 2022 11:18
ESPHome ESP32-C3 configuration
# This is a ESPHome yaml configuration skeleton for
# ESP32-C3 (RISC-V) based boards.
# It is known to work on ESP32-C3-DevKitM-1
# This is using stable release of Arduino 2.0.2 as base
esphome:
name: esp32-c3-test
platformio_options:
board_build.flash_mode: dio
@agners
agners / README.md
Created February 22, 2022 13:33
Silicon Labs OpenThread native git repositories

Silicon Labs OpenThread native git repositories

Background: Silicon Labs offers OpenThread with modifications to support multi-protocol operations as described in AN1333. At least since Gecko SDK release 4.0.0 (Silicon Labs OpenThread release 2.0.0.0) the OpenThread repositories are available through their unified Gecko SDK releases at https://github.com/siliconLabs/gecko_sdk.

However, this repositories has several flaws:

  • It combines all their SDKs in a single big repository
@agners
agners / serial_asyncio_test.py
Created April 2, 2022 10:36
Test serial_asyncio with socat
import asyncio
import serial_asyncio
import serial
class Output(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
print('port opened', transport)
# This causes an exception
#transport.serial.rts = False
@agners
agners / main.py
Last active May 9, 2022 11:48
asyncio aiohttp timeout
import aiohttp
import asyncio
async def work(i: int):
#print(f"start working on {i}")
for i in range(50):
pass
async def main():
tasks = []
@agners
agners / elgate-wave3-fix.sh
Created June 5, 2022 12:22
Elgato Wave:3 Pulseaudio "unstuck"
#!/bin/sh
# Getting Elgato Wave:3 Microphone input "unstuck" on Linux & Pulseaudio
# Replace <card-name> with your microphones card name (check "pacmd list-cards")
# It looks something like "usb-Elgato_Systems_Elgato_Wave_3_<serial>-00"
pacmd set-card-profile alsa_card.<card-name> output:analog-stereo
pacmd set-card-profile alsa_card.<card-name> input:mono-fallback
@agners
agners / rpi-eeprom-ver.sh
Created January 30, 2023 14:10
Get Raspberry Pi EEPROM version (CM4/RPi4, inspired by https://github.com/raspberrypi/rpi-eeprom/blob/master/rpi-eeprom-update)
#!/bin/sh
DT_BOOTLOADER_TS=${DT_BOOTLOADER_TS:-/proc/device-tree/chosen/bootloader/build-timestamp}
BOOTLOADER_CURRENT_VERSION=$(printf "%d" "0x$(od "${DT_BOOTLOADER_TS}" -v -An -t x1 | tr -d ' ' )")
date -u "-d@${BOOTLOADER_CURRENT_VERSION}"
@agners
agners / glc006p.py
Created April 29, 2023 07:14
ZHA custom device (quirk) to override GL-C-006P warm-white/cold-white color temperature
"""GLEDOPTO GL-C-006P device."""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
@agners
agners / iomonitor.sh
Created August 18, 2023 13:35
Simple IO monitoring script usful on Home Assistant OS
#!/bin/sh
#
# IO monitoring for Linux
#
# Taken from armbianmonitor
# https://github.com/armbian/build/blob/master/packages/bsp/common/usr/bin/armbianmonitor
# Adjusted to rely on diskstats only.
#
MonitorIO() {