Help detecting fencing weapon touch with ESP32 Devkit V1

valentin.fayolle
Posts: 1
Joined: Mon Jun 23, 2025 1:29 pm

Help detecting fencing weapon touch with ESP32 Devkit V1

Postby valentin.fayolle » Mon Jun 23, 2025 1:42 pm

Hello,
I have an ESP32 Devkit V1( See attachment) board and I would like to connect it to a fencing weapon (foil or épée) and detect when the touch button is pressed.

Right now, my Arduino code looks like this:

cpp
Copier
Modifier
#include <WiFi.h>
#include <PubSubClient.h>

int past = LOW;
const int inputPin = 2;
#define ledPin 2

void loop() {
client.loop();
int sensorValue = digitalRead(inputPin);

if (sensorValue == HIGH && past == LOW) {
past = HIGH;
Serial.println("Switch is pressed!");
client.publish("ESP/out", "touch");
} else if (sensorValue == LOW && past == HIGH) {
past = LOW;
Serial.println("Switch is released.");
client.publish("ESP/out", "touch");
}
}

But so far, when I press the button (the "touch"), nothing happens!
Do you have any idea what might be wrong or how to better connect the weapon to the ESP32 for proper detection?

Thanks in advance!
Attachments
ESP32 DEV KIT V1.png
ESP32 DEV KIT V1.png (315.06 KiB) Viewed 74 times

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 5 guests