Our work amateur radio club, WA0RC, is very lucky in that we have been given a dedicated room for a club shack and have roof access. However, it is in what used to be a mechanical room, and as such, it is in the middle of the building with no windows. This means there is no obvious way to know if severe weather is headed our way. We had a dedicated system displaying weather radar in one corner of the room, but if you’re deep into your radio operations, you might miss a storm coming. I decided it would be a near project to make a little lightning alerter system that would flash an amber light and be much harder to miss.
This project is based on a Raspberry Pi Pico board as I had not yet used one and this seemed like a good project to test it out with. My goal was to create an internet-connected system that would detect when lightning was reported close to our location and flash an amber strobe. This would be mounted on the wall in front of the radios so it couldn’t be missed. I decided to write the program in MicroPython, a language which I hadn’t used before, although I have plenty of expertise with Python proper.
In terms of hardware, there isn’t a lot to this system. The key parts you’ll need (links are Amazon Affiliate links to example products):
- Raspberry Pi Pico
- Amber Flashing Light
- AC Adapter (the above light needs 12-24V and less than an amp, so you could likely find one in your junk drawer)
- Regulator Board (to drop voltage down to the 5V needed for the Raspberry Pi Pico)
- Relay Board
- LED power indicator (optional)
- Some sort of enclosure (I used a junk bin one)
- Various bits of wire, a cutoff USB micro cable, and perfboard to help organize it
A photo of the installation is shown below, but the system is basically connected in such a way that the relay module is controlled by a GPIO pin on the Raspberry Pi Pico. When the Pico flips the output, the relay turns on and the light flashes (in the light I used, the flashing is controlled within the light itself, so you just need to apply power). The LED power indicator is controlled by a separate GPIO pin so that whenever the program is running it is on. The rest of the circuit is just wiring up the power (make sure to tweak the voltage before connecting to the Pico!).
On the software side, it turns out finding location data of lightning isn’t so easy. LightningMaps.org is a popular website that displays this data on a map based on community-sourced lightning data from Blitzortung.org. They do note they will allow access to this data for certain projects, but this is a manual process and for the scope of this project, it didn’t seem worth all that effort. Instead, I turned to something I am very familiar with – airport weather data.
Public airports typically have weather stations on-site that use high-quality sensors to provide live weather data to pilots broadcasted over local voice radio broadcasts and through written form including METARs. As these stations are FAA or NOAA-run, they are free and open for use. There are simple APIs that exist for gathering and using this data too. The only limitation is that these weather stations only provide useful information close to airports (obviously). In my case, our shack is located about half way between KIXD and KOJC airports (which are separated by about ten miles), so using data from these two airports is useful for our location.
The Raspberry Pi Pico first connects to Wi-Fi, and then pulls the latest weather for the two hardcoded airports (KOJC and KIXD in my case). The weather data is a text string on an HTML page, so it is easy to parse using the urequests library. The program then looks for two key items in the weather – “TS” or “LTG.” According to the ASOS User Guide from the National Weather Service, “TS” means there is a thunderstorm with lightning within five miles and “VCTS” means there is a thunderstorm with lightning with five to ten miles. With this in mind, if “TS” is searched on it’s own, I know there is lightning within ten miles which is always enough to get me off the air. Additionally, it is important to note that a new weather report will always be issued when two or more strikes are detected in those ranges. There is also “LTG” which is typically used for “LTG DSNT” or distant lightning (within 30 miles) with an associated cardinal heading. For my purposes, finding “LTG” in the weather report is also enough to get me off the air; I want to be conservative! So in the end, if lightning is detected within 30 miles of either airport (of which the shack is about five miles from), a lightning alert will be generated.
The program then keeps checking for a new weather report every minute. Once lightning has not been detected for 30 minutes, the flashing light is shut off. The intent is that the lightning should be well clear of the area before we get back on the air. There is supposed to be a new weather report generated when the thunderstorm conditions have passed or significantly changed, so I expect fresh data often during stormy periods. One corner case I’ve realized my software does not handle is that if the alert is going off and then the watchdog timer causes a reset and the previous data is cleared. It is possible that lightning could be no longer reported in the area (and a new weather report says it is clear) but 30 minutes have not elapsed. I haven’t tried to improve the program to fix this yet, but it doesn’t seem like a significant problem.
My software is freely provided on my GitHub. Note that one issue I have is that often the internet drops out when a request is made. My software currently handles that by retrying a certain number of times and then restarting. As a safety measure, I have the amber light flash when it does not know there is no lightning nearby (when the unit has just started and has not yet gotten valid data). As such, it will occasionally go into a little loop of flashing for a second or two, restarting, flashing again, restarting, until it finally gets the internet. This is a nuisance but not a showstopper. I haven’t spent a lot of time on finding a way to better handle this as we generally just say that the light should stay flashing for more than a few seconds for it to be “truth.”
As for how this has worked, I think it has been a success! I have gotten a few messages at work saying it alerted them to weather, and it was even used on our club Field Day as we operated in the shack and bad weather rolled in overnight. There are definitely improvements that can be made but this serves the purpose and helped me test out the Raspberry Pi Pico and MicroPython.