Trouble with obtaining readings from flexiforce sensors using Arduino Due

Below is shown the code that I uploaded to obtain readings from three flexi force sensors that produce analog outputs:

float pressureS;

float pressureS1;
float pressureS2; 
int pressurePin = 1;
int pressurePin1 = 3;
int pressurePin2 = 5;
void setup() {
Serial.begin(9600);
}

void loop(){
pressureS2 = analogRead(5);
delay(10);
pressureS2 = (5.0/1023.0)*pressureS2;

pressureS1 = analogRead(3);
delay(10);
pressureS1 = (5.0/1023.0)*pressureS1;

pressureS = analogRead(1);
delay(10);
pressureS = (5.0/1023.0)*pressureS;

Serial.print("Pressure Sensor 1= ");
Serial.println(pressureS);
Serial.print("Pressure Sensor 2= ");
Serial.println(pressureS1);
Serial.print("Pressure Sensor 3= ");
Serial.println(pressureS2);
if (pressureS < 1.25) 
{
 Serial.println("Warning for first sensor");
}
else if (pressureS >= 1.25)
{
Serial.println(""); 
}
delay(100);
if (pressureS1 <1.25){
Serial.println("Warning for second sensor");
}
else if (pressureS1 >= 1.25){
Serial.println("");
}
delay(100);
if (pressureS2 <1.25){
Serial.println("Warning for third sensor");
}
else if (pressureS2 >= 1.25){
Serial.println("");
}
delay(2000);}

Flexiforce sensors are supposed to change its output voltage when pressure is applied to its tip. My issue is when I run this code, I only obtain reading from one of the sensors, in this case the reading being obtained from pin 5 as the reading from it is taken before the other two. The other two pin readings remain idle.
Then I thought I would add a 10 ms delay in between the readings, however that did not show any improvement.
To illustrate my point here is a sample reading:
Pressure Sensor 1 = 0.85
Pressure Sensor 2 = 0.86
Pressure Sensor 3 = 0.85
After applying pressure to each of the sensors the following is obtained:
Pressure Sensor 1 = 0.85
Pressure Sensor 2 = 0.86
Pressure Sensor 3 = 1.36
But an interesting matter to point out is, when I comment out the analogRead() for any two sensors and just test out one single sensor, I obtain desired results. This was seen for each sensor when tested out individually. But when cascaded, I was not able to obtain desired results from all of the sensors. I would really appreciate help regarding this problem.

Thank you :slight_smile:

I’v increased delays.
Code seems OK

float pressureS,pressureS1,pressureS2; 
int pressurePin = 1;
int pressurePin1 = 3;
int pressurePin2 = 5;
const float q = 5.0/1023;

void setup() 
{
  Serial.begin(9600);
}

void loop()
{
  pressureS2 = analogRead(pressurePin2)*q;
  delay(100);
  pressureS1 = analogRead(pressurePin1)*q;
  delay(100);
  pressureS  = analogRead(pressurePin )*q;
  delay(100);
  Serial.print("Pressure Sensor 1= ");
  Serial.println(pressureS);
  Serial.print("Pressure Sensor 2= ");
  Serial.println(pressureS1);
  Serial.print("Pressure Sensor 3= ");
  Serial.println(pressureS2);
  if (pressureS < 1.25)  
     Serial.println("Warning for first sensor");  
        else Serial.println(); 
  delay(100); // why this ??
  if (pressureS1 <1.25)
     Serial.println("Warning for second sensor");
       else Serial.println();
  delay(100);
  if (pressureS2 <1.25)
    Serial.println("Warning for third sensor");
      else Serial.println();
  delay(2000);
}

I assume they are wired correctly, refer to https://www.sparkfun.com/tutorials/389

Bed time..

Flexiforce sensors are supposed to change its output voltage when pressure is applied to its tip.

No they do not.
they change their resistance not their voltage. You have to wire them up with a pull up resistor.

Hi, can you post a picture of your project, especially of the connections of the sensors to the arduino, also a CAD or pic of a hand drawn circuit diagram, this will help us to see if your program is software or hardware based. Also do you have a multimeter to take some measurements?

Hoping we can help.

Tom.... :)

Thank you for the replies. Thank you for the improvised code. I have to test it out on Monday. My partner is dealing with the analog circuits for the three sensors. The connections were checked and the output was also verified using an oscilloscope. Only then they were connected to the MCU via voltage buffers.

Why are you posting this question in 3 places?

Threads merged, duplicates deleted.

Is it really too much to ask that you read a few simple guidelines before posting your code badly and in the wrong place multiple times?