• Tag Archives bash
  • MP3 streaming of RTL-SDR receivers

    I have just made some progress with something I had been researching for some time. With the rtl-sdr software and the widely available USB DVB-T sticks it is possible to implement a cheap SDR receiver. I wondered whether it is possible to grab the sound output of the rtl_fm low cpu usage receiving utility and convert it into an MP3 stream.

    I came across this post on the Raspberry Pi forum and tried to make it work. After some messing around with settings I succeeded. The commands I am using are as follows:

    rtl_fm -s 22050 -f 145.575M -l 0  - | lame -b 32 -r -s 22.050 -m m -  | ezstream -c /etc/ezstream.xml

    Basically, it runs rtl_fm, sends the output the lame mp3 encoder which sends its ouput to the ezstream icecast stream generator. /etc/ezstream.xml is as follows:

    <ezstream>
            <url>http://dynode.nl:8000/rpi-rtl_fm-test</url>
            <sourcepassword>xxxxxxxx</sourcepassword>
            <format>MP3</format>
            <filename>stdin</filename>
            <!--
             Important:
             For streaming from standard input, the default for continuous streaming
             is bad. Set <stream_once /> to 1 here to prevent ezstream from spinning
             endlessly when the input stream stops:
            -->
            <stream_once>1</stream_once>
            <!--
             The following settings are used to describe your stream to the server.
             It's up to you to make sure that the bitrate/quality/samplerate/channels
             information matches up with your input stream files.
            -->
            <svrinfoname>RPi rtl_fm test stream</svrinfoname>
            <svrinfourl>www.dynode.nl</svrinfourl>
            <svrinfogenre>hamradio</svrinfogenre>
            <svrinfodescription>RPi rtl_fm test stream</svrinfodescription>
            <svrinfobitrate>32</svrinfobitrate>
            <svrinfoquality>2.0</svrinfoquality>
            <svrinfochannels>1</svrinfochannels>
            <svrinfosamplerate>44100</svrinfosamplerate>
            <!-- Turn off YP directory advertising -->
            <svrinfopublic>0</svrinfopublic>
        </ezstream>
    

    I run a dedicated icecast server on a separate server but it should be possible to host this on the RPi itself. The stream takes up about half of the RPi’s processor capacity. Currently, squelch does not work because it seems rtl_fm stops sending data when the squelch is on, causing lame and ezstream to stop. A possible workaround is to have rtl_fm output to the RPi line-out and generate the icecast stream from the line-in of another USB sound card plugged into the RPi. To solve this in software looks more elegant to me.


  • Old Android phone = cheap IP cam

    So, I got me a new Samsung phone because my old phone, a HTC Wildfire is rather slow, especially when it comes to websurfing. It also has low crap resolution. I am much happier with the new phone. So, what to do with the old phone? It’s still a small computer with a camera and touchscreen that should be doing something instead of gathering dust in a drawer.

    One of the things I thought of was a webcam for my turtle tank. It currently houses two (I think female) red cheeked mud turtles, kinosternon cruentatum. I wanted to observe how often one of turtles gets out of the water to bask and what the general activity in the tank is.

    I rooted the phone since I thought it would be handy to have root anyway and installed Cyanogenmod V7, an alternative Android version. This custom ROM does not include the Google Play store to install stuff on Google Play so I had to manually flash it. I am quite unexperienced rooting Android phones and installing custom software but I got it working eventually.

    Next I installed IP Webcam, a nice free webcam app. Since it has a webinterface for remote access it is easily accessible with any computer. Being http-based it’s very easy to grab the images over the wireless LAN that the phone is on using a bash script:

    #!/bin/sh
    wget http://192.168.64.4:8080/shot.jpg
    FILEDATE=$(date)
    montage -geometry +0+0 -background white -label "$FILEDATE" ~/shot.jpg /var/www/meuk/schildpadcam.jpg
    mv ~/shot.jpg /storage/plaatjesenfotoos/schildpadcam_arch/"$(date +%d%m%y%H%M)".jpg

    This script uses wget to fetch the most recent video frame (the app is capturing video all the time), uses the imagemagick tool montage to visually timestamp the image and outputs a new picture in a publicly accessible folder on my server. Finally, the most recently downloaded picture is renamed with a timestamp in the filename and moved to a archive directory on the server. Continue reading  Post ID 1481


  • Arduino environment monitor

    Above is a picture of my recently (practically ) finished project. It is a sort of weather station which measures light, temperature, relative humidity, atmospheric pressure, and of course radioactivity!

    The core of this setup is the excellent DIY Geiger Counter PCB by [Brohogan]. This kit is a geiger counter circuit combined with a standalone Arduino circuit. Most people buy this kit, connect an LCD and put it in a nice box. Because the Atmega328 pins are broken out via handy pin sockets it is very easy to connect any additional components and/or sensors to this PCB. Continue reading  Post ID 1481