Sonic Dip Stick

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.

1 Like

Cool!
Don’t suppose you’d mind pointing the PING))) at a half-full garbage can would you? One of my idle thought projects is to see if one could tell when a garbage can needs emptying.

I could sure try, however I have never seen my trash half full, its either full or overflowing.

1 Like

Very cool! I’m guessing that this is the PING))) mentioned. Keep thinking of cases around the house to reuse this - and the Home Assistant integration is a really nice touch!

Yes, the PING))) Ultrasonic Distance Sensor, I point it down at the oil and it measures how far down the oil level is. Based on that measurement and the size of the tank, I get a rough estimate as to how much oil is left.

The Home Assistant saved me from having to develop my own UI, and datastore solution. I know these are all easy tasks, but they just weren’t what I wanted to focus my time on. Home Assistant does both including charting measurements over time.

Here is a picture of my current interface, should you not integrate with Home Assistant