Introduction: Intel Edison Pushing Bluetooth Audio.
I wanted a new car stereo and an Ogg Vorbis player that played songs in the order I wanted. I decided to use the best features on an Intel Edison to accomplish this.
- Edison has Bluetooth HW and SW.
- Edison has Perl programming language.
- Edison Arduino boards have an SD-card socket.
- Edison has WiFi HW and SW.
Necessary items for this project.
- Intel Edison with the Arduino Breakout board.
- New car stereo with a Bluetooth Audio input (or any Bluetooth speaker).
- A way to power the Edison. I used a microUSB cable.
- And a laptop to do the programming.
- And a 2nd microUSB cable to do the programming.
- PuTTY for Windows.
Stretch goals which I will get to later.
- "Next button" using a GPIO pin to signal control of the device.
- "Delayed Turnoff" with client side scripting that syncs SW and songs with the house server.
I will eventually work on these stretch goals and post them on Instructables.
Step 1: Fetch the Code From GitHub.
I have posted my code on GitHub at:
A simple way of getting the code is to visit the GitHub site and find the "Download ZIP" button and download the code. You will then have to unzip it and "SCP" copy it to the Edison.
I used a Linux system and it's SFTP software to copy the code from Linux to the Edison.
On Windows, I believe the same copying maybe done using WinSCP. When I made my first connection to the Edison using WinSCP, it gave me the "Warning - Potential Security Breach!" I accepted it because I knew I was initiating the connection to the Edison.
Copy the script files in the zip over to the /home/root/ directory of the Edison. There will be instructions later on moving files around.
Step 2: Connect to the Edison and Get a Command Prompt.
The simplest method is to connect to the Edison using a USB serial port. I followed the first few steps at:
I stopped once I got the USB serial port up and running. At this point, I had a command prompt because I was using Putty on my Windows laptop to connect.
I am using the Edison with the Arduino Breakout Board because I wanted an SDCard slot and 5V GPIO pins.
Step 3: Learn Bluetooth Audio.
To learn Bluetooth audio, I followed this Intel article:
That article contains a command line for calling gst-launch which will play a wav file. The command lines for gst-launch are heavily dependent on the audio file type. I recommend you make some audio file and export it as music.wav (and export it as a wav format). To get the file to your Edison, either use WinSCP to login and copy the file to the Edison. Or put the file on an SD-card and put the SD-card in the Edison.
Step 4: Learn to Automatically Connect to the Bluetooth Speaker.
And AUTOMATING the connections. They wrote a script that redirected commands to bluetoothctl. http://stackoverflow.com/questions/21859564/bluet...
I copied their bash script. I also had to learn to use systemd to call that bash script. Today, when I turn on the car, the radio powers on, the Edison powers on, and systemd runs a script in /home/root/ that connects over Bluetooth and starts my Ogg Vorbis playing software.
For this step, you need to do three things.
- Copy to the Edison my BTConnect.sh and myMP3player.server scripts.
- Copy the myMP3player.service file to /etc/systemd/system/multi-user.target.wants/ directory.
- Edit the BTConnect.sh script.
When myMP3player.service is copied over to the multi-user.target.wants directory, it becomes part of the start files for the Edison. When you restart the Edison, that service is launched. If you read that file, you find it tells systemd to launch BTConnect.sh.
You need to edit the BTConnect.sh script because it contains a hard coded MAC address for my car stereo. You need to learn to determine your own stereo's MAC address and put that in the script in place of mine.
TODO: Put URL to systemd here.
Step 5: Learn Gst-launch-1.0.
gst-launch-1.0 comes with the Intel Edison's Yocto OS image.
USING gst-launch TO PLAY OGG VORBIS FILE.
gst-launch-1.0 filesrc location=/home/root/Highway\ To\ Hell.ogg ! oggdemux ! vorbisdec ! audioconvert ! audioresample ! pulsesink
10-31-2015: This worked fine. This worked on an Edison image that lacked mplayer. And playing an ogg seems to take %8 of the CPU.
TODO: Add a copy-left song or example ogg and example wav files to the software image.
Step 6: Write a Playlist Generator.
TODO: This section.
Git Hub code maybe found at:
Step 7: Learning to Configure the WiFi on Your Edison.
(Optional Step) Learn to configure your Edison.
I found it nice to use the SSH protocol to do the programming. The following steps are simply things I think people should know and practice. I followed an Intel article on setting up an Edison:
I know I like using the 2 microUSB cable method because it connects both USB devices on the Edison to the laptop. The two USB devices are the USB thumb-drive which allows you to copy over the OS image and the USB serial port.
You must get a PuTTY session running and talking to the Edison over the USB serial port; that's step 3 of the Intel article.
You must get the wifi setup; that's step 4 of the Intel article.
Once you get this far, use the USB serial port to determine the IP address of the Edison and then use PuTTY to ssh into the Edison.
Supporting information concerning Bluetooth Audio.
Step 8: Adding Text-to-Speech.
I used espeak to perform text-to-speech generation. I use it to tell knock-knock jokes.
ESPEAK on Edison.
- Did an opkg update.
- Installed espeak from AlexT's repository. opkg install espeak
- Tested it using the bluetooth speaker and the commands:
espeak -w speech.wav "hello world"
7 years ago
I love Bluetooth! Thanks for sharing your project and welcome to the community!