I have an old Tivoli PAL radio that I wanted to upgrade to get web radio. For the task, I chose to use an Onion Omega2, for a few reasons:
- It's cheap, the omega2 costs $5
- It's small
- It can handle being unplugged without corrupting the memory
My goal is to achieve the following:
- Play web radio when the power button is in the FM position
- Stream Bluetooth audio when the power button is in the AM position (Alternatively, use Airplay when the knob is in the AM position, guides for that are readily available)
- Use the tuner knob to chose web radio stream
- preserve the mini-jack input for later use
I've made two external modifications to the radio to achieve this: swapping the green LED for an RGB LED, and removing the FM antenna in favor of a WiFi antenna.
This is still a developing project, so the description is lacking, but it should be possible to use :-)
Parts- 1 Onion Omega2
- 1 ATTiny85
- 1 USB audio card
- 1 potentiometer
- PCB (or protoboard)
- 2mm header pins
- 1 RGB LED
- 1 small clear LED
- 1 WiFi antenna with UNF cable
- 1 Buck DC converter
The first step is to remove the tuner PCB.
The old tuner card needed to go, as I needed the room. I've also plucked out the green LED, in order to put in an RGB LED. As it turned out, I couldn't find an RGB LED that fit in the tiny hole in the Tivoli Radio, so I used a small clear LED, clipped of the tip and glued in the hole to use as a "lens" for the larger LED, which I glued on the back of the "lens"
The next step is to detect the position of the power button. This way, the Omega can turn off the stream when the radio is off, and can later be expanded to stream bluetooth. Shown below is the pins of the power button
I hooked up a multimeter, to check which pins were grounded in each button position, and got the following:
As it turned out, some of the pins are always grounded, but each button state has one pin each grounded. Pins 1, 2, and 6 are always grounded, but pins 5, 9 and 10 are only grounded in the OFF, FM and AM position respectively.
To measure the button position, I fed 3.3V to each "to-be-grounded" pin through a large resistor (110k), and measured the voltage at the pin. If the pin is grounded, the voltage will read as low, if the pin is not grounded, the voltage will read as high. The resistor prevents current from moving to the ground when the pin is grounded.
With this in place, it is now possible for the omega2 to know which position the power button is in, and act accordingly (play web radio or bluetooth).
Measuring Tuner Knob PositionNext, we need to measure the position of the tuner knob. This will be used to select the radio stream.
The tuner knob is geared down, so the operation of it feels quite smooth. It also only rotates about half a rotation.
The tuner knob position was measured using a potentiometer. It doesn't really matter what resistance it has, but it shouldn't be too low, as it will then let current pass through it.
Get External Inputs to the OmegaThe Omega doesn't have any analog inputs, and I couldn't get any SPI ADCs to work, so I ended up using an ATtiny85. I programmed the ATtiny using an Arduino, as explained in this guide, and in this video
The bonus with this setup, is that the ATtiny can do a lot of the work that the omega would otherwise do, detect both the tuner knob and the power button, divide the tuner knob positions into one zone for each channel, and a few other things. Bottom line: The ATtiny gives the Omega instructions through serial communication, and the Omega only has to listen from instructions from the ATtiny.
Stripping Down the USB Audio AdapterThe Omega doesn't have any audio outputs, so we need to add that.
I bought a cheap USB sound card from ebay to play audio. To minimize it, I removed the cable, plug and casing.
I also chose to solder the audio cable directly on the PCB, in stead of using a mini-jack plug.
I only soldered on the signal wire for one of the audio channels, since the Tivoli radio only has a single speaker.
The PCB now contains the following:
- Omega2
- Buck 3.3V regulator
- ATTiny85
- Potentiometer
- USB audio card
Set up WiFi using the following;
wifisetup
Type in the correct information for your WiFi. Verity that you are connected by running
ping www.google.com
If you are still not connected, try running
wifimanager
This will reapply the network settings.
Update the firmware by running
opkg update
oupgrade
install the necessary programs to the onion by running the following:
opkg update
opkg install python-light python-logging python-pyserial alsa-lib alsa-utils mpg123 libmpg123 pyOnionGpio
Download the OnionRadio.py python file to the /root folder of you omega, along with a channels.txt file. (channels.txt is a simple text file, each line containing the URL of a web radio channel. Modify this to add/remove channels)
Comments