
Show HN: Program Microcontrollers from Your Headphone jack - gfwilliams
http://forum.espruino.com/conversations/257732/
======
andrewrice
This reminds me of the days of transferring data using the 2.5mm jack on the
TI-83.

~~~
roywiggins
Older(?) Canon(?) DSLRs also used a 2.5mm jack to control the shutter release,
so some people realized if you just spammed data into it from the TI-83 you
could trigger it. Add a crude BASIC script and you have an extremely basic
timelapse setup.

------
codehero
There are two troubling lines in his code (from
[https://github.com/espruino/EspruinoOrion/blob/gh-
pages/seri...](https://github.com/espruino/EspruinoOrion/blob/gh-
pages/serial_to_audio.js))

    
    
      var header = sampleRate; // 1 sec to charge/discharge the cap
      var bufferSize = samplesPerByte*data.length/*samples*/ + header*2;
    

This implies 2 seconds of overhead per message sent from smartphone to
microcontroller, 1 for the light to turn and 1 second of clearing time before
the next transmission. This explains why the lights toggle so slowly.

To top it off, he uses 2 stop bits. The signalling rate may be 9600 baud but
do not expect to be transmitting 9600 DATA bits a second! I think such claims
need to be backed up with a demonstration full loopback capability _without_
either side dropping a byte, with no pauses between serial bits.

~~~
gfwilliams
There is a demonstration there of full loopback, without the 1 sec delay. The
delay is purely so you can send a command using a totally normal audio API
that only uses the sound card when needed.

I could probably get away with 1 stop bit... I didn't try. To be honest if the
transfer speed matters so much, it might be better to use some other means of
communications :)

------
robomartin
This is neat, of course. And it also goes back to old Commodore 64 (and
before) days of using audio for data in/out, including mass storage on audio
tape.

I've always been bothered by Apple and the other tablet maker's choice not to
include an openly usable simple serial port on their devices (or the ability
to use a USB<->serial adapter). I understand the Apple "control everything"
mentality. Their sandbox, their rules. Still, I can only imagine how neat it
would be if all of these devices had a simple two wire serial port available
without limitations. As a result of this we have to go backwards in technology
by some 30+ years for simple little projects.

~~~
binarymax
I always assumed, based on my tiny amount of knowledge of the Square credit
card reader, that this was possible on iOS?

[https://squareup.com/reader](https://squareup.com/reader)

~~~
lgeek
I think it's using the analog audio hardware, similarly to this project.

------
Schweigi
Direct link to their new Kickstarter campaign for the Espruino Pico:
[https://www.kickstarter.com/projects/gfw/espruino-pico-
javas...](https://www.kickstarter.com/projects/gfw/espruino-pico-javascript-
on-a-usb-stick) (4 days left)

------
yitchelle
This remind me of the days of debugging an 8bit micro with only one spare IO
left. I had to write a big-banged UART with a half-duplex serial protocol over
it. Thank goodness that I was debugging anything approaching real time.

------
spiritplumber
[http://robots-
everywhere.com/re_wiki/index.php?n=Main.AudioS...](http://robots-
everywhere.com/re_wiki/index.php?n=Main.AudioSerial) If anyone wants the
android serial output app (I did this in 2010, one way only though, fwiw) it's
here. Their circuit is simpler, though - this was designed to work with a
Parallax Prop or an Arduino. However, my app will work with this.

~~~
gfwilliams
Thanks! I'd seen your post when I googled to see if it could be done. It's
just nice not to have to wire up so many components, or to need a battery!

------
IvyMike
Is it Hayes compatible? ;)

------
rglover
Just remembered I've had an Espruino controller in my drawer for like...a
year. Whoops.

------
eridal
wow this brings a new set of possibilities to the table!

[http://www.slideshare.net/Sudar/transfering-data-using-
audio...](http://www.slideshare.net/Sudar/transfering-data-using-audio-signal-
in-android)

~~~
scoot
New?
[http://en.wikipedia.org/wiki/Compact_Cassette#Data_recording](http://en.wikipedia.org/wiki/Compact_Cassette#Data_recording)

