Some years ago my father shown me a pretty awesome piece of software created by Pieter-Tjerk de Boer. And I was absolutely surprised about this. Pieter built WebSDR, a software defined radio receiver thru Internet with the great gift of many simultaneous users listening to different frequencies.
Recently, Pieter added Raspberry PI support to his software, so it was a great moment to get hands dirty on this project: A fully automated Raspberry PI 3 powered WebSDR receiver. I had a spare Raspberry PI3, and also a RTL-SDR RTL2838u usb dongle ready to be used.
I asked Pieter for a copy of WebSDR, and he answered my email with an attached compressed file with webSDR binaries and files.
Everything wired, burnt a Raspbian 9 image on a SD card and got it working after some setup
My father asked for some kind of dual band setup, for 80 and 40 meter band. (3.5-7Mhz) not simultaneous, but time based. As long as band conditions aren’t the same during the day/night, it’s better to have 40 meter band on daylight, then 80 meter band all night long.
To get a single SDR receiver working for two bands. Easy
This is easy. I’m using rtl_tcp as hardware-software interface
/usr/bin/rtl_tcp -s 1024000 -g 10 -d0 -p9990
So the thing is: I need to swap over WebSDR’s configuration. One for 40-meter band, one for 80-meter band.
I got then, websdr-40m.cfg
... band 40m device !rtlsdr 127.0.0.1:9990 0 samplerate 1024000 centerfreq 7100 initial 7100 lsb antenna 40 meter double bazooka gain -25
... band 80m device !rtlsdr 127.0.0.1:9990 0 samplerate 1024000 centerfreq 3700 initial 3650 lsb antenna Half wave 80 meter dipole gain -25
Then I made a single Systemctl unit to manage both configurations: /etc/systemd/system/websdr@.service
[Unit] Description=WebSDR server After=multi-user.target Requires=rtl_tcp@.service [Service] Type=simple WorkingDirectory=/home/pi/dist11/ ExecStartPre=/bin/sleep 5 ExecStart=/home/pi/dist11/websdr-rpi /home/pi/dist11/websdr-%Im.cfg Restart=on-abort [Install] WantedBy=multi-user.target
%I is the band variable. So I can use systemctl start firstname.lastname@example.org to just start the 40-meter band receiver, and, of course, systemctl start email@example.com for 80-meter band receiver.
And using crontab, I made a software switch for both bands. But, but but but…
40 and 80 meter band doesn’t use the same antenna. So I need something to manage two antennas in one receiver. Something like.. An antenna switch
I can use a GPIO pin from my Raspberry PI to handle the antenna switching. Challenge sorted.
Doing some tests we noticed that our RTLSDR receiver isn’t going very well below 30 Mhz due to bandpass filters, amplifiers and discriminators inside the RTLSDR board. So….
Listen to under-30mhz bands, without losing any reception signal/level. So we got a 100Mhz Upconverter.
An upconverter uses a local oscillator running at very high frequency (100Mhz is very high compared to 3.5-7Mhz heh) mixed with the receiver frequency creating an Heterodyne. So if you want to hear 7100 Khz, you must tune 107100 Khz. (7100 + 100000). But but but…
That would show us we are tuning 107100 khz on our websdr webpage, and that doesn’t look really good, as long as it’s not the real tuned frequency. Thankfully, WebSDR has a parameter to fix this
progfreq x In case you have external SDR hardware of which the WebSDR software controls the frequency (practically speaking: RTL-SDRs), this setting can be used to specify to what frequency (in kHz) the hardware should be programmed, different from centerfreq. This is useful in case of use with an up/down converter.
But but but, Pieter said to me at the first email:
Note that due to a bug in this version, you may need to restart the rtl_tcp driver after starting the WebSDR for it to be programmed correctly for use with a converter (which may be inside your "generic" receiver).
So I wrote a new bash script to fix this:
#!/bin/bash if pgrep -x "websdr-rpi" > /dev/null then echo "Running" else sudo systemctl start websdr@$1.service sudo kill -9 `pidof rtl_tcp` sleep 3 sudo renice -10 `pidof websdr-rpi` sudo renice -10 `pidof rtl_tcp` if [ "$1" == "40" ]; then echo 1 > /sys/class/gpio/gpio3/value else echo 0 > /sys/class/gpio/gpio3/value fi fi
The script checks if websdr-rpi is working, if it’s working it just print “Running”. If not:
- Starts the websdr receiver at desired band (as an argument)
- kills rtl_tcp process.
- due to Restart=on-abort setting on rt_tcp systemctl unit file, rtl_tcp brings again after websdr. This is the proposed fix by Pieter.
- renice both rtl_tcp and websdr-rpi processes in order to get a smoother operation, since both of them now have higher priority.
- then, if we’re operating on 40 meter band, GPIO3 takes a “power-on” value, which means the relay must be activated to select the second antenna.
This script is part of my cron and runs every minute. If websdr-rpi fails, exits, crashes or whatever, cron will bring it up again in a minute (or less). Done? no.
We’ve been doing a lot of tests, setting up websdr, rtl_tcp parameters, tuning wifi connection, trying to get a super standalone raspberry pi setup but, but but but. We missed something.
Been using both 40 and 80 meter antennas thru a Yaesu FF-501 LPF/HPF filter, who grants us an incredible clean signal. We noticed that when doing some other tests and we connected the RTL-SDR source directly to the antennas, then we got a LOT of noise. So for now we are working on a compact low pass filter to get rid of all those noise.