Problems measuring values from an FSR

I’m building an automatic cat feeder (well updating an existing design). I’ve got a set up where I want to measure the weight of a water bowl and food bowl and since I’m not concerned with exact weights just values of empty and full I wanted to use FSRs. I have them set up separately with two different force sensitive resistors, but in each circuit I have a problem with the values decreasing over time with the same test weight on them.

I have used both this coffee pot example and the Adafruit tutorial circuits, but the same thing happens time after time, I get slowly decreasing values. For example, the empty the circuit reads 4094, I put a weight on it and get 3604 and it will them continue to decrease by one or two slowly over time (i’m measuring an average of 10 readings every 10 seconds). I cannot work out why this is happening - any ideas?

Hi @dpr47

FSR’s are notoriously inconsistent. I got the best results by putting the sensor under one corner of the coffee maker so it read 1/4 of the total weight. They are susceptible to moisture incursion which also causes them to be inaccurate.

Another factor is the resistance of the FSR–the one I used was 10k nominal but given that the input impedance of the ADC on the ST Micro MCU’s used in Particle devices is fairly low (40k ohm) you want to avoid the 100k nominal FSRs. You also need to worry about the other resistor in the voltage divider for the FSR being too large–less than 20k ohm being ideal.

Does the change eventually stop and settle on a consistent value +/- 10 ADC levels? That would sound normal.

Maybe your 10 reading filter has a numeric problem and is cause the average to bias down? If you post the code here, several of us will have a look.

1 Like
int currentReading;
int readingAV;
int count;
int average;

void setup() {
    pinMode(A1, INPUT);
}

void loop() {
    currentReading = analogRead(A1);
    readingAV = (readingAV)+currentReading;
    count=(count)+1;
    
    if(count==30)
    {
        average = (readingAV)/30;
        Particle.publish("ReadingAverage", String(average));
        count = 0;
        readingAV=0;
    }
    delay(1000);
}

I’m using a 1k ohm resistor and the Adafruit square FSR. I changed the code to 30 second averages too.

As an example of what’s happening at around 12pm it was showing values in the range of 3603, 2 hours later its now showing averages around 3581. It’s a slow decrease with 30 second averages, but it’s still happening. Thanks for your help.

This doesn’t touch on your issue, but for completeness.
For analogRead() you don’t need to set pinMode() and it’s even advisable not to, to prevent continous switching between AN_INPUT and your set mode INPUT.

You can also use the more concise C syntax

    readingAV += currentReading;
    count++;
1 Like