michael
Danish, working with IT in education. Born at 322 ppm.
I'll post mostly about BSD and Python.
Upsticked
@stefano@littleone.littlefedi.social
On a more serious note: you've moved littleOne to a different public IP and OS a couple of times, right? Is that a problem in any way?
I'm thinking other users that bookmarked or boosted a post of yours from an older "version" (instance of an instance?)? Is that post's URL purely a standard URL with a random number at the end, or is it tied to IP (at the time of posting) or OS?
Like this:
littleone.littlefedi.social/@stefano/01a23648-eb74-75ed-abb2-b43045e144e7#status-01a23648-eb74-75ed-abb2-b43045e144e7
...and now littleOne is running on an OpenBSD VPS!
Hardened with pledge and unveil, it's hosted on an OpenBSD Amsterdam VM ( @OpenBSDAms@mastodon.bsd.cafe ) with 1 core and spinning rust. And performance is still great, considering the VM is also doing (plenty of) other things.
There's a reason I hadn't moved it until today: I don't have much space for backups on there. But today, SFTP backup support landed in the dev branch. So... here we go!
Let me know if you spot any issues at all and... enjoy!
#littleOne #littleFedi #OpenBSD #RunBSD #Fediverse #OwnYourData
Got a slight scare earlier today.
A post of mine was boosted by a popular barista. Within a minute, I received an email about a critical failure on my instance.
Logged in a while later in a browser, and everything seemed fine.
Not exactly what you're looking for, but this Ars article was very inspirational:
MicroPython version of CozIR Ambient demo script:
from machine import UART, Pin
import time
uart1 = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))
uart1.write(b'K 2\r\n')
uart1.flush()
time.sleep(1)
print("COZIR CO2 sensor ready\n")
uart1.write(b'Z\r\n')
time.sleep_ms(100)
discard = uart1.read(10)
while True:
uart1.write(b'Z\r\n')
time.sleep_ms(10)
resp = uart1.read(10)
resp = resp[:8]
fltCo2 = int(resp[2:])
print("CO2 (ppm) = " + str(fltCo2))
time.sleep(1)
Upload script to Pico and run:
(.venv) $ mpremote pico cp cozir.py :cozir.py + exec "import cozir.py"
cp cozir.py :cozir.py
COZIR CO2 sensor ready
CO2 (ppm) = 802
CO2 (ppm) = 802
CO2 (ppm) = 810
CO2 (ppm) = 808
^C(.venv) $
The sensor came with the following Python demo script. First step is to rewrite that for MicroPython.
#!/usr/bin/python3
# Demo script to measure CO2 with a Cozir Ambient sensor
import serial
import time
# Serial port setup
ser = serial.Serial("/dev/ttyU0") # OpenBSD
print("Serial connected")
# Polling mode
ser.write(bytes("K 2\r\n", "utf-8"))
ser.flushInput()
time.sleep(1)
print("COZIR CO2 sensor ready\n")
# Discard first measurement
ser.write(bytes("Z\r\n", "utf-8"))
time.sleep(.01)
discard = ser.read(10)
time.sleep(.5)
# Measure
while True:
ser.write(bytes("Z\r\n", "utf-8"))
time.sleep(.01)
resp = ser.read(10)
resp = resp[:8]
fltCo2 = int(resp[2:])
print("CO2 (ppm) = " + str(fltCo2))
time.sleep(1)
EDC kit suggestion
Using mpremote with Raspberry Pi Pico, OpenBSD edition
The mpremote command line tool provides an integrated set of utilities to remotely interact with, manage the filesystem on, and automate a MicroPython device over a serial connection.
On my laptop, the USB serial device is found at /dev/ttyU0. Make sure that you're member of the dialer group before proceeding.
Start by installing python3 and pip3:
$ doas pkg_add python-3.14.9 py3-pip
Create virtual environment and activate it:
$ python3 -m venv .venv
$ . .venv/bin/activate
Update pip3 and install mpremote
(.venv) $ pip3 install --upgrade pip
(.venv) $ pip3 install mpremote
The device path on OpenBSD isn't among the pre-defined shortcuts. To make connections easier to establish, create a config file for mpremote similar to this:
(.venv) $ cat ~/.config/mpremote/config.py
commands = {
"pico": "connect /dev/ttyU0"
}
Run a demo script on the device:
(.venv) $ mpremote pico exec "import hello"
Hello from MicroPython
#MicroPython #mpremote #RaspberryPiPico #OpenBSD
https://ifx-micropython.readthedocs.io/en/latest/reference/mpremote.html
Hello World!