Start --> Preferences --> Raspberry Pi Configuration
Interfaces --> I2C --> Enable
Reboot your Raspberry Pi
Install the python I2C libraries if you haven't already.
sudo apt-get install python-smbus python3-smbus python-dev python3-dev i2c-tools
Download the FliteSensor library if you haven't already.
https://github.com/DJMarlow/Flite_Python
Import the FliteSensor library:
from flitecore import FliteSensor
Construct an instance of your FliteSensor:
Argument 1 - The color of the Flite sensor (BLACK, BLUE, RED, GREEN), BLACK used in this example
Argument 2 - A directory to store the sensor calibration data
fliteSensor = FliteSensor("BLACK", "/home/pi/Documents/FliteCal/")
The color of the Flite sensor must be BLACK, BLUE, RED, or GREEN. This matches the color of the sensor enclosure.
Initialize your Flite sensor once at startup:
fliteSensor.beginSensor()
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:
level = fliteSensor.getLevel()
Get the current temperature in degrees F:
temperature = fliteSensor.getTemperature()
Get the current pressure in PSI:
pressure = fliteSensor.getPressure()