Hi - this is something I showed off at FullStack and EclipseCon, but sadly the videos aren't online yet, so I did some more :)
Background
What if you want to control some hardware from a computer, phone or tablet? That's almost certainly going to involve developing an application per platform right now - and that's a lot of platforms: iOS, Android, Mac, Windows, Linux, Chromebook, and so on...
What if you could just use webpage instead? Web pages are much easier to make, and they run on almost everything...
Well, how could you communicate from a website? The obvious answer is via the internet, but WiFi on a microcontroller draws quite a lot of power, and is often quite expensive...
But if not that, what else? Not all devices have Bluetooth (and it can't be accessed from a website anyway), and while most devices have USB they all have different type sockets.
In fact the one socket that pretty much every computer has is a headphone jack - and it's easily accessible from a website without the need for drivers or special permissions.
Note that there was no extra software on the Espruino Boards. The data coming out of the cable is interpreted directly by the USART as JavaScript code which is then executed.
Those videos show transmitting, but receive works too - to the point where there's a full terminal window just like the left-hand side of the Web IDE:
There's also integration with Eclipse Orion. See here for more details.
How?
It turns out it's relatively easy. To get a '1' on one of Espruino's inputs, you need at least 1.546v, and to get a '0', you need below 1.166v. You just need to shift the 'resting' voltage level coming out of the headphone jack to something that just about reads as a '1' (so more than 1.546v). This is done with nothing more than a capacitor and two resistors (one of which is built in to Espruino) - see the diagram at the bottom of this post.
As the headphone jack can output -1v to +1v (and all you need is 0.4v), you've got plenty of voltage swing available to make reliable communications. It's then just a matter of creating the right waveform.
And then to send and execute code, do something like the following:
audio_serial_write("digitalWrite(LED1,1);\n");
Two directional communications is harder as the code for it is part of and depends on the EspruinoTools library on GitHub - so would be a little harder to extract and use on its own.
What's it useful for?
There are so many uses for this, for instance:
Teachers can use low-cost Android tablets to teach programming and robotics - there's no software to install, no wireless pairing and no fragile connector - just sturdy a headphone jack.
Maybe you want to read data back from a data logger at a remote location? It's easy to make a headphone plug waterproof too.
Maybe you want a web-controlled hexapod that walks around holding your phone? Who doesn't? This would be perfect for that.
You've might have made something and you just want a nice easy touchscreen UI to set it up - but don't want all that extra mass and cost connected to it all the time.
Will it work on non-Espruino devices?
Maybe, but not without having to write more software to run on the device you're connecting to. With Espruino you can just get it out of the packet, add the 2 components and headphone wires, and you're sorted!
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi - this is something I showed off at FullStack and EclipseCon, but sadly the videos aren't online yet, so I did some more :)
Background
What if you want to control some hardware from a computer, phone or tablet? That's almost certainly going to involve developing an application per platform right now - and that's a lot of platforms: iOS, Android, Mac, Windows, Linux, Chromebook, and so on...
What if you could just use webpage instead? Web pages are much easier to make, and they run on almost everything...
Well, how could you communicate from a website? The obvious answer is via the internet, but WiFi on a microcontroller draws quite a lot of power, and is often quite expensive...
But if not that, what else? Not all devices have Bluetooth (and it can't be accessed from a website anyway), and while most devices have USB they all have different type sockets.
In fact the one socket that pretty much every computer has is a headphone jack - and it's easily accessible from a website without the need for drivers or special permissions.
What's it like:
https://www.youtube.com/watch?v=BQDZNFXygrM
https://www.youtube.com/watch?v=IP7e5KJGVnM
Note that there was no extra software on the Espruino Boards. The data coming out of the cable is interpreted directly by the USART as JavaScript code which is then executed.
Those videos show transmitting, but receive works too - to the point where there's a full terminal window just like the left-hand side of the Web IDE:
https://www.youtube.com/watch?v=3gWgrlbitiY
There's also integration with Eclipse Orion. See here for more details.
How?
It turns out it's relatively easy. To get a '1' on one of Espruino's inputs, you need at least 1.546v, and to get a '0', you need below 1.166v. You just need to shift the 'resting' voltage level coming out of the headphone jack to something that just about reads as a '1' (so more than 1.546v). This is done with nothing more than a capacitor and two resistors (one of which is built in to Espruino) - see the diagram at the bottom of this post.
As the headphone jack can output -1v to +1v (and all you need is 0.4v), you've got plenty of voltage swing available to make reliable communications. It's then just a matter of creating the right waveform.
As above, you can do similar things for receiving data too - everything you need is here: https://github.com/espruino/EspruinoOrion
How's it used?
To get one-way comms, just include the file:
And then to send and execute code, do something like the following:
Two directional communications is harder as the code for it is part of and depends on the EspruinoTools library on GitHub - so would be a little harder to extract and use on its own.
What's it useful for?
There are so many uses for this, for instance:
Will it work on non-Espruino devices?
Maybe, but not without having to write more software to run on the device you're connecting to. With Espruino you can just get it out of the packet, add the 2 components and headphone wires, and you're sorted!
If you've come to this site through a referral, please check out the KickStarter that I'm currently running for the tiny board that you see in the videos.
1 Attachment