User avatar
VeryNoob
Posts: 49
Joined: Thu Feb 14, 2013 1:07 pm
Location: Australia

Lunchbox Internet Radio Guide

Thu May 08, 2014 4:55 pm

It took me a while to build this, as I have never programmed in anything other than BASIC, and I've never used Linux. The write up isn't as detailed as I'd like, but maybe if I get time, I'll come back to it, and make it more detailed.

What I've made is a radio with 6 buttons and a 20x4 LCD screen. There is an "ON" button, and "OFF", "BACK", "PLAY", "STOP" and "NEXT". It is connected to the internet via WiFi, and it powered by a USB hub connected through a Pi-Supply (http://www.pi-supply.com/product/pi-sup ... er-switch/) so I get a proper shut down. And I use a USB sound card, as the quality of the on board is low at best. I run it through my home stereo, and the USB sound card pumps out a much better line volume, so when I am switching from CD to the Raspberry Pi, I don't get big volume changes. I don't change the volume on the Raspberry Pi itself.

Image
http://oi57.tinypic.com/2zq4o3t.jpg

Image
http://oi62.tinypic.com/2qmhmcm.jpg

Most of this work is based on bits and pieces from other people. The biggest influence is Meistervision (http://www.youtube.com/watch?v=KM4n2OtwGl0) who did a really great video of how to build a radio. My wiring is different, my switching method is different, so please don't try to follow both guides for the one project.

Parts
  • * Raspberry Pi (Model B rev 2)
    * A powered USB hub
    * USB sound card
    * WiFi Dongle
    * An SD Card, at least 4gb.
    * 1k Resistors
    * 10k Resistors
    * 20x4 LCD with a Hitachi HD44780 chip.
    * 6x momentary switches
    * 2 variable resistors. This is for contrast and backlight adjustment.
    * Wires, usb cables, etc.
    * A lunch box
    * A Humble Pi (http://shop.ciseco.co.uk/k001-humble-pi/)
Raspberry Pi Setup
First I installed Raspbian (Wheezy). Downloaded from http://www.raspberrypi.org/downloads, and installed by following this procedure http://elinux.org/RPi_Easy_SD_Card_Setu ... on_Windows

I then installed PuTTY (http://portableapps.com/apps/internet/putty_portable). I connected my raspberry pi via ethernet, turned it on, used my router to find the IP address of the Raspberry Pi, and then used PuTTY to log in via SSH. All this info is in just about any beginers guide you will find. But a tip. Don't plug in your wi-fi dongle yet, as it might try to use that instead of the ethernet.

I ran "raspi-config" (http://elinux.org/RPi_raspi-config), and expanded the card, and made sure it didn't boot to desktop.

Then I ran
sudo apt-get update
to update the list of all the programs I can download.

Then to upgrade all the installed software to the latest version. Type in;
sudo apt-get upgrade

Now I add the MPD to play music, MPC to control the music player, and python to do the programing
sudo apt-get install python mpd mpc

The next step is to set up the wi-fi and fix the IP address. To load up the editor to the correct file type in
sudo nano /etc/network/interfaces

My file looks like this

Code: Select all

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.60
netmask 255.255.255.0
gateway 192.168.0.1
wpa-ssid NameOfYourWiFi
wpa-psk YourWiFiPassword

iface default inet static
To exit hit ctrl-x, then press y for yes, then hit enter to keep the same name.

Then type in
sudo shutdown -h now to turn off the Raspberry Pi. It doesn't actually turn off. Wait until the lights stop flashing (give it a minute or two), then turn off the power. Unplug the ethernet, and plug in your wi-fi. Now turn it back on. You can then check it's all worked by using PuTTY to log back on, with the new address you have assigned.

By default the RPi wants to use it's own sound card. So we need to change this.
used the text editor again.
sudo nano /etc/modprobe.d/alsa-base.conf
My alsa-base.conf file looks like this

Code: Select all

# autoloader aliases
install sound-slot-0 /sbin/modprobe snd-card-0
install sound-slot-1 /sbin/modprobe snd-card-1
install sound-slot-2 /sbin/modprobe snd-card-2
install sound-slot-3 /sbin/modprobe snd-card-3
install sound-slot-4 /sbin/modprobe snd-card-4
install sound-slot-5 /sbin/modprobe snd-card-5
install sound-slot-6 /sbin/modprobe snd-card-6
install sound-slot-7 /sbin/modprobe snd-card-7
# Cause optional modules to be loaded above generic modules
install snd /sbin/modprobe --ignore-install snd && { /sbin/modprobe --quiet snd-ioctl32 ; /sbin/modprobe --quiet snd-seq ; : ; }
install snd-rawmidi /sbin/modprobe --ignore-install snd-rawmidi && { /sbin/modprobe --quiet snd-seq-midi ; : ; }
install snd-emu10k1 /sbin/modprobe --ignore-install snd-emu10k1 && { /sbin/modprobe --quiet snd-emu10k1-synth ; : ; }
# Keep snd-pcsp from beeing loaded as first soundcard
options snd-pcsp index=-2
# Keep snd-usb-audio from beeing loaded as first soundcard
# options snd-usb-audio index=-2
# Prevent abnormal drivers from grabbing index 0
options bt87x index=-2
options cx88_alsa index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2
We need a playlist started.

mpc add http://7659.live.streamtheworld.com:80/977_80AAC_SC
mpc add http://www.bbc.co.uk/worldservice/meta/ ... _au_nb.asx
mpc add http://www.bbc.co.uk/worldservice/meta/ ... _au_nb.asx

So we have three radio streams in our playlist now. You can add more if you want.

If you want to delete a stream you use
MPC delete 3

I've just used these streams as an example. You can come back anytime and add or take streams.

So now lets listen to something.
mpc play

To go to the next track the command is
mpc next

and to go back it is
mpc prev

to stop then go
mpc stop

if you want to play a specific track then you can use
mpc play 1

Pi Supply
It took a lot of searching to find this, but I am really glad I did. One of the downsides of the Raspberry Pi is that is has no way to turn it off, without unplugging it. This little gadget lets you run a software shutdown then disconnects the power. When I soldered mine up, I left off the switches, I don't need the hard off switch, as I can unplug it. For the on and shutdown switch, I soldered on headers instead, and ran them to a switch that I could mount on the face of my lunchbox. Pins 7&8 on the Pi-Supply go to my humble pi for the interface to the rapsberry pi GPIO.

I then soldered up the humble pi with all the bit I needed, connected it to the raspberry pi, LCD, buttons and Pi-Supply. Below is a diagram of the way I laid out the board.
Image
http://oi62.tinypic.com/5yuqoh.jpg

When I put it all back together, I logged into PuTTy again and made a new python script called "radio.py"
sudo nano radio.py
the contents of this script is

Code: Select all

#!/usr/bin/python
# Script for Raspberry Pi Internet Radio
#Notes at botton of script

#import
import RPi.GPIO as GPIO
import time
import os

# Define GPIO to LCD mapping
LCD_RS = 25 # LCD Pin 4
LCD_E  = 8 # LCD Pin 6
LCD_D4 = 4 # LCD Pin 11
LCD_D5 = 10 # LCD Pin 12
LCD_D6 = 9 # LCD Pin 13
LCD_D7 = 11 # LCD Pin 14

# Define GPIO for Radio Controls
PREV = 27
NEXT = 24
PLAYBUTTON = 22
STOPBUTTON = 23
POWEROFF = 7
#VOLUMEUP = 17
#MUTE = 2
#RELOAD = 3

# Define some device constants
LCD_WIDTH = 20    # Maximum characters per line
LCD_CHR = True
LCD_CMD = False

LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line
LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line
LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line
LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line 

# Timing constants
E_PULSE = 0.00005
E_DELAY = 0.00005

# What do you want the display to say when it's loading
startupline1 = "+------------------+"
startupline2 = "|   Raspberry Pi   |"
startupline3 = "|  Internet Radio  |"
startupline4 = "+------------------+"

def main():
  # Main program block

  GPIO.setmode(GPIO.BCM)       # Use BCM GPIO numbers
  GPIO.setup(LCD_E, GPIO.OUT)  # E
  GPIO.setup(LCD_RS, GPIO.OUT) # RS
  GPIO.setup(LCD_D4, GPIO.OUT) # DB4
  GPIO.setup(LCD_D5, GPIO.OUT) # DB5
  GPIO.setup(LCD_D6, GPIO.OUT) # DB6
  GPIO.setup(LCD_D7, GPIO.OUT) # DB7
  
  GPIO.setup(NEXT, GPIO.IN) # Next Track
  GPIO.setup(PREV, GPIO.IN) # Previous Track
  GPIO.setup(PLAYBUTTON, GPIO.IN) # Play
  GPIO.setup(STOPBUTTON, GPIO.IN) # Stop
  GPIO.setup(POWEROFF, GPIO.IN) # Volume Up by 5
#  GPIO.setup(VOLUMEDOWN, GPIO.IN) # Volume Down by 5
#  GPIO.setup(MUTE, GPIO.IN) # Set Volume to Zero
#  GPIO.setup(RELOAD, GPIO.IN) # Stops the music, sets the volume to 80% and then plays track 1

  
  
  
  # Initialise display
  lcd_init()
  # Send some test
  lcd_byte(LCD_LINE_1, LCD_CMD)
  lcd_string(startupline1,2)
  lcd_byte(LCD_LINE_2, LCD_CMD)
  lcd_string(startupline2,2)
  lcd_byte(LCD_LINE_3, LCD_CMD)
  lcd_string(startupline3,2)
  lcd_byte(LCD_LINE_4, LCD_CMD)
  lcd_string(startupline4, 2)	 
  os.system("mpc play 1")
  time.sleep(2) 
  while 1:
	  if ( GPIO.input(NEXT) == False ):
		os.system("mpc next")

	  if ( GPIO.input(PREV) == False ):
		os.system("mpc prev")

	  if ( GPIO.input(PLAYBUTTON) == False ):
		os.system("mpc play")

	  if ( GPIO.input(STOPBUTTON) == False ):
		os.system("mpc stop")

	  if ( GPIO.input(POWEROFF) == True ):
		os.system("mpc stop")
		os.system("sudo shutdown -h now")

#	  if ( GPIO.input(VOLUMEDOWN) == False ):
#		os.system("mpc volume -5")

#	  if ( GPIO.input(MUTE) == False ):
#		os.system("mpc volume 0")

#	  if ( GPIO.input(RELOAD) == False ):
#		os.system("mpc stop")
#		os.system("mpc volume 80")
#		os.system("mpc play 1")

	  f=os.popen("mpc current")
	  station = ""
	  for i in f.readlines():
		station += i
          station = station + " " * 80
          stationa=station[0:20]
          stationb=station[20:40]
          stationc=station[40:60]
          stationd=station[60:80]

	  # Send some text
	  lcd_byte(LCD_LINE_1, LCD_CMD)
	  lcd_string(stationa,1)
	  lcd_byte(LCD_LINE_2, LCD_CMD)
	  lcd_string(stationb,1)
          lcd_byte(LCD_LINE_3, LCD_CMD)
	  lcd_string(stationc,1)
	  lcd_byte(LCD_LINE_4, LCD_CMD)
          lcd_string(stationd,1)
         	 

#          lcd_byte(LCD_LINE_1, LCD_CMD)
#          lcd_string("--------------------",1)
#          lcd_byte(LCD_LINE_2, LCD_CMD)
#          lcd_string("Raspberry Pi Radio",1)
#          lcd_byte(LCD_LINE_3, LCD_CMD)
#          lcd_string(station,1)
#          lcd_byte(LCD_LINE_4, LCD_CMD)
#          lcd_string("--------------------",1)

	 		
   
  time.sleep(20)

def lcd_init():
  # Initialise display
  lcd_byte(0x33,LCD_CMD)
  lcd_byte(0x32,LCD_CMD)
  lcd_byte(0x28,LCD_CMD)
  lcd_byte(0x0C,LCD_CMD)  
  lcd_byte(0x06,LCD_CMD)
  lcd_byte(0x01,LCD_CMD)  

def lcd_string(message,style):
  # Send string to display
  # style=1 Left justified
  # style=2 Centred
  # style=3 Right justified

  if style==1:
    message = message.ljust(LCD_WIDTH," ")  
  elif style==2:
    message = message.center(LCD_WIDTH," ")
  elif style==3:
    message = message.rjust(LCD_WIDTH," ")

  for i in range(LCD_WIDTH):
    lcd_byte(ord(message[i]),LCD_CHR)

def lcd_byte(bits, mode):
  # Send byte to data pins
  # bits = data
  # mode = True  for character
  #        False for command

  GPIO.output(LCD_RS, mode) # RS

  # High bits
  GPIO.output(LCD_D4, False)
  GPIO.output(LCD_D5, False)
  GPIO.output(LCD_D6, False)
  GPIO.output(LCD_D7, False)
  if bits&0x10==0x10:
    GPIO.output(LCD_D4, True)
  if bits&0x20==0x20:
    GPIO.output(LCD_D5, True)
  if bits&0x40==0x40:
    GPIO.output(LCD_D6, True)
  if bits&0x80==0x80:
    GPIO.output(LCD_D7, True)

  # Toggle 'Enable' pin
  time.sleep(E_DELAY)    
  GPIO.output(LCD_E, True)  
  time.sleep(E_PULSE)
  GPIO.output(LCD_E, False)  
  time.sleep(E_DELAY)      

  # Low bits
  GPIO.output(LCD_D4, False)
  GPIO.output(LCD_D5, False)
  GPIO.output(LCD_D6, False)
  GPIO.output(LCD_D7, False)
  if bits&0x01==0x01:
    GPIO.output(LCD_D4, True)
  if bits&0x02==0x02:
    GPIO.output(LCD_D5, True)
  if bits&0x04==0x04:
    GPIO.output(LCD_D6, True)
  if bits&0x08==0x08:
    GPIO.output(LCD_D7, True)

  # Toggle 'Enable' pin
  time.sleep(E_DELAY)    
  GPIO.output(LCD_E, True)  
  time.sleep(E_PULSE)
  GPIO.output(LCD_E, False)  
  time.sleep(E_DELAY)   

if __name__ == '__main__':
  main()

# 
# Author: Kyle Prier
# Site: http://wwww.youtube.com/meistervision
# 
# LCD author : Matt Hawkins
# Site   : http://www.raspberrypi-spy.co.uk/
# 
# Date   : 10/01/2012

# The wiring for the LCD is as follows:
# 1 : GND
# 2 : 5V
# 3 : Contrast (0-5V)*
# 4 : RS (Register Select)
# 5 : R/W (Read Write)       - GROUND THIS PIN! We do not want the LCD to send anything to the Pi @ 5v
# 6 : Enable or Strobe
# 7 : Data Bit 0             - NOT USED
# 8 : Data Bit 1             - NOT USED
# 9 : Data Bit 2             - NOT USED
# 10: Data Bit 3             - NOT USED
# 11: Data Bit 4
# 12: Data Bit 5
# 13: Data Bit 6
# 14: Data Bit 7
# 15: LCD Backlight +5V
# 16: LCD Backlight GND (Red)
# 17: LCD Backlight GND (Green)
# 18: LCD Backlight GND (Blue)
Now to have the radio load when the RPi boots up edit the /etc/rc.local
sudo nano /etc/rc.local

Code: Select all

#!/bin/sh -e
#sudo 
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi
sudo python /home/pi/radio.py

exit 0
OK. Reboot (sudo reboot) and when the RPi starts up, your radio should be working, and you should have a Previous, Play, Stop and Next button all working. You can also shut down and turn the radio on with the buttons.

There are a few things I want to do, but I haven't figure out yet
  • - Make the text wrap at spaces, not just at a set length
    - Have the first line show the text I assign to each station, not just what MPC spits out
    - automatically load a playlist off the network when it reboots, so I don't have to SSH in to change it.
If you have any ideas on how do these, please let me know.
So that is it for the guide for now. If I get time, I might add more detail.

Dan Lavin
Posts: 11
Joined: Wed Oct 23, 2013 7:36 pm

Re: Lunchbox Internet Radio Guide

Thu May 08, 2014 8:39 pm

Pretty awesome job for a first project and a noob! Excellent write-up as well!

dan11
Posts: 32
Joined: Wed Feb 05, 2014 10:01 am

Re: Lunchbox Internet Radio Guide

Mon May 12, 2014 4:36 pm

My problem is adding new radios to the playlist. If I add the three ones that you said to the usualpanic playlist it doesn't work. It only works the playlist from here to me:

http://www.raspberrypi.org/forums/viewt ... 51#p547551

Please, any help?

User avatar
VeryNoob
Posts: 49
Joined: Thu Feb 14, 2013 1:07 pm
Location: Australia

Re: Lunchbox Internet Radio Guide

Sun May 25, 2014 8:15 am

Cleaned up a bit

Code: Select all

#!/usr/bin/python
# Script for Raspberry Pi Internet Radio

#import
import RPi.GPIO as GPIO
import time
import os

# Define GPIO to LCD mapping
LCD_RS = 25 # LCD Pin 4
LCD_E  = 8 # LCD Pin 6
LCD_D4 = 4 # LCD Pin 11
LCD_D5 = 10 # LCD Pin 12
LCD_D6 = 9 # LCD Pin 13
LCD_D7 = 11 # LCD Pin 14

# Define GPIO for Radio Controls
PREV = 27
NEXT = 24
PLAYBUTTON = 22
POWEROFF = 7

# Define some device constants
LCD_WIDTH = 20    # Maximum characters per line
LCD_CHR = True
LCD_CMD = False

LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line
LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line
LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line
LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line 

# Timing constants
E_PULSE = 0.00005
E_DELAY = 0.00005

# What do you want the display to say when it's loading
startupline1 = "+------------------+"
startupline2 = "|   Raspberry Pi   |"
startupline3 = "|  Internet Radio  |"
startupline4 = "+------------------+"

def main():
  # Main program block
  GPIO.setmode(GPIO.BCM)       # Use BCM GPIO numbers
  GPIO.setup(LCD_E, GPIO.OUT)  # E
  GPIO.setup(LCD_RS, GPIO.OUT) # RS
  GPIO.setup(LCD_D4, GPIO.OUT) # DB4
  GPIO.setup(LCD_D5, GPIO.OUT) # DB5
  GPIO.setup(LCD_D6, GPIO.OUT) # DB6
  GPIO.setup(LCD_D7, GPIO.OUT) # DB7
  
  GPIO.setup(NEXT, GPIO.IN) # Next Track
  GPIO.setup(PREV, GPIO.IN) # Previous Track
  GPIO.setup(PLAYBUTTON, GPIO.IN) # Play
  GPIO.setup(POWEROFF, GPIO.IN) # Volume Up by 5

  
  # Initialise display
  lcd_init()
  # Send some test
  lcd_byte(LCD_LINE_1, LCD_CMD)
  lcd_string(startupline1,2)
  lcd_byte(LCD_LINE_2, LCD_CMD)
  lcd_string(startupline2,2)
  lcd_byte(LCD_LINE_3, LCD_CMD)
  lcd_string(startupline3,2)
  lcd_byte(LCD_LINE_4, LCD_CMD)
  lcd_string(startupline4, 2)	 
  os.system("mpc play 1")
  time.sleep(2) 
  while 1:
	  if ( GPIO.input(NEXT) == False ):
		os.system("mpc next")

	  if ( GPIO.input(PREV) == False ):
		os.system("mpc prev")

	  if ( GPIO.input(PLAYBUTTON) == False ):
		os.system("mpc play")

	  if ( GPIO.input(POWEROFF) == True ):
		os.system("mpc stop")
         	lcd_byte(LCD_LINE_1, LCD_CMD)
          	lcd_string("+------------------+",1)
          	lcd_byte(LCD_LINE_2, LCD_CMD)
          	lcd_string("|   Shutting Down  |",1)
          	lcd_byte(LCD_LINE_3, LCD_CMD)
          	lcd_string("|    Please Wait   |",1)
          	lcd_byte(LCD_LINE_4, LCD_CMD)
          	lcd_string("+------------------+",1)
		os.system("sudo shutdown -h now")
		time.sleep(180)


	  f=os.popen("mpc current")
	  station = ""
	  for i in f.readlines():
		station += i
          station = station + " " * 80
          stationa=station[0:20]
          stationb=station[20:40]
          stationc=station[40:60]
          stationd=station[60:80]

	  # Send some text
	  lcd_byte(LCD_LINE_1, LCD_CMD)
	  lcd_string(stationa,1)
	  lcd_byte(LCD_LINE_2, LCD_CMD)
	  lcd_string(stationb,1)
          lcd_byte(LCD_LINE_3, LCD_CMD)
	  lcd_string(stationc,1)
	  lcd_byte(LCD_LINE_4, LCD_CMD)
          lcd_string(stationd,1)
         	 
  time.sleep(20)

def lcd_init():
  # Initialise display
  lcd_byte(0x33,LCD_CMD)
  lcd_byte(0x32,LCD_CMD)
  lcd_byte(0x28,LCD_CMD)
  lcd_byte(0x0C,LCD_CMD)  
  lcd_byte(0x06,LCD_CMD)
  lcd_byte(0x01,LCD_CMD)  

def lcd_string(message,style):
  # Send string to display
  # style=1 Left justified
  # style=2 Centred
  # style=3 Right justified

  if style==1:
    message = message.ljust(LCD_WIDTH," ")  
  elif style==2:
    message = message.center(LCD_WIDTH," ")
  elif style==3:
    message = message.rjust(LCD_WIDTH," ")

  for i in range(LCD_WIDTH):
    lcd_byte(ord(message[i]),LCD_CHR)

def lcd_byte(bits, mode):
  # Send byte to data pins
  # bits = data
  # mode = True  for character
  #        False for command

  GPIO.output(LCD_RS, mode) # RS

  # High bits
  GPIO.output(LCD_D4, False)
  GPIO.output(LCD_D5, False)
  GPIO.output(LCD_D6, False)
  GPIO.output(LCD_D7, False)
  if bits&0x10==0x10:
    GPIO.output(LCD_D4, True)
  if bits&0x20==0x20:
    GPIO.output(LCD_D5, True)
  if bits&0x40==0x40:
    GPIO.output(LCD_D6, True)
  if bits&0x80==0x80:
    GPIO.output(LCD_D7, True)

  # Toggle 'Enable' pin
  time.sleep(E_DELAY)    
  GPIO.output(LCD_E, True)  
  time.sleep(E_PULSE)
  GPIO.output(LCD_E, False)  
  time.sleep(E_DELAY)      

  # Low bits
  GPIO.output(LCD_D4, False)
  GPIO.output(LCD_D5, False)
  GPIO.output(LCD_D6, False)
  GPIO.output(LCD_D7, False)
  if bits&0x01==0x01:
    GPIO.output(LCD_D4, True)
  if bits&0x02==0x02:
    GPIO.output(LCD_D5, True)
  if bits&0x04==0x04:
    GPIO.output(LCD_D6, True)
  if bits&0x08==0x08:
    GPIO.output(LCD_D7, True)

  # Toggle 'Enable' pin
  time.sleep(E_DELAY)    
  GPIO.output(LCD_E, True)  
  time.sleep(E_PULSE)
  GPIO.output(LCD_E, False)  
  time.sleep(E_DELAY)   

if __name__ == '__main__':
  main()
# End of File

your_mum
Posts: 17
Joined: Mon Apr 07, 2014 9:54 am

Re: Lunchbox Internet Radio Guide

Mon Jul 21, 2014 10:30 am

Hi VeryNoob, great project and write up!

No doubt by now you have made advances to your software side and issues such as playlists.

Like you, I am a total noob to all things RPi! and have been working on a similar project but concentrating on learning the software side (linux, python and javascript) prior to any hardware implementations.

If you have time and interest, you may find you can easily mod my code to also give you further features for your project.

The layout of my 'lunchbox' will have 8 buttons placed around a alpha/numeric display and in 'radio' mode will control things like volume up/down, station select, station previous and next, sleep and light(on/off). Currently I only have these features written for browser connectivity as I've no hardware (GPIO) to write to and test but plan to do this come winter... However, you already have this sorted - hence you should be able to easily mod the code (famous last words...)
You can find the link in this forum, just search for 'WAF Alarm, Clock, Internet Radio'.
Last edited by your_mum on Tue Jul 22, 2014 12:19 pm, edited 1 time in total.

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Lunchbox Internet Radio Guide

Tue Jul 22, 2014 11:32 am

This is really smart!

I'm doing something similar in that I have a Pi, display, speaker and buttons which I plan to put in a lunch box however the buttons will just trigger various train related sounds for my son to use when playing with his toys.

All the electronics work nicely, I'm just wondering how on earth I'm going to cut holes in the lunch box to mount the buttons/display. Any tips?
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
VeryNoob
Posts: 49
Joined: Thu Feb 14, 2013 1:07 pm
Location: Australia

Re: Lunchbox Internet Radio Guide

Sun Jul 27, 2014 12:25 pm

Hey "your_mum", it sounds like you are doing something interesting, but I'm not willing to download a zip file from a hosting site. If you post your code I might have a look

"elParaguayo", if it's soft plastic, then just a razor and a steel ruler. Make sure you have the ruler over the bit you don't want cut, so if you slip, you slip on to the bit you are throwing away. If it's hard plastic, score the outline with a razor and ruler, then measure in say 3mm and score another line, then use a 4mm drill bit to make holes that are 2mm over each side of your line. Then you should end up with a 1mm jagged edge that you can file down.

User avatar
VeryNoob
Posts: 49
Joined: Thu Feb 14, 2013 1:07 pm
Location: Australia

Re: Lunchbox Internet Radio Guide

Sun Jul 27, 2014 12:36 pm

I've also moved it into something a little nicer

Image
http://oi61.tinypic.com/350uef7.jpg

GRUNDTAL From Ikea

your_mum
Posts: 17
Joined: Mon Apr 07, 2014 9:54 am

Re: Lunchbox Internet Radio Guide

Sun Jul 27, 2014 3:29 pm

VeryNoob wrote:Hey "your_mum", it sounds like you are doing something interesting, but I'm not willing to download a zip file from a hosting site. If you post your code I might have a look

"elParaguayo", if it's soft plastic, then just a razor and a steel ruler. Make sure you have the ruler over the bit you don't want cut, so if you slip, you slip on to the bit you are throwing away. If it's hard plastic, score the outline with a razor and ruler, then measure in say 3mm and score another line, then use a 4mm drill bit to make holes that are 2mm over each side of your line. Then you should end up with a 1mm jagged edge that you can file down.
Currently, I don't have a web site nor any other means to post code (suggestion welcome).
The zip file is about 5.5Meg in size and contains a 'readme', 10-local.rules and the following files (To keep this post smallish, I'll post extract of readme file in another post):
pi@raspberrypi /var/www $ ls -lR
.:
total 208
drwxr-xr-x 2 pi pi 4096 Jul 26 20:45 cgi-bin
drwxrwxrwx 4 pi pi 4096 Jul 27 16:23 clockAudio
-rw-r--r-- 1 pi pi 3135 Jul 7 11:54 clock.html
-rw-r--r-- 1 pi pi 35146 Jun 28 20:27 Copying
-rw-rw-rw- 1 pi www-data 0 Jul 27 16:22 error_log
-rw-r--r-- 1 pi pi 833 Jun 28 20:50 GNU Licence
-rw-r--r-- 1 pi pi 3859 Jul 16 22:45 helpAnniversaries.html
-rw-r--r-- 1 pi pi 4796 Jun 29 06:47 helpBackupRestore.html
-rw-r--r-- 1 pi pi 2447 Jul 23 10:01 help.html
-rw-r--r-- 1 pi pi 5355 Jul 11 22:45 helpRadioTuning.html
-rw-r--r-- 1 pi pi 8232 Jul 23 09:54 index.html
-rw-r--r-- 1 pi pi 2029 Jun 28 20:53 light.html
-rwxrwxrwx 1 pi pi 1412 Jul 8 20:32 originalFAV1
-rwxrwxrwx 1 pi pi 302 Jul 8 20:32 originalFAV1.php
-rwxrwxrwx 1 pi pi 1482 Jul 8 20:32 originalunsortedFAV1
-rw-r--r-- 1 pi pi 33807 Jul 22 11:04 radio.html
-rw-r--r-- 1 pi pi 12970 Jul 25 09:23 radioTuning.html
-rw-r--r-- 1 pi pi 33717 Jul 23 13:11 READ_ME.txt
-rw-r--r-- 1 pi pi 39 Jul 10 21:29 searchList
-rw-r--r-- 1 pi pi 9430 Jul 8 09:08 style.css

./cgi-bin:
total 244
-rw-r--r-- 1 pi pi 23389 Jul 25 10:03 alarm.py
-rw-r--r-- 1 pi pi 11467 Jul 23 10:48 anniversaries.py
-rw-r--r-- 1 pi pi 19386 Jul 26 10:34 backup.py
-rw-r--r-- 1 pi pi 1212 Jul 11 22:35 callRadioTuning.py
-rwxr-xr-x 1 pi pi 5924 Jul 15 10:39 checkIP.py
-rw-r--r-- 1 pi pi 1426 Jun 28 20:08 checkRadioCommand.py
-rwxrwxrwx 1 pi pi 9228 Jun 28 20:35 checkUSB.py
-rw-r--r-- 1 pi pi 35146 Jun 28 20:27 Copying
-rw-r--r-- 1 pi pi 26727 Jul 15 11:52 editAlarm.py
-rw-r--r-- 1 pi pi 841 Jun 28 20:03 GNU licence
-rw-r--r-- 1 pi pi 1250 Jul 23 11:14 __init__.py
-rw-r--r-- 1 pi pi 3799 Jul 26 20:54 logs.py
-rwxrwxrwx 1 pi pi 24470 Jul 16 08:29 radio.py
-rw-r--r-- 1 pi pi 33928 Jul 25 08:43 radioTuning.py
-rw-r--r-- 1 pi pi 11048 Jul 27 07:54 setupHtml.py
-rwxrwxrwx 1 pi pi 3845 Jun 28 20:10 sleepTimer.py
-rwxrwxrwx 1 pi pi 4917 Jul 21 08:30 turnOnOffRadio.py

./clockAudio:
total 4668
-rw-r--r-- 1 pi pi 10866 May 27 14:50 00.mp3
-rw-r--r-- 1 pi pi 7940 May 27 14:50 01.mp3
-rw-r--r-- 1 pi pi 12955 May 27 14:50 02.mp3
-rw-r--r-- 1 pi pi 7522 May 27 14:50 03.mp3
-rw-r--r-- 1 pi pi 5432 May 27 14:50 04.mp3
-rw-r--r-- 1 pi pi 8776 May 27 14:50 05.mp3
-rw-r--r-- 1 pi pi 7522 May 27 14:50 06.mp3
-rw-r--r-- 1 pi pi 11283 May 27 14:50 07.mp3
-rw-r--r-- 1 pi pi 7104 May 27 14:50 08.mp3
-rw-r--r-- 1 pi pi 10866 May 27 14:50 09.mp3
-rw-r--r-- 1 pi pi 5850 May 27 14:50 0.mp3
-rw-r--r-- 1 pi pi 10448 May 27 14:50 10.mp3
-rw-r--r-- 1 pi pi 13373 May 27 14:50 11.mp3
-rw-r--r-- 1 pi pi 10030 May 27 14:50 12.mp3
-rw-r--r-- 1 pi pi 14209 May 27 14:50 15.mp3
-rw-r--r-- 1 pi pi 10448 May 27 14:50 20.mp3
-rw-r--r-- 1 pi pi 22986 May 27 14:50 25.mp3
-rw-r--r-- 1 pi pi 8358 May 27 14:50 30.mp3
-rw-r--r-- 1 pi pi 10030 May 27 14:50 35.mp3
-rw-r--r-- 1 pi pi 5850 May 27 14:50 40.mp3
-rw-r--r-- 1 pi pi 10030 May 27 14:50 45.mp3
-rw-r--r-- 1 pi pi 6268 May 27 14:50 50.mp3
-rw-r--r-- 1 pi pi 10448 May 27 14:50 55.mp3
-rw-r--r-- 1 pi pi 271444 Mar 31 22:10 AlarmClockBuzzer.mp3
-rw-r--r-- 1 pi pi 1095933 Apr 4 21:01 Birthday.mp3
-rw-r--r-- 1 www-data www-data 67 Jul 27 08:45 clockPlaylist.txt
-rw-r--r-- 1 www-data www-data 23 Jul 23 19:45 clockVoiceDir.php
-rw-r--r-- 1 www-data www-data 45 Jul 27 16:21 clockVoiceDirs.php
-rw-r--r-- 1 pi pi 2096223 Apr 4 21:01 Holiday.mp3
-rw-r--r-- 1 root root 441 Jul 26 20:00 ipPlaylist.txt
-rw-r--r-- 1 pi pi 901537 Apr 4 21:01 Other.mp3
drwxr-xr-x 2 pi pi 4096 Jul 1 08:46 UKFemail
drwxr-xr-x 2 pi pi 4096 May 30 08:27 UKMail
-rw-r--r-- 1 pi pi 102528 Apr 4 21:01 Wedding.mp3

./clockAudio/UKFemail:
total 944
-rw-r--r-- 1 pi pi 12955 May 30 08:27 00.mp3
-rw-r--r-- 1 pi pi 10866 May 30 08:27 01.mp3
-rw-r--r-- 1 pi pi 10866 May 30 08:27 02.mp3
-rw-r--r-- 1 pi pi 11283 May 30 08:27 03.mp3
-rw-r--r-- 1 pi pi 12537 May 30 08:27 04.mp3
-rw-r--r-- 1 pi pi 14209 May 30 08:27 05.mp3
-rw-r--r-- 1 pi pi 15045 May 30 08:27 06.mp3
-rw-r--r-- 1 pi pi 12537 May 30 08:27 07.mp3
-rw-r--r-- 1 pi pi 12119 May 30 08:27 08.mp3
-rw-r--r-- 1 pi pi 14209 May 30 08:27 09.mp3
-rw-r--r-- 1 pi pi 9194 May 30 08:27 0.mp3
-rw-r--r-- 1 pi pi 12119 May 30 08:27 10.mp3
-rw-r--r-- 1 pi pi 12955 May 30 08:27 11.mp3
-rw-r--r-- 1 pi pi 14627 May 30 08:27 12.mp3
-rw-r--r-- 1 pi pi 16299 May 30 08:27 15.mp3
-rw-r--r-- 1 pi pi 13373 May 30 08:27 20.mp3
-rw-r--r-- 1 pi pi 19643 May 30 08:27 25.mp3
-rw-r--r-- 1 pi pi 15881 May 30 08:27 30.mp3
-rw-r--r-- 1 pi pi 19643 May 30 08:27 35.mp3
-rw-r--r-- 1 pi pi 12955 May 30 08:27 40.mp3
-rw-r--r-- 1 pi pi 18807 May 30 08:27 45.mp3
-rw-r--r-- 1 pi pi 14209 May 30 08:27 50.mp3
-rw-r--r-- 1 pi pi 18389 May 30 08:27 55.mp3
-rw-r--r-- 1 pi pi 22986 Jun 14 14:11 alarmBackedUp.mp3
-rw-r--r-- 1 pi pi 24240 Jun 14 15:27 alarmRestored.mp3
-rw-r--r-- 1 pi pi 30510 Jun 14 14:11 anniversariesBackedUp.mp3
-rw-r--r-- 1 pi pi 29674 Jun 14 15:27 anniversariesRestored.mp3
-rw-r--r-- 1 pi pi 7940 Jul 1 08:46 dot.mp3
-rw-r--r-- 1 pi pi 20479 Jun 14 14:11 errorBackedUp.mp3
-rw-r--r-- 1 pi pi 12537 Jul 1 08:46 ethernet.mp3
-rw-r--r-- 1 pi pi 32599 Jun 14 14:11 favBackedUp.mp3
-rw-r--r-- 1 pi pi 43884 Jun 14 15:27 favRestored.mp3
-rw-r--r-- 1 pi pi 25076 Jun 14 14:11 fullBackedUp.mp3
-rw-r--r-- 1 pi pi 25912 Jun 14 15:27 fullRestored.mp3
-rw-r--r-- 1 pi pi 17971 Jul 1 08:46 next.mp3
-rw-r--r-- 1 pi pi 50990 Jul 1 08:46 noIP.mp3
-rw-r--r-- 1 pi pi 45974 Jun 14 14:11 NoUsbDeviceFound.mp3
-rw-r--r-- 1 pi pi 41794 Jun 10 09:16 publicHolidayFileUpdated.mp3
-rw-r--r-- 1 pi pi 42630 Jun 17 20:26 singleFileRestored.mp3
-rw-r--r-- 1 pi pi 33017 Jun 16 09:52 updatedMP3.mp3
-rw-r--r-- 1 pi pi 35107 Jun 10 09:09 UsbFlashDrivePluggedIn.mp3
-rw-r--r-- 1 pi pi 14209 Jul 1 08:46 wlan.mp3

./clockAudio/UKMail:
total 324
-rw-r--r-- 1 pi pi 13373 May 30 08:27 00.mp3
-rw-r--r-- 1 pi pi 11283 May 30 08:27 01.mp3
-rw-r--r-- 1 pi pi 9612 May 30 08:27 02.mp3
-rw-r--r-- 1 pi pi 10866 May 30 08:27 03.mp3
-rw-r--r-- 1 pi pi 12119 May 30 08:27 04.mp3
-rw-r--r-- 1 pi pi 12119 May 30 08:27 05.mp3
-rw-r--r-- 1 pi pi 12119 May 30 08:27 06.mp3
-rw-r--r-- 1 pi pi 11283 May 30 08:27 07.mp3
-rw-r--r-- 1 pi pi 10030 May 30 08:27 08.mp3
-rw-r--r-- 1 pi pi 12537 May 30 08:27 09.mp3
-rw-r--r-- 1 pi pi 8358 May 30 08:27 0.mp3
-rw-r--r-- 1 pi pi 10030 May 30 08:27 10.mp3
-rw-r--r-- 1 pi pi 10866 May 30 08:27 11.mp3
-rw-r--r-- 1 pi pi 10448 May 30 08:27 12.mp3
-rw-r--r-- 1 pi pi 12955 May 30 08:27 15.mp3
-rw-r--r-- 1 pi pi 10448 May 30 08:27 20.mp3
-rw-r--r-- 1 pi pi 17135 May 30 08:27 25.mp3
-rw-r--r-- 1 pi pi 12955 May 30 08:27 30.mp3
-rw-r--r-- 1 pi pi 18389 May 30 08:27 35.mp3
-rw-r--r-- 1 pi pi 10448 May 30 08:27 40.mp3
-rw-r--r-- 1 pi pi 16717 May 30 08:27 45.mp3
-rw-r--r-- 1 pi pi 12119 May 30 08:27 50.mp3
-rw-r--r-- 1 pi pi 17135 May 30 08:27 55.mp3

your_mum
Posts: 17
Joined: Mon Apr 07, 2014 9:54 am

Re: Lunchbox Internet Radio Guide

Sun Jul 27, 2014 3:35 pm

VeryNoob wrote:Hey "your_mum", it sounds like you are doing something interesting, but I'm not willing to download a zip file from a hosting site. If you post your code I might have a look

"elParaguayo", if it's soft plastic, then just a razor and a steel ruler. Make sure you have the ruler over the bit you don't want cut, so if you slip, you slip on to the bit you are throwing away. If it's hard plastic, score the outline with a razor and ruler, then measure in say 3mm and score another line, then use a 4mm drill bit to make holes that are 2mm over each side of your line. Then you should end up with a 1mm jagged edge that you can file down.
BTW - your 'new' housing look grrrreat - nice work 8-)


In the earlier post I forgot to say all the files showing are tar'd in a 'backup.gz' file. The readme I mentioned in earlier post is:

"backup.gz created using following on command line:

sudo tar -cvpzf /mnt/usbdrive/backup.gz --exclude=/var/www/.mplayer --exclude=/var/www/.pulse /var/www

Note: '/mnt/usbdrive/' is the mount point directory for USB memory stick.

To extract back (the following should work on the command line):

sudo tar -xvpzf /mnt/usbdrive/backup.gz -C / var/www

Note: change '/mnt/usbdrive/' to whatever location you first copy backup.gz to before xtraction of directories and files.

Hint: read the READ_ME.txt in /var/www/ for further details.

When USB memory stick is plugged into RPi, the following udev file will be actioned, resulting in checkUSB.py script being run:
ADD THIS FILE WITH THE FOLLOWING TWO LINES IN: /etc/udev/rules.d/10-local.rules
KERNEL=="sd[a-z]", SUBSYSTEM=="block", ACTION=="add", RUN+="/var/www/cgi-bin/checkUSB.py input=in"
KERNEL=="sd[a-z]", SUBSYSTEM=="block", ACTION=="remove", RUN+="/var/www/cgi-bin/checkUSB.py input=out"


Hint: Install a web server such as 'lighttpd' (use web directory '/var/www' and user/group 'www-data') and MPlayer.
After file extraction, use an 'external' browser to navigate to the RPi IP address, the browser should display the 'index' page returned by the RPi web server.
Check error log (error_log) if there are any issues or unexpected results during operation."

KentPeterson
Posts: 1
Joined: Sat May 24, 2014 12:54 am

Re: Lunchbox Internet Radio Guide

Wed Jan 21, 2015 5:13 am

I like the template you have for the Humble Pi. What application is it and do you have a copy of the template you used for the Humble Pi?

Return to “Graphics, sound and multimedia”