Introduction: Wi-Fi Twitter Water Level Sensor

Picture of Wi-Fi Twitter Water Level Sensor

Introduction

Got indoor plumbing? Yep. Got city water? Nope. Then you're in the right place. If you have a well, then you probably have a water tank. This project is a way to measure how much water is left in your tank. You could use this project for other applications too, such as tracking the level of a lake, reservoir, cattle tank, moat, etc.

What is it?

The key of this project is a weather proof ultrasonic distance sensor (similar to the backup sensors on a car) connected to a Spark Core Wi-Fi module. The Spark Core module reads the sensor and posts the measurement to Twitter. You can view the water level using the Twitter app already on your phone... and you can track water usage history by looking at old tweets.

Step 1: Step 1: You Will Need...

Picture of Step 1: You Will Need...

Ingredients

Spark.io Core

Ultrasonic Range Finder - XL-MaxSonar-WR1

Some wire

6" of Schedule 20 1" PVC pipe

3/4" threaded reducing female adapter (such as a Dura 435-131, which is usually carried by your favorite big box building supply store)

1" PVC end cap

Tools

soldering iron and lead-free(!) solder

Pro Tips

  • Spark.io Core works great for this application, but a Photon has a connector for an external antenna which will probably improve the Wi-Fi distance.
  • PVC pipe comes in several thicknesses. Use Schedule 20 (the thinnest walled pipe) for this application so that we don't affect the antenna too much. It's cheap, but you probably have to buy a really long pipe, so plan to either fold it by hand, or bring a saw with you to the store so you can fit it into your car.
  • Sometimes the color used to die plastics affects the antenna, so choose white PVC instead of gray or black if you have a choice.
  • Most of the MaxBotix ultrasonic distance sensors would technically work, but the expensive water proof ones will last better inside a water tank. We use the Analog Output of the sensor because the serial port of this specific sensor is incompatible with most Arduino style boards, including the Photon Core.
  • It's really tempting to use lead solder, but DON'T DO IT! After all, you're putting this in your water supply.
  • The best way to get the right PVC pipe fittings is to carry the sensor into the building supply store and buy whatever fits.

Step 2: Step 2: Connect the Spark.io Core to Your Wi-Fi Network

The Spark.io Core is the brains of the system. Plug it into a USB power supply and follow the directions at http://docs.spark.io/ to get it onto the Wi-Fi network.

You will need to know your Wi-Fi network SSID and password. The app will attach the Spark.io Core to you network, and also help you set up a Spark.io account. Finally, this will connect your specific Spark.io Core to your new Spark.io account so that you can deploy code to it.

Pro Tip

There are many, many ways to connect the Spark.io Core to your Wi-Fi network. Use whatever works as long as in the end:

  • it's connected to your Wi-Fi network
  • it's connected to your account

(I did it the hard way using a serial port)

Step 3: Step 3: Create a New Twitter Account for Your Sensor

Picture of Step 3: Create a New Twitter Account for Your Sensor

Create a twitter account for your sensor at https://twitter.com/signup. Don't be too picky about the username. Unless you want the whole world to watch your water level, it's probably best to use one of the randomly generated suggestions. It's best to create a new account for your sensors instead of reusing your existing account, so that your loyal twitter followers don't feel like they're getting spammed with M2M data.

Step 4: Step 4: Get a Security Credentials for the Twitter Account

Picture of Step 4: Get a Security Credentials for the Twitter Account

Log on to your new Twitter account, then from the same web browser go to http://arduino-tweet.appspot.com/oauth/twitter/login , and click Authorize app.

SAVE THE TOKEN! You'll need to paste it into the code to make it post to YOUR Twitter account instead of My Twitter account.

We are using the incredibly useful site http://arduino-tweet.appspot.com/ to interface between the Arduino/Core friendly code and the enterprise class Twitter APIs. Because we don't use https, the data is sent unencrypted to arduino-tweet.appspot.com. This is OK, since we're about to post it to Twitter on an account that only exists to post this data, but you probably don't want to use this technique if you're monitoring coolant level in a nuclear reactor, launch codes, Area 51 secrets, etc.

Step 5: Step 5: Build the Circuit

Picture of Step 5: Build the Circuit

Solder wires to connect these 4 pairs of pins:

Sensor pin AN --> Core pin A7

Sensor pin 4 --> Core pin D2

Sensor pin V+ --> Core pin 3V3*

Sensor pin GND--> Core pin GND

Pro Tips

  • Run the wires through the PVC pipe adapter before soldering them. Neither the Core, nor the sensor will fit through the inside of the adapter. Fortunately, you can attach the PVC pipe later.
  • Either use colored wires, or mark each wire before soldering it so you know which wire goes to which pin on the sensor.

Way to go! You've finished all the electrical parts of the sensor!

Step 6: Step 6: Load the Software

Picture of Step 6: Load the Software

Spark.io has a web based programming tool for the Core at https://www.spark.io/build

Go there and paste the code in the attached file tankmeter.txt into your first program.

Replace the TOKEN "2958....MeZz" with your own token from the previous step.

Click the lightening bolt icon to deploy your code.

Step 7: Step 7: Read Twitter Posts From Your Water Tank Sensor

Picture of Step 7: Read Twitter Posts From Your Water Tank Sensor

Now sit back and relax. All your water tank level questions can now be answered on Twitter.

https://twitter.com/your_sensor_name_here

Comments

Farkleman (author)2017-11-16

Nice project! Stumbled upon it once and had to search pretty hard to find it again. Glad I did. I am going to make a variation of it and will post an instructable on my version. A couple of questions though... Why 6" of pipe for a 2" module? How did you mount the sensor on/in the tank? Did you look at self contained power options?

Notes for readers: Spark.io is now Particle.io and the model of MaxSonar Sensor sold by Adafruit appears to be better suited to this purpose (and currently slightly less expensive.)

ToddT1 (author)2016-05-24

Tim, nice project! Have you mounted this to a water tank? I have a 1500 gal black poly tank in a pump house that I would like to monitor. Would I just drill a hole and mount the sensor somewhere in the top of the tank pointing down at the water? This would send some type of distance reading to the twitter account? Long distance would equal lower tank level? Thanks!!

AaronO21 (author)2016-05-07

Can you post a link to your twitter, or a screenshot of a tweet? I'm really curious as to how the output looks. Thanks in advance.

seamster (author)2015-01-07

This is an excellent idea. Very nice work!

About This Instructable

8,624views

25favorites

License:

More by tim.ousley:Wi-Fi Twitter Water Level Sensor
Add instructable to: