Data over audio

This week’s project, webaudio-serial-tx, let’s your phone (or any computer with a headphone jack) transmit serial data to hardware like an Arduino.

Bottomline: you can control physical things / servos / motors / hardware from your phone, using just the browser. Super useful for hackathon hackers.

Here’s an example of a phone controlled servo from author James Halliday:

How does it work? First, webaudio-serial-tx implements the UART protocol in JavaScript - which encodes data as “framed” binary strings.

Next, it uses the WebAudio API to create an output buffer, mapping Os &amps 1s into voltages between -1 &amp 1, which are output via the headphone jack.

Everything is packaged up super nicely, so you can send data in a few lines of code:

```javascript var serial = require(‘webaudio-serial-tx’); var port = serial({ baud: 9600 }); // oh man, remember when 9600 baud was a big deal?!

port.write(new Buffer(5000).fill(‘Hi There!’)); port.start(); ```

If you browserify that script & run it in Chrome, you’ll hear some digital noise coming out of your speakers—but trust me, your Arduino (with a few extra caps & resistors) will totally grok it.

Comments :)
2017 Neal Shyam