Download the FliteSensor library if you haven't already.
https://github.com/DJMarlow/Flite_Arduino
Add this to the top of your sketch:
#include <FliteSensor.h>
Construct an instance of your FliteSensor:
char color[] = "BLACK";
FliteSensor fliteSensor = FliteSensor(
color,//This is the color of the Flite sensor (BLACK, BLUE, RED, GREEN), BLACK used in this example
201,//This is the memory location in EEPROM for the low calibration distance
211,//This is the memory location in EEPROM for the low calibration level
221,//This is the memory location in EEPROM for the high calibration distance
231,//This is the memory location in EEPROM for the high calibration level
241,//This is the memory location in EEPROM for the zero PSI offset
251);//This is the memory location in EEPROM for the temperature offset
The color of the Flite sensor must be BLACK, BLUE, RED, or GREEN. This matches the color of the sensor enclosure.
The following 5 parameters represent the memory locations on your Arduino's EEPROM.
These are the locations where the calibration data is stored, so it won't be lost if your device is powered off.
More information on Arduino EEPROM usage can be found at:
https://www.arduino.cc/en/Reference/EEPROM
Initialize your serial output to the console and your Arduino's EEPROM:
Serial.begin(115200);
EEPROM.begin(512);
Initializing your Flite sensor will return a bool indicating if the initialization was successful:
if(fliteSensor.beginSensor()){
Serial.println("Successfully began FliteSensor sensor!");
} else {
Serial.println(" Error - Unsuccessful beginning FliteSensor sensor!");
}
Before your Flite sensor can provide accurate gallon level readings, it must be calibrated. Calibration requires two points, preferably close to the minimum and maximum keg levels. Call each function when the sensor is installed on a keg with the known level (gallons) passed as the parameter:
fliteSensor.calibrateLow(0.0);
fliteSensor.calibrateHigh(5.0);
The temperature sensor in the lid can read a higher temperature than the liquid in the bottom of the keg. For this reason, a temperature offset can be added which is SUBTRACTED from the temperature value read, and this corrected value is displayed. With the sensor sitting at ambient pressure, call the below funtion to assign a temperature offset:
fliteSensor.setTemperatureOffset(7.5);
Before your Flite sensor can provide accurate pressure readings, it must be calibrated. Flite uses an absolute pressure sensor, so any changes in elevation must be accounted for. With the sensor sitting at ambient pressure, call the below funtion to zero the pressure sensor:
fliteSensor.calibrateZeroPSI();
The Flite sensor will return a value of floating point type when the below functions are called.
Get the current level in gallons:
float level = fliteSensor.getLevel();
Get the current temperature in degrees F:
float temperature = fliteSensor.getTemperature();
Get the current pressure in PSI:
float pressure = fliteSensor.getPressure();