Dejan Levec

Water Usage Meter

I needed a way to measure water used outside the house. There are some commercial products, like Gardena Smart Water Flow Meter, but they are not cheap and can’t draw nice looking graphs.
This seemed like a good weekend project and I can finally use XRF wireless modules, that I bought a few weeks ago. XRF wireless modules are Xbee-like radios with a lot of features:

  • they work out of the box,
  • have Xbee-like pinout,
  • support 128-bit AES encryption
They cost 15€ each, but because they need 3.3V supply voltage and have 2mm pitch layout, I also bought some active breakout boards. I have been using it for only one day and I already like them. Sadly, there isn’t much documentation about them on the Internet, as there is for Xbee modules.
Anyway, they have a really easy configuration mode. To enter it you need to send +++ and wait 1 second before and after you send it. I use the following configuration:

ATEA password
ATID 0000

which enables AES encryption, sets password to ‘password’ and specify network ID as 0000. New lines are represented as \r char, and commands return OK if it’s successful.

I decided to use the following configuration:

Flow meter on regular intervals send data about water usage to Netduino Plus gateway. Netduino Plus listens to XRF network and sends every received message to webapp hosted by Google App Engine. I plan to update gateway to support two-way communication, however, firstly I need to make web GUI to display flow meter’s data nicely, since numbers without graphs are somewhat boring.

Flow meter

Flow meter device consists of Seeedstudio’s Water Flow sensor, XRF module, Atmega8 microcontroller, and it’s currently constructed on breadboard. I will move it to PCB, when I find enough time (next weekend sound good). Water flow sensor contains hall-effect sensor and sends pulse on every rotation of rotor. After some testing I came up with the following formula:

water flow [dcl] = pulses / 3.2 per measured period

Example: If it sends 3.2 pulses in one seconds, it means that  water flow is 1 dcl per second.
I decided to sample water flow for ten seconds period, and send sum of those values to web app every five minutes.

Netduino gateway

Netduino Plus listens to XRF wireless data and sends every received command to web app with HTTP GET request.
Commands consist of following data: start character, two digit receiver id, two digit sender id, data and end character.
Example command:

!0102hello world$

which sends hello world string from device #02 to device with id #01. Web app saves these information including current timestamp to the database.

Google App Engine
It’s first time I actually tried GAE and I kinda like it in the sense of building application. It multiple languages but I decided to use Python. Documentation and examples are really good and Python web community is quite big so it’s not hard to find different libraries. Databases are really cool, because you don’t need to specify columns in advanced, so it’s like MongoDB, which I really like. Sadly, web frameworks like Django mostly expect relational database.
Anyway, the only thing I don’t like about GAE for now are their free quotas. Yesterday, when I was testing I sometimes sent up to 10 updates per minute and I used 10% of database quota in about 1 hour. I’m a bit afraid that I might hit those limits quickly if I add additional processing to web app and additional modules to my system.

Leave a Reply

Your email address will not be published. Required fields are marked *