Settings

Theme

Show HN: Serial communication using the WebAudio API

github.com

49 points by ecubed 13 years ago · 15 comments

Reader

ecubedOP 13 years ago

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 13 years ago

    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.

  • bliker 13 years ago

    This is great! Very interesting idea, if I had more time I would incorporate it into my semester project. My solution using putty now looks so cheap.

revelation 13 years ago

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

  • ecubedOP 13 years ago

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

RyanZAG 13 years ago

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?

  • ecubedOP 13 years ago

    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.

  • bliker 13 years ago

    I personally love the portability that web api provides and the fact that I can run it without overhead right now.

zaroth 13 years ago

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

https://github.com/NeoCat/FSK-Serial-Generator-in-JavaScript...

samsquire 13 years ago

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

  • ecubedOP 13 years ago

    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 13 years ago

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

mmastrac 13 years ago

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

Also, s/buad/baud/

  • ecubedOP 13 years ago

    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 13 years ago

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

      Edit: Awesome project. (:

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection