Skip to content

Turn the Raspberry Pi into a radio box with Android Things

Notifications You must be signed in to change notification settings

jferrao/things-rockfm

Repository files navigation

About

Turn the Raspberry Pi into a radio box with Android Things and Raspberry Pi

My personal little project to create a Madrid's Rock FM box using aRaspberry Pi 3 with a Rainbow HAT powered by Android Things.

You can actually use this application to play any online radio and not only RockFM. Just use a different URL for the station’s stream and you’re set to go!

Requirements

Components

If you’re using the Rainbow HAT you can skip this section though the Rainbow HAT is not strictly necessary you’ll need it to control the volume and get volume information.

If you don’t have a Rainbow HAT or if you don’t want to use one but still want to have volume control you can connect components to the Raspberry Pi GPIO:

  • 3 buttons for volume control (volume up, down and mute)
  • 3 leds
  • 4 character digital display used to display the station name and mute state
  • 7 led strip for volume visualisation

Connections:

  • Volume up button connected to BCM16
  • Volume down button connected to BCM20
  • Sound mute button connected to BCM21
  • 4 digit display connect to I2C1 bus
  • 7 led strip connected to SPI0.0 bus

You may find Raspberry Pi GPIO Pinout useful to get the connections right for each component.

Known Issues

Audio output using the Pi’s 3.5 mm output

Especially if using a HDMI screen while testing or setting up this project and to make use of the Raspberry Pi’s 3.5mm audio output you might need to tweak the Pi’s config.txt boot file.

Seems that by default the Pi with Android Things Developers Preview 6, probably other older versions as well, will use the HDMI output for audio output. In order to separate the video and audio outputs and set the audio output to the internal 3.5mm audio port add the following line to the Pi’s boot config.txt:

hdmi_ignore_hotplug=1

Using this setting it will use composite mode even if HDMI monitor is detected.

Thanks to Burngate for pointing me in the right direction in the Force pi to Analog/Digital output - Raspberry Pi Forums post from back in 2012. It took me quite a bit of time to understand why I could not get sound through the Pi’s audio output port:

hdmi_ignore_hotplug Pretends HDMI hotplug signal is not asserted so it appears a HDMI display is not attached

Usage

With the Raspberry Pi connected to a computer in debug mode flashed with Android Things either run it from Android Studio or use the gradle wrapper to install the application:

./gradlew installDebug

::Note that due to some of the required Android permissions for this application, chances are that you’ll need to restart the Raspberry Pi so that those permissions can be accepted by the device.::

Every time you start the Raspberry Pi it will start playing Rock FM and it will go on until turned off.

ToDo

  • Get name and display what is currently playing

About

Turn the Raspberry Pi into a radio box with Android Things

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages