Browse Source

blog: Add "Weathered Radio" post

Chimo 2 years ago
No known key found for this signature in database GPG Key ID: B0C36EDD0BB35A9C
2 changed files with 85 additions and 0 deletions
  1. +85
  2. BIN

+ 85
- 0
content/blog/ View File

@ -0,0 +1,85 @@
title: Weathered Radio
description: ""
publishdate: 2019-06-23
slug: weathered-radio
categories: blog
tags: [rtl, radio, weather]
A while ago, I wrote about <a href="/blog/aqueous-radio/">listening-in to our
wireless water meter with a USB SDR</a>. A while after that, we received a
weather station that includes a wireless sensor to measure the weather
<img src="/images/weathered-radio/acurite.jpg"
alt="Acurite weather station and wireless sensor" />
With the excellent <a href="">rtl_433</a>
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.
{{< highlight bash >}}
# output dir
# 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}"/
# Overwrite the old file with the new data
mv "${dir}"/ "${dir}"/weather.json
{{< / highlight >}}
I use the following systemd timer/service to have the script above run every
15 minutes:
{{< highlight SYSTEMD >}}
Description=Update weather info every 15mins
{{< / highlight >}}
{{< highlight SYSTEMD >}}
Description=Update weather info
{{< / highlight >}}

static/images/weathered-radio/acurite.jpg View File

Before After
Width: 400  |  Height: 400  |  Size: 13 KiB