

Show HN: Serial communication using the WebAudio API - ecubed
https://github.com/cteubank/AudioSerial

======
ecubed
I'd appreciate any feedback, especially from more experienced devs. I built
this JS class to send serial commands over the headphone port of an iPhone
using Javascript and the HTML5 WebAudio API. This enabled me to use an iPhone
application to control my embedded systems design senior project.

~~~
revdinosaur
This is a great hack, very clever. You mention on the GitHub page that you use
a comparator to convert the signal for the ATMega168. I know that the
ATmega328 has an embedded comparator so I'm wondering how easy you think it
would be to create a library for Arduino projects?

I currently have a few projects which are bound to servers so I can control
them with web apps and this seems like a great way to liberate them from the
network. Low-level analog signal processing is about where my knowledge comes
to a screeching halt (hence using Arduinos in the first place) but I'd love to
play around with any AVR code to try and implement this for high-level
language hardware people.

------
revelation
I don't know about the JavaScript code, but I did look at the uC code (EE459
repo I guess?).

Since you are already taking the flash hit with sprintf, you might be
interested to know that you can redirect stdout to print all data through your
serial line, i.e. just using printf. Saves going through an intermediate
buffer. Looks something like this:

[http://pastie.org/8073251](http://pastie.org/8073251)

~~~
ecubed
Thanks for the tip! I'll try and implement this once I get the parts in for my
new board.

------
RyanZAG
Great hack and worth doing just because it is a great hack, but since it was a
senior project, wouldn't it have been easier to just grab an old Android phone
off Ebay and use standard 2-way communication directly?

~~~
ecubed
Possibly. It was an embedded systems class, and I have a background dealing
more with webdev and audio systems, so I figured I could combine all three
into something novel. It actually worked out really well for the purpose,
which was supposed to be a power-saving application. This way required only
the addition of a comparator chip between the ATMega168 and the headphone
line, which made it a super low power (and computationally light) way to
communicate.

------
zaroth
Here's something similar doing FSK with Javascript and HTML5 audio:

[https://github.com/NeoCat/FSK-Serial-Generator-in-
JavaScript...](https://github.com/NeoCat/FSK-Serial-Generator-in-JavaScript/)

------
samsquire
You could have applications that talk with your smartphone without a network
and just a browser providing you can access your microphone in Android and
iOS. reply

~~~
ecubed
Correct. The next step on this project will be to try and get two way
communication working. I ran out of time before the class ended to get that
established. If I remember correctly I ran into some issues with the mobile
safari and the microphone input via javascript. I believe PhoneGap provides an
API for this though.

------
masswerk
Very neat! Maybe you could even implement read using navigator.userGetMedia to
provide two way communications ...

------
mmastrac
Neat project, but would be great to see a demo page.

Also, s/buad/baud/

~~~
ecubed
I'm in the process of building a more general purpose dev board using the same
processor I used for the class, so once I've got that up and running I'll try
and post more "How to" related stuff on the github.

~~~
orangethirty
Do you think there might be a way to receive data? Maybe measure the voltage
drop from a normally high circuit?

Edit: Awesome project. (:

