In Focus

Playing Audio With Intel Edison

In this article, I am going to show you how we can play an audio file with Edison by connecting it to Bluetooth speakers.

Intel Edison has onboard Wi-Fi and Bluetooth. This is one of my favorite IoT boards as it never disappoints me. Recently I wanted to play some sound with Edison in one of my projects so I thought to give its Bluetooth functionality a try and it was easier than I thought. In this project I am going to show you how we can play an audio file with Edison by connecting it to Bluetooth speakers.

Requirements

  • Intel Edison with Arduino Expansion board
  • Bluetooth Speakers
  • USB cables

Connections

Connect your Edison to a PC and also establish a serial communication. As we are connecting through Bluetooth our Edison will work in Device Mode. If you are using a USB sound card and headsets you need to switch it to host mode, in that case this article won’t be much help to you.

Setup

Connect to Edison with Putty

Enter username and Password. The default username is root with no password.

PuTTY Configuration
                                                            Figure 1: PuTTY Configuration

Make sure your Bluetooth speakers are turned on. Now type these commands,

root@edison:~# rfkill unblock bluetooth
root@edison:~# bluetoothctl


Unblock bluetooth
                                                            Figure 2: Unblock bluetooth

You will enter into Bluetooth control mode. Scan the Bluetooth devices:

[bluetooth] scan on,

Scan Bluetooth devices.
                                                            Figure 3: Scan Bluetooth devices.

You will see your device listed. Find your device and Pair it.

[bluetooth] pair 30:21:85:A1:46:3D

Sometimes the device does not automatically connect so you need to run another command to connect it.

[bluetooth] connect 30:21:85:A1:46:3D

Command to connect
                                                            Figure 4: Command to connect

Exit the Bluetooth Manager.

[bluetooth] quit

Now let us verify that our device is recognized in pulse audio as a sink device and if everything goes fine you will see it listed as bluez_sink.

pactl list sinks

Configure the default sink to use pulse audio server with the following command, replacing with the details of your device,

Configure the default sink
                                                            Figure 5: Configure the default sink

pactl set-default-sink bluez_sink.30_21_85_A1_46_3D

Replacing with the details of your device
                                                            Figure 6: Replacing with the details of your device

Now we are almost done. Let us run the audio file using gStreamer. I have already copied an audio file to my Edison using FileZilla.

Edison using FileZilla
                                                            Figure 7: Edison using FileZilla

Run this command and also replace the file name and location.

gst-launch-1.0filesrc location= /home/root/Songs/SanamRe.wav ! wavparse !pulsesink

Run command
                                                            Figure 8: Run command

If everything goes fine you will notice a song playing via your Bluetooth speakers. Enjoy your new music player!

Onboard Wi-Fi and Bluetooth
                                                            Figure 9: Onboard Wi-Fi and Bluetooth

References

Here are few links on everything you want to know about Edison Bluetooth or Audio.

Read more articles on Internet of Things: