Skip to content

Python software that is aimed to run on a Raspberry Pi to read data from Tilt Hydrometer and store it in Firebase Database

License

Notifications You must be signed in to change notification settings

kkocel/tilt-raspi-firebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tilt-raspi-firebase

Python software that is aimed to run on a Raspberry Pi to access Tilt Data and store it in Firebase Database.

Prerequisites

  1. Raspberry Pi with Bluetooth LE support - tested on B3 but Zero W should be ok.
  2. Tilt Hydrometer.

Raspberry Pi and Tilt Hydrometer immersed in water

Installation

  1. Install latest raspian.
  2. Install following components:
sudo apt-get install python-dev
sudo apt-get install libbluetooth-dev
sudo pip3 install pybluez
sudo pip3 install pyrebase
  1. Grab blescan.py, tiltblescan.py and firebasesend.py using wget or similar software.

  2. Configure Firebase

    1. Create a project.
    2. Import initial database structure:
      {
        "batch" : 1,
        "calibration" : {
          "sg" : 0.006,
          "temperature" : 0
        },
        "measurements" : []
      }
    3. From service accounts create key in json format and put it in same directory as .py files.
    4. Update configuration section in firebasesend.py file:
    config = {
      "apiKey": "apiKey",
      "authDomain": "projectId.firebaseapp.com",
      "databaseURL": "https://databaseName.firebaseio.com",
      "storageBucket": "projectId.appspot.com",
      "serviceAccount": "path/to/serviceAccountCredentials.json"
    }

    Where:

    apiKey and projectId can be found in Firebase project settings.

    databaseURL can be found in Database section in Firebase console.

    serviceAccountCredentials.json is previously generated key in json format. Keep in mind to provide full path here in order to run this script periodically by cron.

Running and automating

If everything was configured properly run:

sudo python3 tiltblescan.py

Output should be similar to:

temp correction: 0 sg correction: 0.006 batch: 1
temp F: 84 sg uncal: 1036
temp C: 28.89 sg: 1.042 plato: 10.48

Before putting Tilt into fermenter remember to calibrate, then to sanitize it and set appropriate batch number in your Firebase DB.

Cron

Collecting data from tilt hydrometer and saving it in Firebase can be automated using cron.

Eg. To run script for every five minutes edit crontab file by calling crontab -e and add following line"

*/5 * * * * sudo /usr/bin/python /home/pi/firebasesend.py

Calibration

In order to get best measurements tilt hydrometer needs to be calibrated before putting it into fermenter.

SG Calibration

Put tilt hydrometer in water and read SG using provided mobile application.

If SG differs from 1.000 then put appropriate value in calibration > sg section in your Firebase DB.

Eg. For 0.996 put 0.004 as offset that would be added to measurement.

Temperature Calibration

After about 10 minutes in water you can calibrate temperature. Use electronic thermometer and similarly put offset value in calibration > temperature.

Storing and reading data

This script stores each measurement on a path in Firebase: measurements/1/1492706249.

In above case 1 is a batch number and 1492706249 is an unix timestamp in GMT.

Every measurement has two values - plato degrees and temperature in celesius:

  "1492706249" : {
    "plato" : "10.48",
    "temp" : "28.89"
  }

IMPORTANT! Remember to update batch number before each fermentation process. Failing to do so will result in data inconsistency in your database.

Acknowledgements

Bluetooth scanning and parsing data from tilt is based on code from: https://github.com/jimmayhugh/TiltRPi

Thanks to https://github.com/mjarco for porting ble scanner to python3

About

Python software that is aimed to run on a Raspberry Pi to read data from Tilt Hydrometer and store it in Firebase Database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published