Sunday 2 April 2017

Web-enable the Tivoli model One with style

Turn your Tivoli Audio Model One into a web radio with Onion.io's Omega2


EDIT: you can now have a look at the build here on youtube.

Model One downsides

My Model One suffers from a few shortcomings:
  • interference from the switching power supplies of the kitchen lights
  • FM reception limited to local stations
  • AM unuseable because of interference
  • no short- or longwave reception
This particular Model One is the old version without the individual AUX setting. So with a plug in the AUX input, AM/FM reception is impossible.

So what I need is an underpiece to match the style of the Model One that provides reception of all my favourite stations, both domestic and foreign.


Underpiece design idea

Onion.io Omega2

When I was contacted by Randolf from Onion.IO, if I wanted to have a go at the Onion2, this looked like the ideal system to upgrade my Model One:

  • below 1 W power consumption (including USB audio dongle)
  • GPIOs easily accessible with the expansion dock (also has a serial-usb bridge and power regulator)
  • supported usb audio dongle available
  • all packages required for my project already available

Easy as Pi

I work with linux systems for a living and have quite a few RaspberryPis scattered around the house. I have also done projects with OpenWRT systems, so getting the Omega2 to work was an easy task. It is also extremely well documented.

Test setup


How it works

I designed the underpiece to have six pushbuttons. Each one connects one of the GPIO pins to the 3V3 rail.

The resistors are a bit of an afterthought. Still simple enough.



The command:
gpioctl dirin 1
sets GPIO #1 as an input. It's state can be queried with:

root@Omega-8D3B:/etc# gpioctl get 1
Using gpio pin 1.
Pin 1 is LOW
root@Omega-8D3B:/etc#

If scripted, this output needs a bit of tidying. I couldn't figure out where to get the value from the sysfs. If anyone knows, please let me know.

The only additional piece of software needed is mpg123 simply installed by:

opkg install mpg123

(You might need to run opkg update first)

On a microcontroller, reacting to the push of a button would normally be a job for an interrupt. The following script works without that. At the cost that the button has to be pressed for up to a second.

So when I momentarily connect any of the GPIOs (with the exception of GPIO6) to 3.3V, the script starts mpg123 with the appropriate stream URL.

The "radio.sh" script to be placed in /usr/bin

 #!/bin/ash

        gpioctl dirin 0
        gpioctl dirin 1
        gpioctl dirin 2
        gpioctl dirin 3
        gpioctl dirin 6
        gpioctl dirin 7
        gpioctl dirin 8
        gpioctl dirin 9


         COUNTER=0
         while [  $COUNTER -lt 100 ]; do
        #     echo The counter is $COUNTER
        #     let COUNTER=COUNTER+1


BUTTON0=$(gpioctl get 0 | grep Pin | cut -b 10)
BUTTON1=$(gpioctl get 1 | grep Pin | cut -b 10)
BUTTON2=$(gpioctl get 2 | grep Pin | cut -b 10)
BUTTON3=$(gpioctl get 3 | grep Pin | cut -b 10)
#BUTTON6=$(gpioctl get 6 | grep Pin | cut -b 10)
BUTTON7=$(gpioctl get 7 | grep Pin | cut -b 10)
BUTTON8=$(gpioctl get 8 | grep Pin | cut -b 10)
BUTTON9=$(gpioctl get 9 | grep Pin | cut -b 10)


if [ $BUTTON0 = 'H' ]; then
killall mpg123
               echo starting radio mode
                echo BBC 1
mpg123 http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p &
            fi


if [ $BUTTON1 = 'H' ]; then
killall mpg123
               echo starting radio mode
                echo BBC-World
mpg123 http://bbcwssc.ic.llnwd.net/stream/bbcwssc_mp1_ws-einws &
            fi



if [ $BUTTON2 = 'H' ]; then
killall mpg123
               echo starting radio mode
                echo France inter
mpg123 http://direct.franceinter.fr/live/franceinter-midfi.mp3 &
            fi

#world: http://bbcwssc.ic.llnwd.net/stream/bbcwssc_mp1_ws-einws

if [ $BUTTON3 = 'H' ]; then
killall mpg123
               echo starting radio mode
                echo SWR3
mpg123 http://swr-mp3-m-swr3.akacast.akamaistream.net/7/720/137136/v1/gnl.akacast.akamaistream.net/swr-mp3-m-swr3 &
            fi


#if [ $BUTTON6 = 'H' ]; then
#killall mpg123
#               echo starting radio mode
#               echo D-Radio
#mpg123 http://stream.dradio.de/7/249/142684/v1/gnl.akacast.akamaistream.net/dradio_mp3_dlf_m &
#            fi


if [ $BUTTON9 = 'H' ]; then
killall mpg123
               echo starting radio mode
                echo D-Radio Kultur
mpg123 http://stream.dradio.de/7/530/142684/v1/gnl.akacast.akamaistream.net/dradio_mp3_dkultur_m &
            fi


if [ $BUTTON8 = 'H' ]; then
killall mpg123
               echo starting radio mode
                echo D-Radio Wissen
mpg123 http://stream.dradio.de/7/698/142684/v1/gnl.akacast.akamaistream.net/dradio_mp3_dwissen_s &
            fi


        sleep 1
         done


The script is called from the file /etc/rc.local, so it starts when the Omega2 reboots:

 # Put your custom commands here that should be executed once  
 # the system init finished. By default this file does nothing.  
 /usr/bin/radio.sh & > /dev/null  
 exit 0  





5 comments:

  1. I have try this radio play good not save in omega2+
    some body help me how save code into omega2
    thanks

    ReplyDelete
    Replies
    1. With root-provileges, you should be able to copy the script to /usr/bin
      This is a non-volatile file system in the module's flash memory. Usually mounted r/w, so there should not be any issues. Can you explain the problem in more detail?

      Delete
  2. Hi,
    Earlier a year back i use it run for stations like http://airraagam-lh.akamaihd.net/i/airraagam_1@507820/master.m3u8. But after updating the image to latest version am getting error
    [mpg123.c:605] error: Unknown mpeg MIME type application/vnd.apple.mpegurl - is it perhaps a playlist (use -@)?

    [mpg123.c:606] error: If you know the stream is mpeg1/2 audio, then please report this as mpg123 bug

    should i go backand install the old image

    ReplyDelete
    Replies
    1. I haven't upgraded my image for ages. So I can't give any recommendations.

      Delete
  3. Hello, when I replace the radio links first no playing state works great. And if I touch a button my radio channels work but I cant change them. Your code and channels work perfectly

    ReplyDelete