I have 6 FSRs set up with 10K pull-down resistors running on an Uno with this code below. Yes, I know it's not calibrated and the output is not correct.
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0~5:
for(int i = 0; i < 6; i++){
int sensorValue0 = analogRead(i);
delay(700);
// Convert the analog reading (which goes from 0 - 1023) to voltage range (0 - 5V);
float voltage0 = sensorValue0 * (5.0 / 1023.0);
// print out the value you read:
Serial.print("Sensor "); Serial.print(i);
Serial.print(" = ");Serial.print(voltage0);Serial.print("kg ");
if (i == 5) Serial.println(" ");
}
}
I have replicated this circuit for each FSR, supposedly rated up to 50kg (who knows if AliExpress sent what I ordered?).
The problem is that the output varies massively with a static load. It varies so much that some from readings from a 10kg weight are less than a 20kg weight! Surely, a static load should give a fairly stable reading and the accuracy should be sufficient to distiguish between 10 and 20kg? Am I doing something wrong or is it hardware?
PS I'm a TOTAL noob to Arduino and programming, so please imagine you're explaining to Homer Simpson
You have the breadboards with the split power rails (top and bottom). I can't see in the photo where you feed power to the power rails and I do not see a ground wire from the Arduino.
You need to jumper the splits like as shown in this photo
Thanks, groundFungus. My bad. It was connected but fell off when I took the pic I think. Would it have given any readings if it was disconnected when I was testing? I'm not using the other rails so I guess they don't need connecting?
Anyway, it seems that A5 is causing the issue. It returns varying values between about 170-300! I swapped the FSR, resistor and tried different holes on the board in case it was a bad connection. I have no idea where it's getting those values. Any ideas?
I have about 5kg on A0 and that seems pretty stable returning 5 or 6. Hurrah! Just added another 5kg and it reads 10! This is encouraging...maybe that ground came out earlier?
Without the ground connected the inputs would just read noise from the environment, mostly. The readings could look like the readings from A5. Use your meter to measure the voltage into A5 to confirm whether it follows pressure on the LDR. Measure the resistance of the LDR on A5 to make sure that it is intact.
It sure looks like one of the LDR circuits is on the other side of the break. Could that be the problem with A5?
Doh! I'm an idiot! I forgot there was a break in the middle of that rail (warned you I was a total noob). It's looking much better now. I think you might have saved my remaining (questionable) sanity. Thank you!