Sonic Dipstick
This is my project for measuring oil levels with raspberry pi
Background
I have 300 gallon oil tank, just like a lot of homes out in the county. It’s down in the basement, and it has one of those pretty standard tank liquid level gauges. This means I have to go down to the basement and check it every now and then which is not optimal.
So I’m working on using my Raspberry Pi and a PING))) Ultrasonic Distance Sensor to take measurements at regular intervals, and record them to a database. I then display the data on a website using ExpressJS also running on my RPI.
This first step is to create a module specifically for taking the measurements.
Deployment Options
Option 1:Resin.io] (Recommended)
Setup
Follow the Getting Started
When you get to the Deploy Code part, swap their simple-server-node repository with this one
git clone git@github.com:mckaycr/sonicdipstick.git
Once the repo is cloned, change directory into the newly created sonicdipstick
directory and add the resin git remote endpoint by running the command git remote add
shown in the top-right corner of your application page:
cd sonicdipstick
git remote add resin <USERNAME>@git.resin.io:<USERNAME>/<APPNAME>.git
From there just continue following the Deploy Code guide again, and your oil sensor should be deployed
Option 2:Install yourself on a raspberry pi
Prerequisites
sudo apt install -y python-dev python-rpi.gpio
Setup
git clone git@github.com:mckaycr/sonicdipstick.git
cd sonicdipstick
npm install
sudo npm test
sudo npm start
Remember that in order to use the GPIO pins you must run your app as sudo.
Usage
In your browser go to:
http://<IPADDRESS>/check
Results
{ date: '08/05/2016',
inches: 130.75472259521484,
time: '01:16:49' }
Home-Assistant Integration
It is super simple to integrate this sensor into Home Assistant.
I’m not really going to go into how to set up home assistant, so follow their Getting Started guide.
Once you are up and running edit your configuration.yaml file by adding the following under sensor:
- platform: rest
name: 'Oil Level'
resource: http://<IPADDRESS>/check
unit_of_measurement: 'inches'
value_template: '{{ value_json.data | round(0)}}'
scan_interval: 3600
Then restart Home Assistant, and you should start seeing your oil measurements.