Introduction: DIY a Wi-Fi Speaker

About: Howdy, we are application engineers in Seeed. Sharing projects with the maker community is awesome. Hope you like it XD Seeed is the IoT hardware enabler providing services that empower IoT developers to swift…

Here share my latest project, a Wi-Fi Speaker.

This speaker is based on LinkIt Smart 7688, an open source development board that featured with Wi-Fi and Audio.

I made a wooden box to make the speaker look retro, wooden will provide nice sound as well.

This speaker has the simple hardware and shell, it won't be hard if you has some knowledge of electronic, any way if you want one, you can make it.

Step 1: The Video

Here's a simple video to help you to have a overview of this speaker.

Step 2: Prepare the Stuff

There's something need to be prepared.

Electrical Parts

  • Smart LinkIt 7688 Duo
  • Breakout for LinkIt 7688
  • Grove - LCD RGB Backlight
  • 5'' Horn
  • High gain Power Amplifier board
  • WS2812B LED
  • Logic DC Jack
  • 12V Switching Power

Wooden board & Acrylic

  • 5mm width wooden board
  • 3mm lucid acrylic

Others

  • M3 Nut
  • M3 Cu pillar

Tools

  • Laser Cutter
  • glue gun
  • screwdriver

Step 3: Laser Cutting the Speaker Body

You need a PC and a laser cutter here. Generally speaking you wouldn't have such a machine at home. Never mind, you can find a laser cutter in any maker space.

And there's many place supply the laser cutting service, just upload you file and pay for it, then you will get the things days later.

You can download the 2d file attached and make some change for your need.

Step 4: Building the Speaker Body

For this step we will need:

  • Glue gun
  • Wooden white glue

After the previous step, we got 6 piece of wooden board. Put them(expect the back one) together with the glue gun.

Step 5: Fitting the Electronic Modules

For this step we will need:

  • glue gun
  • M3 nut x 20
  • M3 Cu pillar x 10
  • Screwdriver

There are many parts of electronic modules, include:

  • High gain Power Amplifier board with two Volume knob
  • Grove - LCD RGB Backlight
  • Breakout for LinkIt 7688
  • 5'' Horn
  • Acrylic

For the details of the fitting, you can refer to the above images.

Step 6: Fitting the Power

The High gain Power Amplifier board need 12VDC and the LinkIt 7688 need a 5VDC.

I was thinking that make it 2 power input, one for 12V and the other 5V. But's it's some kind of inconvenient.

Finally I got a AC -> 12VDC switch power, about the 5VDC, I got a Logic DC Jack, which will buck 12V to 5V.

As the LinkIt 7688 is micro usb input, and Logic DC Jack Grove output, so we need to make ge Grove -> Micro USB cable.

Step 7: Programming

There's few steps to follow:

1. Connect 7688 to a Wi-Fi router

& vi /etc/config/wireless
config wifi-iface 'sta'
	option device 'radio0'
	option mode 'sta'
	option network 'wan'
	option ifname 'apcli0'
	option led 'mediatek:orange:wifi'
	option ssid 'UplinkAp'    # Setting SSID
	option key 'SecretKey'    # Setting paas word
	option encryption 'psk'
	option disabled '0'       # Enable setting
# Save and exit
& wifi down
& wifi up   
# wait for WiFi connecting</p>

2. Install shairport

& opkg updat
& opkg install avahi-daemon dbus libao libavahi libavahi-client libdbus libexpat shairport

3. Enable startup running

& /etc/init.d/shairport enable
& /etc/init.d/shairport start

4. Change shairport Configuration

& echo “” > /etc/config/shairport
& vi /etc/config/shairport
config shairport
         option name 'Shairport_lks7688'
         option password ''
         option port '5002'
         option buffer '256'
         option log '/var/log/shairport'
         option cmd_start ''
         option cmd_stop ''
         option cmd_wait '0'
         option audio_output ''
         option mdns ''
& reboot

5. Now use iphone to push music to Shairport_lks7688

6. Code to display music and IP address through Grove - LCD RGB Backlight

# Copy and save code bellow to /root/ rgb_lcd_display_mpc_music.js

function ledStrip_init(){

    var m = require("mraa");
    i2c =  new m.I2c(0);                          
                                              
    i2c.address(0x23);                            
    var buf1 = new Buffer([0x80, 0, 0xCC, 0, 0xCC])
    var buf2 = new Buffer([0x80, 1, 0xCC, 0, 0xCC])
    var buf3 = new Buffer([0x80, 2, 0xCC, 0, 0xCC])
    var buf4 = new Buffer([0x80, 3, 0xCC, 0, 0xCC])
    var buf5 = new Buffer([0x80, 4, 0xCC, 0, 0xCC])
    i2c.write(buf1);
    i2c.write(buf2);
    i2c.write(buf3);
    i2c.write(buf4);                  
    i2c.write(buf5);
};
setTimeout(ledStrip_init, 2000);
var LCD = require('jsupm_i2clcd');
// Initialize Jhd1313m1 at 0x62 (RGB_ADDRESS) and 0x3E (LCD_ADDRESS)
var myLcd = new LCD.Jhd1313m1 (0, 0x3E, 0x62);
myLcd.setCursor(0,0);
// RGB Blue
//myLcd.setColor(53, 39, 249);
// RGB Red
function clear_lcd(line){
    myLcd.setCursor(line, 0);
    myLcd.write("                ");
    myLcd.setCursor(line, 0);
}
var musicName = "";
var ipAddr = "";
function display_music_name(){
    var exec = require('child_process').exec;
    exec('mpc status | awk \'{if(NR==1) print}\'',function(error, stdout, stderr){
        if(musicName != stdout) {
            console.log(stdout);
            clear_lcd(0);
            myLcd.write(stdout);
        }
        musicName = stdout;
    });
   
    exec('ifconfig | awk \'{if(NR==2) print $2}\'', function(error, stdout, stderr){
        if(ipAddr != stdout) {
            console.log(stdout);   
            clear_lcd(1);
            myLcd.write(stdout.slice(4));
        }
        ipAddr = stdout;
    });
}
setInterval(display_music_name, 1000);

7. Copy and save Startup running

script /etc/init.d/rgb_lcd_mpc 
#!/bin/ash /etc/rc.common<br>START=99
start() {
        sleep 5   # make sure boot process is done, no more console msgs
        . /etc/profile
        echo $PATH
        node /root/rgb_lcd_display_mpc_music.js
}
stop() {
         killall node
}
Step 8 – Enable startup running script
& /etc/init.d/ rgb_lcd_mpc enable
& /etc/init.d/ rgb_lcd_mpc start&
Finally, connect cables and restart lks7688.

Step 8: Play a Music

Now, open your music player and enjoy.

cheers.