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

The Scunthorpe Problem

I was talking with a friend recently about an email of theirs running afoul (🐔) of another aggressive filter system, because they dared to to talk with someone called Dickson. I know right, they’re the absolute worst. For those unfamiliar, this is the The…

via Rubenerd November 21, 2024

In which Neil is surprised by the lack of an HDMI cable

Some modern technology decisions baffle me. Today, I was sitting in a meeting room. In the room was my friend, with her laptop. Her laptop has an HDMI port. Also in the room was a screen, onto which my friend wished to display her laptop’s desktop. The screen …

via Neil's blog November 19, 2024

Helm: JSON schema generation

Helm charts support the inclusion of a values.schema.json file to validate values.yaml. Documentation: https://helm.sh/docs/topics/charts/#schema-files A JSON schema is akin to defining the structure of and type-annotating a JSON file. It helps to “shift lef…

via not just serendipity November 14, 2024