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: https://github.com/attm2x/m2x-sample-cleverfaucet-web
What you need
- Familiarity with the AT&T M2X API
- Raspberry Pi running RaspBian
- A free AT&T M2X Account.
- Suggested Sensors:
- 4.7k Ohm resistor, jumper wires, and a breadboard
- 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
- Clone this repository
$ git clone https://github.com/attm2x/m2x-sample-cleverfaucet $ cd faucet
- Create a new M2X device.
- Copy the Device ID from the device page.
- From your M2X account page get your Master API Key.
- Create two data streams in that device. One named 'water_use' and the other named 'temperature'.
- In main.py 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')
WARNING: Wiring this incorrectly could fry your Pi so proceed with caution.
Place the faucet directory on your Pi. Now simply run the following:
$ sudo ./start.sh
- 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.