Headphone Jack Communications

It's possible to use normal Headphone and Line In/Microphone connections as a 3.3v 9600 baud serial port. This means you can connect to a totally normal Espruino without needing USB or drivers.

All you need is a very simple circuit using a few cents worth of components. You can do this in two ways:

Note: DO NOT RUN THE TOOLS SHOWN HERE WITHOUT THE HEADPHONE JACK CABLE PLUGGED IN - it makes nasty noises, and if you have the volume turned up high it might damage your speakers.


Serial pin Original Espruino Pico
RX A10 B7
TX A9 B6


Bidirectional headphone jack circuit

The circuit above shows a 4 pin jack plug (like you'd have in a smartphone). If you're using a PC with a separate Microphone jack then you'll need to wire up two jacks, one for each.


Unidirectional headphone jack circuit


As you can't get power down the headphone jack, Espruino will need an external power source.

You can use a battery or USB, but if using USB then don't use your PC. When connected to a PC via USB Espruino will automatically move the 'console' over to USB, and you won't be able to interact with it.

How does it work? (electrically)

Transmit to Espruino

Logic inputs on Microcontrollers have to convert a voltage to a 1 or a 0, however that voltage can be anywhere between 0 and 3.3v. In order to avoid noise and to be error tolerant, they set some simple rules:

At the same time, the headphone output of your computer generally produces -1V to +1V. so a voltage swing of 2 volts. If we could shift that (by adding about 1.5V) then it'd produce 0.5V to 2.5V - just enough for the microcontroller.

So that's what we do:

And then it's just up to the PC to output the correct sounds (signals) on the headphone jack.

Note: Most computers already have a ~10uF capacitor in their headphone output, meaning the capacitor might not be needed. However some computers may not have it so we'd always suggest including one.

Receive from Espruino

Receiving is even easier, as we can use some software in the PC to decode the signals that come from Espruino. All we care about is making sure the signals aren't so big that they might damage your computer.

So all we do is use a potential divider (R2 and R3) to convert the 3.3v Espruino TX signal into a 1.6v signal for the microphone. In fact if you didn't care much about your computer, you could just connect directly and the computer's input protection circuitry would probably protect it - buy we really don't recommend that at all!


Note: Plug your headphones in first,

Normal Web IDE

Once that's done, you can click the Send to Espruino button and write any code you want!


If you have a bidirectional cable then pressing the Reset button on your Espruino (or power-cycling the Pico) should show you the Espruino Logo.

If you can't get the logo, but can send LED1.set() then fiddle with the Connect over Audio settings again. You may need to invert the output but not the input, or vice-versa.

When that's done you can use Espruino totally normally - including the left-hand side 'terminal'.

Online Web IDE

Since you're just using the headphone jack, there's actually no need for the Chrome Web App at all.

Simply run the Web IDE online by clicking here - and use the instructions from above.

Note: this is a work in progress - any changes that could be made to the code at https://github.com/espruino/EspruinoWebIDE would be greatly appreciated!

Your own website

Since it's just audio, you can send information to Espruino using your own websites. Just include the file on your webpage with:

<script src="https://espruino.github.io/EspruinoOrion/serial_to_audio.js"></script>

And then to send and execute code, do something like the following:

// audio_serial_invert = true; // if your computer needed the inverted polarity

Bidirectional communications are harder, as the relevant code is embedded in the EspruinoTools project. If you're interested please get in touch on the forum and we can work on getting an easy to use library developed.

More examples and information are available on:

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.