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!