Header Image - Kilo Charlie 4 Romeo Charlie Romeo

Category Archives

4 Articles

Streaming Audio Using Darkice

It is easy to use a Raspberry Pi to stream audio to your own webserver (running on the RPi) or using a global site such as Broadcastify. Though I used a RPi to build this, it is not unique to the RPi and can run on a variety of systems (I have used the same setup on my Ubuntu laptop).

Here’s what you will need:

  • Raspberry Pi (any will work but I use a RPi4 with 4GB RAM)
  • USB Audio Dongle
  • Speaker to Line Audio Converter (build or buy)
  • Scanner (or other radio output device)
  • Assorted audio connectors and cables
  • An Internet connection of course

Assumptions:

  • You have a working knowledge of installing the Raspberry Pi Operating System and can access it on your network or directly from a console setup
  • Your scanner or radio receiving device works and has an antenna and can receive the frequency or range you wish to broadcast
  • You are able to open a port for port forwarding on your Internet router to the port running Icecast (if you want to open the server to the world)

First, get your Raspberry Pi set up however you like with the Raspberry Pi Operating System according to the instructions found here (or using your own method). The instructions here should work for pretty much any modern Debian-based Linux distribution.

Now for the hardware setup. Your scanner or radio’s audio needs to be taken down from speaker level to line level. They do make converters you can buy such as these on Google. But you can also build one. I used this design found here with two 3.5mm jacks for the connections:

Speaker to Line Level Converter from https://www.epanorama.net/circuits/speaker_to_line.html

One note on this, it assumes your scanner is mono so no reason to use a stereo 3.5mm plug. Here’s my built version on the above diagram:

Speaker to Line Converter (using Mono to Stereo Connectors)

On an older version I had a commercial converter shows in this picture:

The SNI-35 Line Output Converter

Now let’s put it all together with the USB Audio device inserted into the RPi and the microphone jack running through the speaker to line converter to the speaker out jack of the scanner. By the way, this setup is in my laundry room because it is opposite the ham antenna side. There will still be some de-sensing on transmit especially with these older scanners. There is an external discone antenna it is connected to (see BC760XLT Scanner Repair for the background story).

RPi with USB Audio Device
Scanner Connected to RPi Audio

Now we move on to the software side of things. Boot up your RPi and once you have the system up and running how you like it, install Darkice via the command:

sudo apt-get install darkice

You will need to create/modify the Darkice configuration file. The default location is in /etc but you can specify an alternate location when you run the darkice command to start your streaming.

There is a great darkice.cfg example at the following link which is the one I used as my starting point on the Raspberry Pi:

https://wiki.radioreference.com/index.php/Live_Audio/Ubuntu_Darkice

You will need to sign up for a Broadcastify feed provider account and get the “mountpoint” and “password” from your account page and input it in the configuration file. Also note you may have to change the configuration slightly depending on your hardware. I had to change the “device” setting to “hw:2,0” and “sampleRate” to “44100” based on my configuration. You can view your hardware location via the “aplay -l” command. NOTE! When I rebooted headless (no monitor) the HDMI connection changed the hardware ports, so be aware this might happen.

Similar to the issue described on the page linked above, Darkice does not reliably restart on reboot. I’ve tried various configurations, running it as root, etc. and nothing has proven effective. If I find a solution I will post it.

Darkice should be run as a normal user, not root. The reason for the comment here is that when you run it as a normal user it will tell you try running as root, that is not needed.

If all is well, run darkice from the command prompt and your feed will show active over at Broadcastify! As I said before, you might have to fiddle around with the sample rate or other settings to get it just right for your configuration. For reference, here is how I start my Darkice instance:

nohup darkice -c /home/pi/darkice.cfg &

The “nohup” signifies No Hangup which leaves the process running after I log out. The “-c” specifies the configuration file and the “&” means run as a daemon/background process. Since I run headless, I ssh into my RPi and start darkice this way from my remote terminal.

BREAK BREAK BREAK… Okay you are done if all you wanted is a Broadcastify feed. But some have asked how you would host streaming audio on your own. the following section describes the additional steps which will be needed to do this.

If you want to run your own server you can install Icecast2. Darkice will feed to Icecast. Install Icecast using apt:

sudo apt-get install icecast2

Icecast will install in /etc/icecast2 and run the auto configure program for you. Be sure to remember your passwords as you will need the source password in the darkice.cfg file. The port you choose to run on (default 8000) is the one you will point your browser to on the RPi IP address. You can always edit the icecast.xml configuration file found in the installed directory mentioned above. Another good install document can be found here. Once you have finished the configuration, run:

sudo systemctl start icecast2

You can always replace “start” with “restart” or “stop”. You can also enable it to always run on reboot with “enable” (or do the opposite with “disable”). Once running you can point your browser to http://yourRPiaddress:port where that is the RPi’s IP and port number you chose in the setup. If you are local, you could use http://127.0.0.1:8000, for example. You should see this:

Icecast2 with no Streams

If that page came up, great news you are almost there. The next step is to feed Darkice into Icecast. You do that by adding an Icecast section to the darkice.cfg file using the password you set up in the Icecast installation for sources. If your darkice.cfg has an “[icecast2-1]” section already you can edit it, otherwise add the following, tailored for your installation:

[icecast2-1]
bitrateMode = abr # average bit rate
format = vorbis # format of the stream: ogg vorbis
bitrate = 96 # bitrate of the stream sent to the server
server = 127.0.0.1
port = 8000 # port of the IceCast2 server, usually 8000
password = SOURCEPWD # source password to the IceCast2 server
mountPoint = KC4RCR # mount point of this stream on the IceCast2 server
name = DarkIce
description = KC4RCR Scanner Traffic
url = http://www.kc4rcr.com
genre = Mostly 2 meter ham repeaters around the VA area
public = no # advertise this stream?

Now restart the service using sudo systemctl restart icecast2 if applicable and go back to your web browser and reload the Icecast page. You should see something similar to the following:

Icecast Streaming

You can also login via your admin password (username admin) and see the stream stats and listener info. It is just one mount point here so that’s all that is displayed. Icecast supports a variety of configurations if you are interested. Visit icecast.org for more information.

BC760XLT Scanner Repair

So the preamble to the story is that I just moved into a new QTH and while my ham gear is protected by multiple ground rods and polyphasers, my scanner was not.

Now, it was a cheap scanner (found on eBay for under $50) connected to a Raspberry Pi 4. It was at the service entry point to the house and I hastily set it up. I used it to live stream audio to a web server on the Pi that I could access with my phone. The antenna was set outside, not raised up much or anything (power lines above). I just needed to pick up the local repeaters when I was away and wanted to listen in. Everything was plugged into a small UPS but I knew the antenna was susceptible. It would work for now until I can get back to it.

The very day I set out to ground and protect the antenna, I was outside trying to get things finished when a freak storm rolled up. Well glad I came in to take a break with the rain because lightning lit up my property (my ham shack was disconnected). I am sure I heard electrical arcing in the house when it hit.

Later that evening I noticed things were offline with the Pi. And as you probably guess from this title blog, my scanner was dead from the lightning induced voltage spike in the antenna. That and the Raspberry Pi were toast.

Dead. Can you find the smoked component? Hint: Upper-left quadrant

Nothing I could do for the Raspberry Pi. No way I could solder that. Next for the scanner. There were no visible marks but it did turn on with distorted garbled audio which faded off to nothing. It smelled of burning electronics. That was GOOD for me! I opened it up and poked around. The part that was smoking was definitely a problem!

That IC was smoking hot!

Looking up the part number it turned out to be an audio amplifier circuit. That made sense why the audio went out! I also tested the voltage regulator (8V as designed according to the part number). Strangely the power supply transformer was putting out 18V instead of 13.5! At least that was within range of the voltage regulator to handle (I changed that out too).

Well I am terrible at soldering and the leads on the printed circuit board burned very easily so I decided to make a modular design (hopefully not to replace often). While waiting on the $5 part, I soldered jumper wires in the IC socket to connect to a solder-less breadboard just awaiting the IC.

Jumpers I use for RPi projects soldered into the IC socket points

Now here is the modular design in action. Luckily the age of the scanner makes for a lot of extra space in the case.

Modular design

And now here is the final product. I wouldn’t want this rattling around in a mobile installation but it works well for a stationary setup. It will have adhesive to keep it somewhat fixed.

Lots of room
All done!

AllStar Node Build

I enjoy ham radio nets and try to reach out to the furthest ones I can pull off with my 2-meter radio and J-pole antenna (81.4 miles is the record to the K3NQT repeater as of this posting on 21 Apr 2020). I have used EchoLink to reach out to some West Coast nets in California and Washington (usually the Puget Sound Repeater Group nets) but I prefer using a radio over my cell phone. Also, building my own AllStar node would allow me the flexibility to control the link. Furthermore, I wanted to join in the East Coast Reflector which I could only break the squelch on the nearest repeater.

Credit goes to K3KDX for providing me with instructions as to how he set up his node which I based this built off of.

East Coast Reflector AllStar connections. See if you can find KC4RCR (Hint: Connected to Node 27339).

Here are the items I used to build the node:

  • Alinco DR-135 MkIII (2 meter single band transceiver)
  • Raspberry Pi (I used a RPi 4 4GB/RAM, but 3B+ is fine)
  • RIM-Alinco (Interface from Pi’s USB to Radio’s DB-9)
  • Dummy Load (Use one sized appropriately, this one is 50W)
  • SMB-201 Cooling Stand (Reuse of this, you can use a cheaper fan)
  • SD Card with HAMVOIP image installed
  • Keyboard, Power, HDMI, Coax and other cables as needed
  • Raspberry Pi Case with fan recommended
  • Register with AllStarLink for a server and node
  • A second radio that is the control point you wish to use

The first recommended step is to register with AllStar. They validate your license and it takes a bit of time for them to set up your node in the database. This only took a few hours in my case, but it’s better to do this ahead of time if you can. You need to register and set up a “server” under the “Portal” menu. The server is just the name and location. Next you have to create a “node” for that server, also under the “Portal” menu. AllStar will take the time to create a node number and password. You will need these in the setup of HAMVOIP.

Next load the HAMVOIP image onto the SD card. Choose a good quality card. I had a Samsung 32 GB card handy, so I used that. The HAMVOIP site has instructions on how to install the image on to the card (if you have not done this before). I already had win32diskimager on a Windows machine so I downloaded the Windows .exe (execute to decompress the image) and used the win32diskimager to write the image to the SD card.

Raspberry Pi 4 / 4 GB version with metal case and fan

Here is how the RIM-Alinco device arrived. It looks of excellent quality. Note that this is a mini-USB not the more common micro-USB. The RIM-Alinco comes with this cord so no worries about finding one if you don’t have it. Install this to the DB-9 connector on the radio. Note the lack of heat sink fins on the bottom side of the radio, we will come back to that later…

RIM-Alinco device as received in packaging
RIM-Alinco connected to the radio’s DB-9 with the provided mini-USB cable connected to a RPi USB Port

I had an unused SMB-201 cooling stand which fits the form-factor exactly. The only catch was the Alinco radio has the majority of the heat sink fins on the top, not the bottom. Originally I set this up facing the “proper” direction.

Alinco on cooling stand, original position

However, look at the above picture. There is a lack of heat sink fins on the bottom side (do not run the length of the radio). While the fan on the bottom still kept the radio at a reasonable temperature (low power), I decided to flip it over for proper cooling. Eventually I’ll make a stand that inverts the entire setup.

Inverted on stand. Fan toward heat sink
Need to invert the whole stand but this is the most efficient position given the side of the heat sink and fan position

Remember, the radio is a node so the TX and RX duty cycles are reversed. That means the TX duty time is the time you are listening on your node channel on your other radio. That is a very heavy duty cycle especially for long nets. I am hoping the Alinco can handle this long term. This is why cooling is extremely important. Also, setting the power at the lowest setting necessary is also very important. Right now I use a dummy load because the radio is nearby. Low power on this radio is listed as <5 Watts. This is 50 Watt dummy load so I have no overheating issues or SWR problems. I measured around 4.5 Watts output at the radio on low power. Oh, and I recommend setting the radio to tone-coded squelch so you don’t rebroadcast other simplex users inadvertently. Set the radio to the simplex frequency you plan to contact your node with.

50W Dummy Load

If not done already, connect everything together as appropriate and power the devices. Set up the RPi to display the HDMI on a monitor/TV and have a USB keyboard plugged in. When you boot the RPi, it will launch the installation program. It will ask for your assigned node number and password (from registering with AllStar). It will also ask you for a number of setting choices. The RIM-Alinco page provided a few seen here:

I noticed my TX was quiet, so I modified a few settings. Don’t worry you can always go back in and adjust things as needed. When you boot from now on you will see this screen allowing you to modify the settings as needed. I performed the system updates after I set up WiFi. There is also an echo function in the simpleusb-tune program which helped me set the audio levels.

Here are the settings directly from my configuration files: simpleusb.conf and simpleusb_tune_usb.conf.

AllStar has a list of commands you give the node over the radio (starting with a “*”). I prefer to use the command line (Asterisk CLI client). That way I’m not keying the radio all the time to issue commands via RF. This is not necessary but a preference on my part.

Connecting my node (51461) to node 27339 (East Coast Reflector)

That’s all there is to it! It took me no more than an hour to set up. The hardest part was waiting for the parts to arrive.

I’ve also set up the node to relay weather information using the AutoSky SkyWarn module. Setup can be found here from HAMVOIP.

Next, I plan to dual-purpose the Alinco. Since it’s a well-performing 2-meter radio, I want to use this as a base-station as well when not in use on a node. I have programmed a momentary switch in Python which is connected to the RPi GPIO pins to shutdown and restart the AllStar node asterisk service. That way I can disable the node and use the radio as a normal 2-meter transceiver when I want without having to SSH to the RPi and turn off the node. Once I formalize this, I will publish the process and Python code.

Raspberry Pi Projects

by admin 2 Comments

This page will be where I post about the Raspberry Pi projects I have created or are working on.

Years ago I learned C++ extensively (my Computer Science degree). I started looking into Raspberry Pis in 2019 and started learning the Python programming language.

I’ve written a lot of home security programs, home automation and also stream my favorite local repeater.

I’ll write more here about the projects soon.