Giter Site home page Giter Site logo

kkocel / tilt-raspi-firebase Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 2.0 675 KB

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

License: Apache License 2.0

Python 69.71% HTML 30.29%
raspberry-pi-3 tilt firebase-database firebase-db brewing-beer hydrometer fermentation beer

tilt-raspi-firebase's Introduction

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

tilt-raspi-firebase's People

Contributors

kkocel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.