Internet radio + LCD 2x16 + TactSwitch

From Orange Pi Wiki
Jump to: navigation, search

Instructions[edit]

Wiring[edit]

Wiring is easy. We need LCD 2x16 HD44780, three tact switch and two small potentiometers 10K. Schematic-lcd-switch.jpg

Write image to SD card[edit]

(Debian8_jacer_2.img) - first run After first run login as root (password: orangepi). In this tread we will login always as root - to be easly do everythink - I know it is not well.

fs_resize
systemctl set-default multi-user.target (login to console - to open X - startx)
passwd (if you want to change root password)
reboot

Upgrade system[edit]

apt-get update
apt-get upgrade

Installing radio packages[edit]

apt-get install mpd mpc ncmpc

Make radio playlist in PLS format (bellow is example file): /var/lib/music/radio.pls
[playlist]
Version=2
numberofentries=5
File1=http://95.141.24.22:80
Title1=RauteMusic ChartHits
File2=http://193.200.42.210:80
Title2=HITPARTY.fm
File3=http://95.141.24.40:80
Title3=RauteMusic Main
File4=http://193.34.51.92:80
Title4=RauteMusic HOUSE(FUNKY)
File5=http://205.164.36.5:80
Title5=CHILLOUT LOUNGE RADIO (1.FM TM)

If you want to activate analog audio by 3.5mm jack change "card 1" to "card 0" in two places in /etc/asound.conf

pcm.!default {
    type hw
    card 0
    device 0
  }
  ctl.!default {
    type hw
    card 0
  }

reboot After reboot we have to test radio:

mpc load radio.pls
mpc play

If you update playlist (radio.pls) do:

mpc clear
mpc load radio.pls
mpc play

To adjust volume use:

alsamixer

If you hear music it is great - you should - if not google ;) From now radio is working. You can control it by command line (#mpc next, #mpc prev, etc.), by program #ncmpc, from Android phone (Mupeace, Droid MPD Client - search MPD in Google Play)

Remote control - Lirc[edit]

It is not required step. Install lirc:

apt-get install lirc

To configure lirc it is article on this forum. Bellow my configuration files: /etc/lirc/hardware.conf

# /etc/lirc/hardware.conf
LIRCD_ARGS=""
#START_LIRCMD=false
#START_IREXEC=false
LOAD_MODULES=true
MODULES="sunxi-ir-rx"
DRIVER="devinput"
DEVICE="/dev/input/event5"
LIRCD_CONF=""
LIRCMD_CONF=""

Check wich input number is for you - look where is sunxi-ir - change DEVICE in hardware.conf cat /proc/bus/input/devices My remote is small cheap remote from car mp3 player

Configuration for it: /etc/lirc/lircd.conf

begin remote

  name  CAR_MP3
  bits           56
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9000  4500
  one           563  1687
  zero          563   562
  ptrail        563
  pre_data_bits   8
  pre_data       0x0
  gap          108000
  toggle_bit_mask 0x0
  frequency    38000
  duty_cycle   33

      begin codes
          KEY_CHANNELDOWN          0x01004500000001
          KEY_CHANNEL              0x01004600000001
          KEY_CHANNELUP            0x01004700000001
          KEY_PREVIOUS             0x01004400000001
          KEY_FORWARD              0x01004000000001
          KEY_PLAYPAUSE            0x01004300000001
          KEY_VOLUMEDOWN           0x01000700000001
          KEY_VOLUMEUP             0x01001500000001
          KEY_HOME                 0x01000900000001
          KEY_RECORD               0x01001600000001
          KEY_BACK                 0x01000C00000001
          KEY_UP                   0x01001800000001
          KEY_INFO                 0x01005E00000001
          KEY_LEFT                 0x01000800000001
          KEY_OK                   0x01001C00000001
          KEY_RIGHT                0x01005A00000001
          KEY_MENU                 0x01004200000001
          KEY_DOWN                 0x01005200000001
          KEY_STOP                 0x01004A00000001
      end codes

end remote

You can configure any remote by irrecord

To control radio necessery is file - bellow example: /etc/lirc/lircrc

begin
  prog = irexec
  button = KEY_CHANNELDOWN
  config = mpc prev
end

begin
  prog = irexec
  button = KEY_CHANNELUP
  config = mpc next
end

begin
  prog = irexec
  button = KEY_PLAYPAUSE
  config = mpc toggle
end

Restart the system reboot

Installing python library for control GPIO[edit]

apt-get install python-dev
git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3.git
cd /root/orangepi_PC_gpio_pyH3
python setup.py install

Last step - main code[edit]

Copy /root/radio.py from attachement [1] to /root

Run this program

python radio.py

You should see text on LCD - radio informations Button 'Right" - next radio from playlist, Button "Left" - previous radio from playlist Button "Menu" - menu, if you don't touch any button for 4 seconds it return to display radio informations. In menu click "Left" or "Right" to scroll options and "Menu" to run it. Just test it

If it works you can run this program during boot: add in /etc/rc.local above exit 0

python /root/radio.py &

See also[edit]

External links[edit]