Skip to content

Instantly share code, notes, and snippets.

@wojtekka
wojtekka / gist:14742f035b7e0c9682a02df54789d30a
Last active September 19, 2022 19:10
Raspberry Pi Zero PWM audio overlay
/boot/config.txt:
[all]
dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
/boot/cmdline.txt:
snd_bcm2835.enable_compat_alsa=1
/etc/rc.local:
@wojtekka
wojtekka / index.html
Last active October 21, 2020 09:30
Simple WebSocket console, self-contained, desktop/mobile, Firefox/Chrome, public domain
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<script type="text/javascript">
var url = "ws://" + location.host + location.pathname + "websocket";
var connected = false;
var ws;
var ready = false;
@wojtekka
wojtekka / am2320.py
Created April 15, 2019 19:20
Simple code to read AM2320 connected to Raspberry Pi in Python without external libraries
# AM2320 connected to Raspberry Pi pin 3 (SDA) and 5 (SCL)
# Public domain
import sys
import fcntl
import time
import struct
I2C_SLAVE = 0x0703
AM2320_ADDR = 0x5c
@wojtekka
wojtekka / gist:3c5197daefc631b3ed10b2ce1d03700a
Created April 1, 2019 10:29
Generate self-signed certificate
$ openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
@wojtekka
wojtekka / gist:6c532afa9437c9b6696e789caa6ecf4a
Last active February 8, 2022 10:11
Raspberry Pi Zero USB network with DHCP server
#!/bin/sh
echo "dwc2" >> /etc/modules
echo "g_ether" >> /etc/modules
echo "dtoverlay=dwc2" >> /boot/config.txt
cat > /etc/systemd/network/usb0.network << EOF
[Match]
Name=usb0