Using multiple FlexiForce sensors

Apologies in advanced that this is going probably going to be long, but I’ll add lots of pictures and diagrams!

I’m new to this arduino world, and even newer to what are probably elementary level circuits. In short, I am making a keg monitor for my kegerator. It will monitor temperature, the weight of the keg and the CO2 canister, and light (to turn off the LCD when the door is closed). I have the temp and light sensors working, that was easy. I am having problems with the FlexiForce weight sensors (variable resistors). I stripped down the Arduino code to just deal with the weight, here is my current code:

#include <SoftwareSerial.h>
#include <OneWire.h>

int kegSensorPin = A0;
int coSensorPin = A2;

SoftwareSerial lcdSerial(4,3); // pin 2 = TX, pin 3 = RX (unused)

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

  delay(500); // wait for screen to clear
}

void clearLcd(){
  lcdSerial.write(0xFE);   //command flag
  lcdSerial.write(0x01);   //clear command.
}

void initLcd() {
  clearLcd();
  lcdSerial.write(254); // move cursor to beginning of first line
  lcdSerial.write(128);
}


void loop(){

  initLcd();

  float rawKegWeight = analogRead(kegSensorPin);
  float rawCoWeight = analogRead(coSensorPin);

  //   THIS SECTION FOR DEBUG PURPOSES
  
   Serial.print("Keg: ");
   Serial.println(rawKegWeight);  
   Serial.print("CO2: ");
   Serial.println(rawCoWeight);  
   

  //The math here will need to be modified to reflect 100 for full
  //and 0 for empty.  For now it's a percentage of all on or all off.
  int kegWeight = rawKegWeight * (100.0 / 1023.0);
  int coWeight = rawCoWeight * (100.0 / 1023.0);

  lcdSerial.print("Keg: ");
  lcdSerial.print(kegWeight);
  lcdSerial.print("%");

  lcdSerial.write(254); 
  lcdSerial.write(192); // move to second line
  lcdSerial.print("CO2: ");
  lcdSerial.print(coWeight);
  lcdSerial.print("%");

  delay(1000);

}

And here is how I initially had my circuit set up:

http://s28.postimg.org/cnoj8f4yl/diagram_Vdivide.jpg

When running two FlexiForce sensors like this, when I added pressure on one, the output values on BOTH went up. I don’t know why. If anyone can tell me why two voltage divider circuits next to one another like that will affect one another, I’d love to hear it! So anyway I looked at the data sheets.

http://s15.postimg.org/m68gra623/manufacturer.jpg

Ok, so the manufacturer says to run the whole thing through an opamp. The way they have it set up in the data sheet it appears to be an inverting amplifier. So I bought a MCP6002 and rebuilt my circuit using the method the FlexiForce datasheet showed.

http://s30.postimg.org/huokwqfoh/diagram.jpg

But now my output sits at 0. I’ve tried different resistors in Rf, but it’s still 0. I’m not a EE, in fact I’m quite new at circuit design, so I’m pretty sure I have it all wrong. I tried reading the output voltage with a multimeter, and it was negative, and only slightly lower than 0.

It doesn’t really matter the output, so long as it’s variable and I can math it to show 0 for empty keg, and 100 for full keg.

Thanks for any and all help!

If anyone can tell me why two voltage divider circuits next to one another like that will affect one another, I’d love to hear it!

What's happening is that you have put a large resistor in series with the analog input pin when you do the voltage divider w/the flex sensor and 1M resistor. The Arduino's "brain" switches each input pin to it's single A/D converter, waits a short period of time and then does the actual conversion. There' s also a small capacitor (effectively) in parallel w/the A/D converter. Due to the high resistance this cap never completely settles when switching from one analog pin to the next. The result is both readings tend to mush together.

There are at least 2 ways to fix this; one is to put an op-amp btw the high resistance divider and the analog input pin. This way the pin is “fed” from the op-amp’s, low resistance, output. Your circuit doesn’t work for reasons I’ll explain below. The other way is to put more time btw switching of the pins and reading the A/D, to allow the cap to settle to the chosen pin’s voltage. The simplest way to do that is to do an analogRead() of the pin, delay some amount of time and then redo the analogRead(). The switch matrix (aka MUX) remains switched btw the 2 readings. Use only the 2’nd reading. Do this for both pins. If you can provide a link for your sensor strips, I can tell you the wait time. Since your loop doesn’t need to run quickly, start with 10msec.

Your circuit gives a zero because it’s an inverting configuration. It’s trying to output some negative voltage since it’s input is 5v. It can’t go negative since it’s powered by +5v and gnd. The best it can do is zero (or near to it). And even if it did go negative, the A/D converter only works for 0 - 5v. So you need a non-inverting configuration.

FWIW how are you intending to use the flex sensors to measure weight ? Why not a load cell like this …

https://www.sparkfun.com/products/10245

or a pressure sensor …

https://www.sparkfun.com/products/9376

??

FYI - circuit and output for one FSR

Thanks for all the information! I left the project on my desk at work, so I’ll have to try the read delay on Monday.

I am trying to measure weight - the weight of a keg and a CO2 canister. I am using this sensor strip:

https://www.sparkfun.com/products/8685

It’s not really a flex sensor, the name is a bit misleading. The weight tolerance has to be able to support up to 60 pounds, because that’s about the weight of a full sixth-barrel / torpedo keg.

The load sensor you linked may be a better solution, though building it in to a scale like platform might be a bit more challenging than my current “put the flexiforce sensor between two pieces of plywood and put the keg on top” solution.

ciavolella:
It’s not really a flex sensor, the name is a bit misleading.

OK, if you center the weight on a puck (as mentioned in the manual) it should work.

The simplest way to do that is to do an analogRead() of the pin, delay some amount of time and then redo the analogRead().

Totally worked. Thank you!

Now I can update the code, put all the other sensors back on, and install this puppy.

ciavolella:
Totally worked. Thank you!

Now I can update the code, put all the other sensors back on, and install this puppy.

Kewl. Pics ... or it didn't happen ! :mrgreen:

Soon as it’s done, pics will happen. Right now it’s just a bunch of jumper wires, an Arduino and a breadboard. I have a ProtoShield and a tall enclosure. Just need to build out the ProtoShield, box it up, and magnet it to the side of the kegerator fridge. Pics of the build and stuff to come.

Thanks again for the assist. I knew something had to be up with the FlexiForce voltage divider circuit. I just didn’t know enough about the way the Arduino is engineered. Smarter every day. Gotta love them internets.

@ciavolella, please PM me – I have a question or two for you.

Thanks!

Butch