As a hobby, I'm into amateur radio (also known as Ham Radio). I've been licensed for a number of years, and have had a strong interest in the digital modes (AX.25 packet, PSK-31, etc. If you don't know what these are, it's not really important to the CuFP). I'm also interested in projects involving telemetry, or equipment mounted in generally inaccessible areas. In addition, weather and weather reporting technologies have fascinated me for a long time.

I recently used Perl to tie together my weather station on my boat, and announcing the weather in a spoken format over one of the local repeaters. A repeater is a radio receiver/transmitter pair that typically sits in a local high spot, listens on one frequency (socket, if you like), and re-transmits on another. Because the frequencies we use are comparitively high (440 megahertz), you have a line of sight effect. This means that if there is a tall hill between you and someone else, you'll not be able to talk. But with a repeater atop the hill, since you can both 'see' the repeater, you can talk to each other. A repeater in Georgia typically has a 30 to 70 mile coverage radius, depending on it's height, output power, and antenna. Terrain effects this greatly. Enough with the radio lessons...

For a good while I've had the weather station on my boat on the web. Every 10 minutes, the weather is read from a Peet Brothers Ultimeter U-2000 weather station by the local Linux machine. It then opens a connection to the mySQL server on my ISPs machine, and writes the data up there, where my site is basically mirrored (this all dates back to before I could serve off my IDSL line). After updating the database, it uses the festival/MBROLA text-to-speech package to generate a .MP3 and a .WAV file of the current conditions (this is available at the www.jcwren.dyndns.org/cgi-bin/nph-weather.pl address, but not my mirror site).

A few months ago, I designed and manufactured a custom DTMF decoder board. This board has a microcontroller (Philips 87C2051) and a DTMF decoder chip that 'listens' to the radio on the same frequency (socket) as the repeater outputs on. As it hears each DTMF digit (most radios have a DTMF pad, just like a telephone), it outputs a start-of-digit out the serial port when it first hears it, then when the digit is complete (depending on how long the key is held down), it sends an end-of-digit marker, and the duration in milliseconds the digit was heard.

A Perl script on the local Linux box is connected to the serial port of the DTMF decoder board, and when it hears a certain sequence of digits, it puts my radio in to transmit mode, and plays the weather .WAV file. When the file completes, it the takes the radio out of transmit mode, and goes back to listening for the digit sequence again.

Playing the .WAV file is a little trickier than it should be, for two reasons. The first is that the sound chip (the motherboard has an integrated audio chip) is complete junk. The second is that the audio channel is connected to a Bearcat BC895XLT scanner, which follows the local police, fire and public services frequencies. This is served via a LiveIce encoder and IceCast. LiveIce isn't smart enough to put the sound channel in read-only mode, and the sound card isn't full-duplex, so basically using the output channel of the soundcard is out of the question.

To solve this, I installed the Perl libwin32 package on my Win2K laptop. libwin32 contains Win32::Sound::Play, which allows a .WAV file to be played. I wrote a 14 line script that opens a listening socket, and listens for a file name to play. The volume on the Linux machine is NFS shared to the other machines on the local network. When the request to play a file comes to the Win2K machine, it simply goes out to the network drive with the path/file specified, and plays it. The output of the soundcard in the Win2K machine is connected to the radio, the radio has already been placed in transmit mode by the DTMF listener script, and the audio goes out to the other users on the repeater. When the Win2K machine is finished playing the .WAV file, it sends an 'OK' back to the Linux box, who then takes the radio out of transmit mode, and goes back to listening for more digits.

Of course, all this can be simplified (like getting rid of the last two paragraphs) when I get around to getting a real motherboard for the Linux box, complete with a Creative Labs Live! MP3+ card. The motherboard I'm using right now was originally meant to go in my Durango, as an on-board PC, integrating it with the Alpine Navigation System... Yet another GUP (Great Unfinished Project)...

Instead of using the direct socket approach, I was going to use the RPC::pServer and RPC::pClient modules. Alas, they are not supported under Win32. Technically, they're a little more than I needed to do this, but I thought it would be cool to play with them. Maybe next time.

--Chris

e-mail jcwren

In reply to Using Perl to tie together repeaters, weather, and computers by jcwren

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.