Don't have one? Buy it here
Looking for a more integrated solution? Check out our FDC1004 & ESP32-S3 based Sensything CAP
The FDC1004 is a single-chip IC for capacitance measurement for applications including proximity sensing and liquid level sensing. This is based on the concept of measuring capacitance of an electrode with respect to ground.
This breakout board contains everything to connect it to a MicroPython board over I2C and it can be connected to any other platform with support for I2C two-wire interfaces. We have made several cool projects with it including proximity sensing and liquid-level sensing from the outside of a tank. Check out our Hackster page for the detailed project description.
This is the MicroPython library. It depends only on the MicroPython standard library (machine.I2C) — no external packages. Looking for another platform? See the Arduino, CircuitPython and Raspberry Pi (CPython) libraries.
The breakout has Qwiic connectors — a single Qwiic cable carries 3V3, GND, SDA and SCL, so no jumper wires are needed. To wire it by hand instead:
| FDC1004 pin label | Board Connection | Pin Function |
|---|---|---|
| GND | GND | GND |
| SCL | SCL | Serial Clock |
| Vcc | 3V3 | Power |
| SDA | SDA | Serial Data |
Pin numbers vary by board. On a Raspberry Pi Pico / SparkFun Thing Plus RP2040 the Qwiic bus is I2C0 (GP6 SDA / GP7 SCL). On a plain ESP32 try I2C(0, scl=Pin(22), sda=Pin(21)).
The library installs with mip straight from GitHub.
From your computer, with the board connected over USB:
mpremote mip install github:Protocentral/protocentral-micropython-fdc1004From the board itself (if it is on Wi-Fi):
import mip
mip.install("github:Protocentral/protocentral-micropython-fdc1004")In Thonny: Tools → Manage packages → install by URL.
from machine import Pin, I2C
from protocentral_fdc1004 import FDC1004
import time
i2c = I2C(0, scl=Pin(7), sda=Pin(6)) # use your board's Qwiic / I2C pins
fdc = FDC1004(i2c)
while True:
fdc.configure_single(channel=0)
cap_pf = fdc.read_capacitance(channel=0)
print("CH0: {:.3f} pF".format(cap_pf))
time.sleep(0.5)See the examples folder for a single-channel test, a 4-channel scan, and a CAPDAC proximity/touch demo.
| Method | Description |
|---|---|
FDC1004(i2c, address=0x50) |
Construct; reads the device ID and raises if the FDC1004 is not found. |
configure_single(channel, capdac=0) |
Configure a single-ended measurement on channel (0-3); capdac (0-31) subtracts a hardware offset. |
trigger_single(channel, rate=RATE_100_SPS) |
Start one (non-repeating) conversion. |
measurement_done(channel) |
True once a triggered measurement has completed. |
read_raw(channel) |
Signed 24-bit raw result. |
read_capacitance(channel) |
Trigger, wait, and return capacitance in pF. |
read_all() |
Convenience 4-channel scan, returns [pF, pF, pF, pF]. |
reset() |
Software reset. |
Sample rates: FDC1004.RATE_100_SPS, RATE_200_SPS, RATE_400_SPS.
A single-ended measurement is converted to picofarads as:
C_pF = raw24 / 2**19 + CAPDAC * 3.125
where raw24 is the signed 24-bit result (MEAS_MSB << 8) | (MEAS_LSB >> 8), and CAPDAC is the 0-31 offset code (≈3.125 pF/step, up to ~96.9 pF). The I2C address is 0x50 (max 400 kHz), registers are 16-bit big-endian, the manufacturer ID (0xFE) reads 0x5449 and the device ID (0xFF) reads 0x1004. These constants follow the TI FDC1004 datasheet (SNOSCY5) and are the shared source of truth across the Arduino, MicroPython, CircuitPython and Raspberry Pi libraries.
Tested on MicroPython v1.20 and newer, on the Raspberry Pi Pico / RP2040 and a plain ESP32. Any board exposing machine.I2C should work. The library guards its MicroPython-only imports so it also imports under desktop CPython, which is how the unit tests run:
python -m unittest discover tests -v # mocked-I2C unit tests
ruff check . # lintFor further details, refer the documentation on FDC1004 breakout board
This product is open source! Both our hardware and software are open source and licensed under the following licenses:
All hardware is released under Creative Commons Share-alike 4.0 International.
All software is released under the MIT License(http://opensource.org/licenses/MIT).
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please check LICENSE.md for detailed license descriptions.