Simple Smart Faucet using AT&T's M2X (Python + Raspberry Pi)
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Sample Smart Faucet using AT&T's M2X and Raspberry Pi

This Python app for your Raspberry Pi records how much water and what temperature water is being used at a faucet connected to your Pi using a flowmeter and a temperature sensor. It then will send that information to AT&T's M2X service where it is stored for future retrieval and analysis.

If you want to display the data from your faucet, here’s a quick app that you can deploy to Heroku:

What you need


  • Python running on your Raspberry Pi (Tutorial)
  • m2x-python - v3.0.4
  • RPi.GPIO - If you are running Raspbian this should already be included with its Python installation


  1. Clone this repository
$ git clone
$ cd faucet
  1. Create a new M2X device.
  2. Copy the Device ID from the device page.
  3. From your M2X account page get your Master API Key.
  4. Create two data streams in that device. One named 'water_use' and the other named 'temperature'.
  5. In replace MASTER_API_KEY and DEVICE_ID:
client = M2XClient(MASTER_API_KEY)
device = client.devices.get(DEVICE_ID)
client = M2XClient('your_key_here')
device = client.devices.get('device_id_here')
  1. WARNING: Wiring this incorrectly could fry your Pi so proceed with caution.

    Use the following diagram to connect the sensors to your pi: Wiring diagram

    Here is the GPIO Diagram from the various Pi Models:

  2. Place the faucet directory on your Pi. Now simply run the following:

$ sudo ./
  1. Check out the data streams on M2X and you should see them update when you use the faucet!


This sample application is released under the MIT license. See LICENSE for the terms.