Skip to content
Shop

Wi-Fi touch sensor (ESP32)

Explore with your favorite AI

Gemini & other AI

Copy this page’s context into your AI to explore how it works and what you can build.

Open Gemini

Copy the prompt, then paste it into Gemini’s message box.

View prompt

This demo uses the Arduino sketch installed on the ESP32 MCU leaf at the factory. Connect your smartphone or PC to Leafony’s Wi-Fi to display touch sensor readings sent from the ESP32 in your web browser.

Use the following leaves.

TypeNameQ’ty
AP02ESP32 MCU1
AV042V~4.5V1
AX07Back to back1
AX0829pin header1
AZ62Connector Cover 2
AZ63Nut Plate2
AAA battery holder1
AAA battery3
M2*15mm screw4
φ10x2mm magnet1

Assemble the leaves as shown in the figure below.

assemble1

Refer to the figure below for the pin assignment of each leaf.

Download the ESP32_AP_Touch folder. Keep ESP32_AP_Touch.ino, esp32_ap_touch.h, web_server.cpp and web_server.h together in the same sketch folder. Copying the .ino file alone is not enough.

  1. Complete Arduino IDE setup for AP02.
  2. Open ESP32_AP_Touch.ino from the downloaded folder. Check that the other source files appear in the IDE.
  3. Select ESP32 Dev Module and the connected port, then compile. The sketch uses the Wi-Fi libraries provided by the ESP32 board package.
  4. Follow the setup page’s upload and Boot switch instructions to upload it to AP02. This replaces the program already on the MCU.

Follow the ESP32 kit getting started guide to connect to Wi-Fi and open the demo. This page focuses on changing the source; the guide contains the battery, SSID and browser steps.

In web_server.cpp, the printMsgIfTouched function defines THRESHOLD = 20. It displays Touch detected when the reading is at or below that value.

  1. Use the original sketch to note the values when touching and not touching pin 26.
  2. Change THRESHOLD to a value between those readings and upload again.
  3. Repeat the check both with and without a touch. Adjust the value if it detects a touch while idle or misses a touch.

The displayed inputs are pins 7, 9, 22, 26 and 28. Pin 24 is omitted because it conflicts with RTC & microSD. Check the pin assignment before adding an input.

ESP32_AP_Touch.ino uses WiFi.softAP to create a network and WiFiServer to serve the page on port 80. WIFI_SSID and WIFI_PASSWORD set the network name and password. After changing them and uploading, reconnect your phone or computer with the new settings.

web_server.cpp reads the touch inputs and generates the HTML. The page’s 0 Stop and 1 second controls stop or resume automatic refresh. For connection problems, use ESP32 Wi-Fi troubleshooting. To restore the original behavior, upload an unmodified copy of this sketch.