Skip to content

Instantly share code, notes, and snippets.

@DJMarlow
Last active July 28, 2021 15:56
Show Gist options
  • Save DJMarlow/3b5beb512ad97154f8eaf5b2f415bb3e to your computer and use it in GitHub Desktop.
Save DJMarlow/3b5beb512ad97154f8eaf5b2f415bb3e to your computer and use it in GitHub Desktop.

FLITE PYTHON INTEGRATION DOCUMENTATION

Flite Sensor Wiring (Looking at top of sensor)

Pinout_Grey_Background

Enable I2C (Raspberry Pi Example)

Start --> Preferences --> Raspberry Pi Configuration

image

Interfaces --> I2C --> Enable

image

Reboot your Raspberry Pi

Install python I2C libraries

Install the python I2C libraries if you haven't already.

sudo apt-get install python-smbus python3-smbus python-dev python3-dev i2c-tools

Import the flitesensor library

Download the FliteSensor library if you haven't already.

https://github.com/DJMarlow/Flite_Python

Import the FliteSensor library:

from flitecore import FliteSensor

Create FliteSensor Object

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

Initialize your Flite sensor once at startup:

fliteSensor.beginSensor()

Calibrate Flite Sensor Level

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)

Configure Temperature Offset

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)

Zero Flite Sensor Pressure

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()

Read Sensor Data

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment