Weathered Radio

By chimo on (updated on )

Note: This setup was superseded by Airy Tooth.

A while ago, I wrote about listening-in to our wireless water meter with a USB SDR. A while after that, we received a weather station that includes a wireless sensor to measure the weather outside:

Acurite weather station and wireless sensor

With the excellent rtl_433 utility, it was quite easy to get a reading off of the wireless sensor. The following script will launch `rtl_433` for 30 seconds and output the readings in JSON format. We then use `jq` to select only the readings specific to our sensor by filtering by sensor id (there are a couple other wireless sensors around it seems), keep only the last reading, do some calibration with `jq` again and write the final JSON to a file. I then point nginx to that file, serve it with a 'application/json' Content-Type and boom: local weather accessible remotely. Why? No idea, but it's kind of neat.

#!/bin/bash

# output dir
dir="/tmp"


# Run rtl_433 for 30 seconds (the sensor returns data every 16s, but whatever)
/usr/bin/rtl_433 -R 40 -F json -T 30 | \
# Filter out everything we received except data from our sensor (id=2168)
jq --unbuffered -c 'select(.id == 2168)' | \
# Only keep a single reading
tail -n 1 | \
# We subtract "3" from the temperature reading since the sensor seems to
# consistently be around 3 degrees too high
jq --unbuffered '.temperature_C = .temperature_C - 3' > "${dir}"/weather.new.json

# Overwrite the old file with the new data
mv "${dir}"/weather.new.json "${dir}"/weather.json

I use the following systemd timer/service to have the script above run every 15 minutes:

weather.timer
[Unit]
Description=Update weather info every 15mins

[Timer]
OnBootSec=15min
OnUnitActiveSec=15min

[Install]
WantedBy=timers.target
weather.service
[Unit]
Description=Update weather info

[Service]
Type=oneshot
ExecStart=/home/chimo/scripts/weather.sh

Recent articles from blogs I follow

I think fedizens should be able to disable replies to some or all of their posts

Every so often, there is a bit of a debate in the fediverse about whether a person should be able to make a post to which other users cannot reply. Yes, they should My view is simple: yes, they should. It is no different to running a website and not offering…

via Neil's blog December 7, 2024

Adding Encrypted Swap and a Userspace OOM-Killer

When setting up my Ideapad, I didn't configure swap because I wanted to avoid reducing the (already unknown) lifetime of it's eMMC storage. This, however, has proven to be a mistake - the Ideapad only has 4GB of RAM and I'm quite good at accid…

via www.bentasker.co.uk December 7, 2024

Advent of Code: Day 4

Link to Day #4 puzzle.

via not just serendipity December 6, 2024