Electronic – Analog to Digital convertor using capacitor

analogcapacitordigital-logic

I found out that I can use a capacitor in order to get the data from an analog sensor in a digital manner(Connecting the analog sensor to the GPIO of a Raspberry Pi).

I have a 1μF polarised capacitor. Is it suitable? How should I connect it in order to work?

The sensor I'm talking about is the below push sensor.

Is it ok to connect GND to GND, VCC to 3.3V Power and the capacitor with the positive branch to OUT and with negative to the GPIO pin?

Here is the datasheet of the sensor: http://www.robofun.ro/docs/2010-10-26-DataSheet-FSR400-Layout2.pdf

Thank you!

enter image description here

Best Answer

Use two GPIO pins, alternate between input and output mode

Steps:

Discharge the capacitor

Charge one known resistor

Discharge capacitor

Charge the UNKNOWN resistor (the sensor)

http://www.doctormonk.com/2013/12/analog-sensors-without-analog-inputs-on.html

Use GPIO as input mode to detect the charge up reaching theshold (about mid point voltage)

This technique allow simple low cost MCU without build in ADC to read analogue sensor (variable resistance depending on sensed quality), including temperature (thermistor), humidity, light (CdS), force, etc.

Good absolute accuracy if the known resistor is high accuracy. Tolerance of capacitor is cancel out.

Widely used in consumer electronics device. Have excellent resolution, can be up to 16 to 20 bits or so. Typical conversion time in range of 100ms. Faster conversion can be traded with smaller resolution. Can use MCU hardware timer.

Raspberry Pi (vs Arduino) has no build in ADC and this technique is often used.

One pin version, lower absolute accuracy as affected by capacitor tolerance. http://www.raspberrypi-spy.co.uk/2012/08/reading-analogue-sensors-with-one-gpio-pin/

Also, three pin version, use one pin for sensing (input mode) and quick discharge (output), for quicker conversion time.