Making sensors come alive using the drawdio circuit

Key Insight: We took the output of the drawdio circuit and connected it to the mic pin of the headphone jack like so :

This was our key breakthrough. Having interfaced the drawdio with the computer opened a plethora of possibilities for us to play around with.

1418185195

In this following videos, we have connected the pin -3 of the drawdio circuit (above) to the mic of the headphone jack and in the placeholder of R5, we insert different sensors such as the LDR(Light dependent Resistor). IR led, etc. This allows us to have an audible feedback from the sensors that are connected, making them ‘come alive’.

 

Wireless Drawdio circuit

                           Humans as elements of a circuit

Inspiration:

Humans are amazing antennas!

Humans as antennas is an established paradigm and the works on Body Coupled Communications(BCC) and Personal Area Netwok (PAN) from the MIT media lab are at the frontiers of innovation based on this concept. Their works get into the technicalities of such a communication such as protocols, circuit design, etc. The only down side being that, the technology is inaccessible to the common man. If you still want to experiment with it, we have something that could get you started.

Screenshot_2019-05-19_15-55-21

In this post, we connected the headphone jack’s mic wire to the human body and used it to transmit and receive signals through space – Wireless!

Why the headphone jack ?  Why not? Not only is it something that is readily accessible, it also does not require additional hardware.

Screenshot_2019-05-19_15-54-18

Demonstration:

In this post, we demonstrate this idea by turning the drawdio circuit made by Jay Silver using the 555 timer ‘wireless’ by using the human as an antenna.

In order to make the drawdio circuit (see diagram below) wireless, take out R5 and place your hand instead to complete the circuit.

 

 

Hook up a headphone jack to your computer and listen to the signals received on your mic. Your body will act as an antenna and you will be able to receive the signal on your computer. Make sure to adjust the gain of the microphone accordingly.

(see our post – Preparing a headphone jack for hacking to know how to set up your headphone jack in order for this to work)

Now if you are aware about common grounds then the above video might not seem as appealing because the drawdio in the above case by powered by an Arduino connected to the computer which is receiving the audio signal. The same concept does work with different grounds as well as we demonstrate in the following video where the drawdio is powered externally through an OTG cable.

If you would like to transmit the drawdio output in the RF range instead, one can hook up the output of the drawdio to a crystal oscillator and touch the output wire of the crystal oscillator instead.  In this video, a 32 MHz crystal oscillator is used and a FM radio app tuned at 96MHz is used to pick up the drawdio signal. This would be another way to demonstrate the idea of using the human body as an antenna.*

Instead of the drawdio, if you would like to transmit serial data from the USB port wireless, we can play the same game. Just place your hand on the TX pin of the USB-TTL and listen on the mic of the headphone.

 

What can you do with this ?

 

There are obvious limitations of using a headphone jack for BCC rather than something more dedicated as explored by the folks at the MIT media lab,  this post is an exploration on how one can intuitively achieve this using the headphone jack.

 

*There is a great chance that many of you might have already tried this out in your car at some point.

** More explorations on the drawdio circuit click here

** More explorations on the headphone jack click here.

 

 

 

 

 

 

The anatomy of a headphone jack

Most of us live under the simple algorithm : Plug a headphone into the jack and move on with life. But the beauty of it is what happens during those instances when you insert the jack and the mobile/laptop recognizes the device to be indeed a headphone jack.

Most modern smart-phones and laptops detect a headphone using the following simple principle :

Establish a potential difference between the mic and the ground ( ~ 2- 3 V ) and observe the resistance. If its high, its air and probably nothing has been inserted. If its really low, then a headphone jack has been inserted.

drawing

And the fact that a potential difference is constantly being given between the mic and the ground allows us to plug in a led and light it up .

Corollary 😉 :

All that the phone is looking for low resistance value. You can very easily fool the phone to think that an aluminum foil is a headphone jack.

Older headphone jacks

This answer by Rick on stackexchange answers this question so accurately :

Yjl5u

” Headphone jacks have extra contacts inside, which act as switches. The the drawing below, pins 4 and 5 are intended for sensing that the plug was inserted. They are not intended for audio signal. When the plug is not present, the switche, which are formed by 2 & 4 and 3 & 5, are closed.

When the plug is inserted, these switches are open. The plug flexes 2 and 3 slightly, and they break contact with 4 and 5. You could insert a 3.5mm plastic rod [a dummy] into the jack, which will open the contacts, and the phone might think that earphones are plugged in. ”

 

Headphone jack plugged in or not ? (Software end)

In a previous post , we talked in depth about the /dev/input directory in Linux.  This video talks about how the computer knows whether a headphone jack has been plugged in or not from a software point of view.

The ultimate guide to using LEDs with headphone jack

drawing112

Lighting up an LED using the headphone jack is probably one of most easiest tasks. Take the mic of the TRRS pin ( or left in a TRS ) and connect it to the shorter end of the LED. Take the ground and connect it to the longer end of the led and you are good to go !

A potential difference of ~3V exists between the two pins that is sufficient to light up a LED. Why is there a potential difference in the first place ? Well, this will answered in great detail in one of our post on the Anatomy of a headphone jack.

Now no one wants to stop with just lightning up a LED, so let’s improvise..

 

Controlling LED brightness

Like we said: A potential difference of ~3V exists between the two pins that is sufficient to light up a LED.  By controlling the volume, we can reduce this potential difference and thereby dim the LED.

 

You can control 2 LEDs (min.) with a single headphone jack

With a simple headphone jack, one is capable of controlling 2 LEDs at the very minimum. Take 2 LEDs and connect them both to the Left/Right in the configuration shown below:

drawing-1

If one plays a square wave through the Left/Right then the first LED would light during the positive half of the cycle and the second one during the negative half. This is because LEDs are conductive only in one direction.

You can watch a demonstration of this in the following video.

And as a bonus, we did a frequency sweep  from 1 – 30 Hz (Square Wave) and here is how that looks:

Hang on a second!

If you can do that, then you play songs and also visually witness Beats phenomenon right? Absolutely!

Visualizing songs using LED

Beats phenomenon

Headphone jack as a switch

In all our above setups, we connected the jack directly to the LED. But one might need the LED to be brighter. So, to do that we had to bring in a operational amplifier ( LM324 ). This can be powered using a OTG (On-the-go) cable or using an Arduino.

drawing-2

Now using this we can use the headphone to perform switching operations. And this is what we demonstrate in the following series of videos:

Schematics/Circuit diagrams will be uploaded soon! Thank you.

 

 

 

The headphone jack meets an actual spark gap!

So, we had the opportunity to test out the headphone jack with an actual spark gap and it was absolutely wonderful. Check it out:

With the data we can actualy find out the frequency of the spark occurrence. In our case it turned out to be ~ 34 – 36 Hz. And since this is in the Audible range we can actually hear this (somehow we missed this when making the video)

Screenshot from 2017-06-10 20:01:07

Audio file : GoogleDrive

**

Part – I – Lightning detector with a simple headphone jack

Part – II – Detecting switching ON/OFF of Tube Light using headphone jack

Part – III – Cigarette lighter spark detection using headphone jack

 

It is ridiculously easy to generate any audio signal using Python

Updated: May 15,2019

Now it comes as a surprise to many people when I tell them that generating an audio waveform is extremely simple.

One needs to have basic understanding on how audio signals work and basic python programming to generate any audio wave form. This post will show you exactly how.

Python packages needed: Numpy, Scipy

Screenshot_2019-05-15_11-06-02

How to play the audio the generated audio file on computer ?

1. Command line using SoX

play -t raw -r 44.1k -e signed -b 8 -c 1 test.wav

where -r = sampling rate -b = sampling precision (bits) -c = number of channels

2. Use Audacity (check video)

 

Link to code : GitHub

You can find a list of other waveforms that can be generated using SciPy here

Known Issues:

[1] This does add any headers to the audio file and therefore you cannot play it on any media player as is . Check this reddit post if you really want to have one.

[2] Adding headers to the above code seems to be making it slower. And this is a problem if you want to make larger audio files.

[3] The code generates only 8-bit audio signal. Feel free to play around with the code to change it to other formats.

[4] A lot of technical details were conveniently not included in code in order to appeal to the theme of this post. And therefore this code is not “efficient”.

DIY: Obstacle detector with Audible feedback (IR sensor + Headphone jack + 555 timer)

We were inspired by the buzzer that you find in mobile and laptop showrooms – the ones that produce this annoying high frequency tone if you fiddle a ‘little too much’ with the displayed product.

schematic

We use a 555 timer in its Astable mode to produce the frequency tone and couple it with a digital IR sensor module. We do this by connecting the output pin and the ground parallel to R2 in the figure.

single-ir-sensor

And as a result when there are no objects in the vicinity, the system produces a high frequency tone, but when an object is introduced the sound dies out.  This is attributed to the change in resistance value.

Here is another variation of the same:

Cigarette Lighter spark detection using headphone jack

This is part-III of the post series on detecting electromagnetic waves using headphone jack. In this we capture the EMW that emanate from the spark gap junction on a lighter. This is analogous to our gas lighter experiment but conducted at a smaller scale.

Screenshot from 2017-06-07 11:41:35

We say that this is analogous to the Gas lighter experiment because the waveforms obtained are extremely similar in nature.

Screenshot from 2017-06-07 13:35:47

 

Check out:

Part – I – Lightning detector using headphone jack 

Part – II  – Detecting switching ON/OFF tubelight with a headphone jack