Putting a Dumb Weather Station on the Internet

After all, why not? Why shouldn't I put a dumb Temu weather station on the Internet?

Written .

The Problem

Perhaps it's apartment life cramping my HF style, but I've been into APRS ever since I got into ham radio. It's an interesting way to share little bits of data with the world such as messages, positions, and weather information.

As such, there are many commercial weather stations available that one can buy and hook up, and they will share their measurements via APRS, using either radio or the Internet (the latter is called APRS-IS). I've seen some online, and they're great. Some of them can measure temperature, humidity, precipiation, wind, radiation, light intensity, and more. The major downside, though, is that these are expensive and cumbersome.

There are few hobbies that really embrace the hacker ethos, and amateur radio is one of them. It's the only service where the FCC explicitly allows operators to build their own compliant equipment.

A meme featuring Bilbo Baggins from Peter Jackson's "The Lord of the Rings: The Fellowship of the Ring", contemplating wearing The One Ring.  Text: "After all, why not?  Why shouldn't I build my own ham radio equipment?"
Time is money, and sometimes, you have more money than time. This is not one of those cases.

The Hardware

So, I picked up a nondescript wireless indoor/outdoor thermometer from Temu. This is a barebones kit, lacking even a brand name, but it works very well. A battery-powered transmitter goes outside, and a base station sits inside. Like most things, this uses the 433 MHz band like many other consumer electronics. After a simple pairing procedure that's no more complicated than pressing two buttons, the transmitter says, It's 25 degrees outside, and the base station shows that number on the screen.

The outdoor transmitter to my weather station, snuggled up under the porch stairs.  Christmas lights are visible nearby.
No, the LED Christmas lights don't affect the temperature readings.

It's about as simple as it gets. Being cheap, it's powered by alkaline batteries, transmits on a common frequency using a radio that was probably bought by the pallet, and does not encrypt the signal over the air. We're going to use this to our advantage.

Years ago, I bought an RTL-SDR for no good reason. First designed to let computers listen to DVB-T television signals, hackers quickly found out that this little USB dongle can listen to just about any frequency. The included antenna somewhat limits the product, but for what I need it for, it'll be perfect.

I have my desktop computer near the window, so it can pick up the signals from the transmitter. If you don't have that luxury, grab a Raspberry Pi or other single-board computer. Connecting it to the Internet is left as an exercise to the reader.

The Parser

The rtl_433 app is an open-source decoder for signals on the 433 MHz band. Once your SDR dongle is connected to your computer, you can simply run the rtl_433 command-line app and watch for periodic broadcasts from your weather stations' transmitters.

Terminal output of the rtl_433 command.  Aside from showing some noise level adjustments, there are a few lines of JSON data from various sensors in my neighborhood, including my weather station's transmitter.
It's not much to look at, but this step doesn't make things pretty. That's happening later.

Once I got a feel for the data being transmitted, I messed around with command-line options until I got the output just the way I like it.

rtl_433 -M time:iso -M protocol -M level -C customary -g 0 -Y autolevel -M noise -f 433.90M -F log -F syslog:127.0.0.1:42069 -v
Of everything here, the most important options are the ones to emit sniffed data in the JSON format, and the option to send it to localhost on port 42069. More on that later.

You can save this as a shell script and run it to build a daemon that will sniff your weather station's data and send it somewhere for processing. In the next section, we'll build that somewhere.

The Uploader

People who have been following me for a while know that I've written a popular command-line tool called aprs-weather-submit. As I said when I first introduced it to the world, it lets you send out arbitrary weather data. While you can go outside, eyeball a thermometer, then come back inside to report it, I'd intended for enterprising hackers to use it to bring their own weather data to the Internet of Things. This is no exception!

Now, my Bash skills aren't that great, and I didn't feel like sitting down and writing a data parser in C (at least not yet). So, I turned to another of my cross-platform language skills, .

To make your lives easier, you can view and save my parser and uploader script. I'll summarize it briefly for you:

  1. The script starts a UDP listener on 127.0.0.1:42069 (by default). That will listen for data sent by rtl_433.
  2. Ignore any data that's not from a weather station.
  3. Ignore any data that's not from my weather station.
  4. Parse out the temperature and humidity.
  5. aprs-weather-submit is called with the hardcoded callsign and SSID, hardcoded location, and the weather data. It's all sent to the Tier 2 APRS servers, and nodes may digipeat it over RF.
  6. The current time, temperature, and humidity are saved. The weather station may broadcast a few times a minute, but it's considered rude to emit duplicate APRS packets more than once every ten minutes, so if the weather isn't changing, we're not going to spam the airwaves.

My particular weather station can only sense temperature and humidity. Other sensors might be able to detect barometric pressure. If yours reports more or less data than mine, you can update the PowerShell script to include that. aprs-weather-submit supports any environmental data defined in the APRS specification and its addenda.

At this point, we've connected the Temu weather station to the Internet and the ham radio network. Anyone with an APRS-enabled radio, digipeater, receiver, or just a web browser can see what the temperature and humidity are at my house.

But not everyone has an amateur radio license, and some of those who do don't have the equipment to listen to APRS packets. Now, if you read the script, you'll see some stuff about Mastodon in there. What's going on with that?

The Tooter

Not content with sharing my data via APRS, I decided to be even crazier and share out my data via Mastodon. This federated social network that succeeded the former birdsite welcomes bots (that openly identify as bots), so I decided to create an account for this. I run my own Mastodon instance, so I was able to create a bot account for my weather station. However, you should have no issues creating a second account on any Mastodon instance. Edit the profile, images, links, and whatnot to your liking.

Once you're in your account settings, look for the options to create an API token. Save it somewhere secure. It's considered bad practice to hardcode it into your script, but I'm going to do it anyway, because this is just for me and it runs on my home computer.

Once you have that server address and the authorization token pasted into the PowerShell script, this script will toot no more than once per hour. Any more and we risk alienating anyone who's crazy enough to follow this bot account.

The first toot from my weather station. Rather inauspicious, but it does exactly what it's told.

With that, our little experiment is complete! You can use an APRS app to check the weather at home, or simply open up Mastodon and look for the last toot from your weather station's account!

Links

rtl_433 on GitHub
https://github.com/merbanan/rtl_433
aprs-weather-submit on GitHub
https://github.com/rhymeswithmogul/aprs-weather-submit
My weather station, W1DNS-2, on APRS.to
https://aprs.to/station/station.php?id=921976
APRS 1.01 Specification
http://www.aprs.org/doc/APRS101.PDF
My weather station's Mastodon account
https://mastodon.colincogle.name/@weather

Cite This Article

Suggested citation:
Cogle, Colin. Putting a Dumb Weather Station on the Internet. Colin Cogle's Blog, , colincogle.name/weather.