Hi all,
I just started working with the ESP32 and I plan to use it to activate something when a pressure of around 10kg is applied. I purchased the following sensor, which should have the desired range (max force 22 lbs): Pressure Sensor Amazon
Here is my circuit setup with a 10 kOhms resistor:
and here is my code:
#include <Arduino.h>
const int fsrPin = 34; // FSR is connected to GPIO 34
void setup() {
Serial.begin(115200); // Start serial communication at 115200 baud
pinMode(fsrPin, INPUT); // Define fsrPin as an input
}
void loop() {
int fsrReading = analogRead(fsrPin); // Read the value from the FSR
float voltage = fsrReading * (3.3 / 4095.0); // Convert ADC reading to voltage (3.3V reference, 12-bit resolution)
// Calculate force from voltage - this formula needs calibration with actual sensor data
float force;
if (voltage == 0) {
force = 0; // No pressure
} else {
force = (voltage / 3.3) * 100; // Example conversion, replace with calibrated formula
}
// Print the readings
Serial.print("FSR Reading: ");
Serial.print(fsrReading);
Serial.print(" - Voltage: ");
Serial.print(voltage);
Serial.print("V - Force: ");
Serial.print(force);
Serial.println("g");
delay(500); // Delay for half a second
}
The issue is that I easily reach the highest FSR value (4095) with just slight pressure, which should correspond to about 100g, not nearly 10kg.
Am I doing something wrong? I need help, please.
