Raspberry Pico Capacitive Sensor

Ferry Djaja
3 min readJan 12, 2024

I built this simple touch interface with Raspberry Pico to execute the automation in Home Assistant.

All you need are a few components:

  • A Raspberry Pico Wireless device.
  • A Common Anode RGB LED (not the Common Cathode RGB LED).
  • A resistor 220 Ω.
  • A USB C cable for touch panel. I’ve damaged my USB C cable, but instead of discarding it, I’m repurposing it for this specific use case.

The Design

Here is the design diagram illustrating the connection of Pico PINs to the RGB LED.

Python Code

We will write a Python code based on this Git repo and modify to our needs for activating the RGB LED.

The RGB LED will on with the following conditions:

  • Blue LED turns on when the touch level is above 0.9.
  • Red LED turns on when the touch level is between 0.5 and 0.9.
  • Green LED turns on when the touch level is below 0.5.

If the Blue LED remains on for a specific duration (in this instance, 3 seconds), it will initiate an automation in Home Assistant and you can do whatever you wish in there.

Here is the complete code:

--

--