Arduino UNO Q - Touch Sensor
A touch sensor works like a digital button — it outputs HIGH when touched and LOW when not touched. On Arduino UNO Q, you can monitor touches locally on the MCU, or use Bridge to detect and act on touch events from the Linux side via Telegram.
In this tutorial, you will learn:
- What a touch sensor is and how it works
- How to wire the touch sensor to the Arduino UNO Q MCU
- How to program the MCU (C/C++ Arduino code) to read touch sensor state
- How to program both the Linux side (Python) and MCU side (C/C++) to detect touch events via Bridge
- How to receive Telegram notifications when the touch sensor is activated on Arduino UNO Q
- How to use OpenClaw on Arduino UNO Q with the touch sensor

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of the Touch Sensor
Pinout
The touch sensor has three pins:
- GND: Connect to GND (0V)
- VCC: Connect to 3.3V or 5V
- SIGNAL: Digital output — outputs LOW when not touched, HIGH when touched. Connect to a digital pin on the Arduino UNO Q MCU.

How It Works
- When the sensor is not touched, the SIGNAL pin is LOW
- When the sensor is touched, the SIGNAL pin is HIGH
The touch sensor behaves exactly like a momentary push button — it can be read with digitalRead() and requires no library.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
| Touch Sensor Pin | Arduino UNO Q MCU |
|---|---|
| GND | GND |
| VCC | 3.3V |
| SIGNAL | D7 |
How To Program For Touch Sensor
- Set up the Arduino UNO Q MCU pin as a digital input:
- Read the sensor state:
- Check and respond:
Arduino UNO Q Code
The Arduino UNO Q has two processors working together:
- The STM32 MCU reads the touch sensor directly via a digital pin — all sensing runs on the MCU
- The Qualcomm MPU runs Debian Linux and handles Wi-Fi, Python, and cloud connectivity
- In this section, only the MCU is programmed — the Linux side stays idle. A later section shows how both processors work together via Bridge.
The MCU reads the touch sensor every 500ms and prints the state to the Serial Monitor.
Detailed Instructions
First time with Arduino UNO Q? Follow the Getting Started with Arduino UNO Q tutorial before proceeding.
- Connect: Wire the touch sensor to the Arduino UNO Q MCU as shown in the wiring diagram.
- Open Arduino App Lab: Launch Arduino App Lab and wait until it detects your Arduino UNO Q.
- Create a new App: Click the Create New App button.

- Give the App a name, for example: TouchSensor
- Click Create to confirm.

- Paste the sketch: Copy the MCU code above and paste it into sketch/sketch.ino. Keep other files as default.
- No library required — the touch sensor uses only the built-in digitalRead() function.
- Upload: Click the Run button in Arduino App Lab.

- Place your finger on the sensor and watch the Serial Monitor.
App Lab Console Output
Bridge: Linux + MCU
This section shows how to program both processors of the Arduino UNO Q so the Linux side can detect touch events via Bridge:
- The touch sensor is connected to the MCU digital pin — the MCU monitors state changes in loop() and sets an event flag when touched
- The MPU cannot read the digital pin directly — it calls Bridge functions to query the current state or consume the touch event
- The MPU has Wi-Fi — running full Debian Linux, it can react to touch events and send Telegram notifications
- Arduino_RouterBridge enables RPC communication between the two processors
- ⚠️ /dev/ttyHS1 (Linux) and Serial1 (MCU) are RESERVED by the router — never open them in user code
In short: MCU detects touch events in loop() → MPU polls via Bridge → MPU triggers actions over Wi-Fi.
MCU Code (Bridge)
Python Code (Bridge)
Detailed Instructions
- Connect: Wire the touch sensor to the Arduino UNO Q as shown in the wiring diagram.
- Open Arduino App Lab: Launch Arduino App Lab and wait for the board to be detected.
- Create a new App: Click Create New App, name it TouchSensorBridge, then click Create.
- Paste the MCU sketch: Copy the MCU Bridge code above and paste it into sketch/sketch.ino.
- Paste the Python code: Copy the Python Bridge code above and paste it into the Python file in the App.
- Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.

- Search for Arduino_RouterBridge created by Arduino and click the Install button.
- Upload: Click the Run button in Arduino App Lab.

- Touch the sensor and watch the Python console report the state change.
App Lab Console Output
Telegram
Get instant Telegram notifications when the touch sensor is activated.
MCU sketch: Keep the same MCU sketch from the previous Bridge section.
Python Code (Telegram)
Detailed Instructions
- Replace YOUR_TELEGRAM_BOT_TOKEN with your actual bot token from BotFather.
- Replace YOUR_CHAT_ID with your Telegram chat ID.
- Paste this Python code into your App's Python file (keep the same MCU sketch).
- Click the Run button. Touch the sensor and check Telegram for the notification.
App Lab Console Output
ArduinoBot
OpenClaw
...OPENCLAW
OpenClaw support for Arduino UNO Q Touch Sensor is coming soon.
...OPENCLAW
Project Ideas
You can build many useful projects with the touch sensor and Arduino UNO Q:
- Touchable Smart Lamp: Touch the sensor to toggle an LED or relay via Bridge — the MPU handles the toggle logic and logs each touch event with a timestamp
- Door Chime: Place the touch sensor near a doorframe — when touched, the MPU plays a sound file or sends a Telegram notification to alert you of a visitor
- Secret Knock Counter: Count consecutive touches within 3 seconds via Python-side logic — if the count matches a preset pattern, Bridge triggers an unlock relay
- Presence-Activated Display: Touch the sensor to wake up an OLED display — the MCU turns on the display via Bridge on the first touch and turns it off after 10 seconds of inactivity
- Lab Safety Confirmation: Require a touch confirmation before a Bridge command activates a high-power relay — the Python side checks get_event() before sending the control signal
Challenge Yourself
Ready to go further with the touch sensor on Arduino UNO Q? Try these challenges:
- Easy: Count the number of touches since startup and expose the count via a get_count(String) Bridge function — the Python side prints the count each time it increases.
- Medium: Implement a double-tap detector: the MCU records touch timestamps and sets a double_tap flag when two touches occur within 500ms — the Python side retrieves this via get_event() and sends a Telegram alert.
- Advanced: Build a touch-based Morse code input: the MCU distinguishes short touches (dot) and long touches (>500ms, dash) — the Python side decodes the sequence and sends the decoded letter to Telegram.