How to reduce/eliminate fluctuations in FSR sensor?

Below code for connecting 6 FSR 38.1mm Square type with Arduino UNO.

/* FSR testing sketch. 
 
Connect one end of FSR to power, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground 
 

int fsrPins[] = {0, 1, 2, 3, 4, 5}; // Array to store all FSR pin numbers
int numFSRs = 6; // Number of FSRs connected
float fsrReadings[6]; // Array to store analog readings from each FSR
double fsrVoltages[6]; // Array to store voltages for each FSR
double fsrResistances[6]; // Array to store resistances for each FSR
double fsrConductances[6]; // Array to store conductances for each FSR
double fsrForces[6]; // Array to store forces for each FSR
double fsrWeights[6]; // Array to store weights for each FSR

int interval = 1; // Time interval between readings (in milliseconds)
unsigned long previousMillis = 0;

void setup(void) {
  Serial.begin(9600); // We'll send debugging information via the Serial monitor
}

void loop(void) {
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    processFSRReadings(); // Call the asynchronous function to process FSR readings
  }
}

// Asynchronous function to process FSR readings
void processFSRReadings() {
  for (int i = 0; i < numFSRs; i++) {
    fsrReadings[i] = analogRead(fsrPins[i]);
    Serial.print("Analog reading " + String(i+1) + " = ");
    Serial.println(fsrReadings[i]);
    
    // analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
    fsrVoltages[i] = map(fsrReadings[i], 0, 1023, 0, 5000);
    //Serial.print("Voltage reading " + String(i+1) + " in mV = ");
    //Serial.println(fsrVoltages[i]);  

    if (fsrVoltages[i] == 0) {
      //Serial.println("No pressure");
    } else {
      // The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
      // so FSR = ((Vcc - V) * R) / V        yay math!
      fsrResistances[i] = 5000 - fsrVoltages[i]; // fsrVoltages is in millivolts so 5V = 5000mV
      fsrResistances[i] *= 10000; // 10K resistor
      fsrResistances[i] /= fsrVoltages[i];
      //Serial.print("FSR resistance " + String(i+1) + " in ohms = ");
      //Serial.println(fsrResistances[i]);

      fsrConductances[i] = 1000000; // we measure in micromhos so 
      fsrConductances[i] /= fsrResistances[i];
      //Serial.print("Conductance " + String(i+1) + " in microMhos: ");
      //Serial.println(fsrConductances[i]);

      // Use the two FSR guide graphs to approximate the force
      if (fsrConductances[i] <= 1000) {
        fsrForces[i] = fsrConductances[i] / 300; // The division by 350 is an empirical constant used to approximate the force based on experimental calibration.
        fsrWeights[i] = fsrForces[i] / 9.80665;
        //Serial.print("Force " + String(i+1) + " in Newtons: ");
        //Serial.println(fsrForces[i]);
        //Serial.print("Force " + String(i+1) + " in Kg: ");
        //Serial.println(fsrWeights[i]);
      } else {
        fsrForces[i] = fsrConductances[i]-1000;
        fsrForces[i] /= 250;
        fsrWeights[i] = fsrForces[i] / 9.80665;
        //Serial.print("Force " + String(i+1) + " in Newtons: ");
        //Serial.println(fsrForces[i]);   
        //Serial.print("Force " + String(i+1) + " in Kg: ");
        //Serial.println(fsrWeights[i]);         
      }
    }
    //Serial.println("--------------------");
  }
}

And my output 10 samples with interval for same weight in different sensor.

below is my circuit connection.

I need to reduce the fluctuations in each FSR, so that i can able to calibrate for weight calculation.

Thanks in advance.

your code has comments issues.

post the output as text, and the circuit directly here (drag and drop the image into the post)


  • ensure you perform a double read of the analog pins to let the voltage stabilize for the ADC
  for (int i = 0; i < numFSRs; i++) {
    analogRead(fsrPins[i]); // throw away 
    fsrReadings[i] = analogRead(fsrPins[i]);
  •••
  • quality of your power supply is also important

What is that double read.?
my output, first is raw analog reading and next average output. it keep on increasing and when i place next the same weight of 100g it will start with different value and keeps increasing.

258 256 
257 256 
258 256 
260 257 
258 257 
259 257
257 257 
258 257 
258 257 
258 257 
259 257 
257 257 
258 257 
258 257
257 257 
259 257 
259 257 
259 257 
257 257 
259 257 
260 257 
257 257 
260 257 
257 258 
258 258 
258 258 
257 258 
257 257 
258 257 
259 257 
258 257 
257 257 
259 257 
256 257 
257 257 
259 257 
258 257 
257 257 
257 257 
257 257 
258 257 
259 257 
258 257 
259 257 
259 257 
255 257 
259 257 
257 257 
259 257 
257 257 
257 257 
259 257
259 257
260 258 
258 258 
259 258 
259 258 
260 258 
259 258 
259 258 
260 258 
259 258 
259 258 
259 258 
260 258 
259 258 
260 259 
260 259
259 259 
261 259
258 259 
260 259 
258 258 
261 258 
260 258 
261 259 
260 259 
258 259 
258 258 
261 258
259 258
261 258 
261 259 
261 259
259 259 
260 259 
261 259 
260 259 
261 260 
260 260 
262 260 
262 260 
262 260 
261 260 
260 260
261 260 
262 260 
258 260 
260 259 
260 259 
260 259 
260 259 
258 259
260 259 
261 259
261 259
264 259 
261 259 
261 259 
261 260 
260 260 
262 260 
261 260 
262 260 
261 260 
261 261 
260 260 
261 260
263 260 
260 260 
260 260 
258 260 
262 259
260 259 
263 259 
260 259 
259 259
260 259 
258 259 
262 259 
262 260 
266 260
260 260 
262 260 
264 261
262 261 
264 261
264 261 
264 261
266 262 
268 262 
266 263 
259 263 
262 263 
264 263 
265 263 
263 263 
262 263 
263 263 

@sugan04

FSRs may be easy to use but they are not an accurate means to measure force. Basically when you use FSRs you should only expect to get ranges of a response, hard, medium, soft, etc. They also vary some from sensor to sensor perhaps 10% or more. So, while FSRs can detect weight, they're a bad choice for detecting exactly how many pounds of weight are on them.

My application: I need to measure force given for ultrasound scan by the doctor using Probe. @jim-p

I don't see how that would be possible because the FSR would interfer with the ultrasound transmssion/reception.

That’s to let the input of the ADC getting more stable

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.