Project

General

Profile

Logging water/gas pulses

Added by tickett about 7 years ago

What's the best way to do this?

I currently have custom jeenodes attached to my gas meter, cold mains water supply and boiler hot outlet.

The current sketch reports the number of pulses since the last report every 10 seconds.

I have enabled simple graphing on the three devices and it looks pretty good.

Ideally i'd like to actually be able to "reconcile" the pulse count with the meter reading (is there a way to accumulate the pulse count reading somehow?). It'd also be beneficial to be able to query somehow for the highest usage day, month, week, that sort of thing. Although hopefully the RRD graphs will give quite a nice indication of this sort of thing.

Let me know how you are currently recording these details in DomotiGa

Thanks

Lee


Replies (32)

RE: Logging water/gas pulses - Added by Samfox2 almost 5 years ago

I'm using this [[https://lowpowerlab.com/shop/index.php?_route_=EE-SY310_breakout]] photo reflectiv sensor to count light/dark difference of a cycling triangle on my water meter. Pulses are submitted wireless with a TinyTX and received on my raspberry (you can also use a wire if your water meter is not too far away from your domotiga server). A script calculates the flow volume and is submitting the value with a JSON call to a virtual domotiga device. I do the same with electricity and gas usage.

RE: Logging water/gas pulses - Added by sincze almost 5 years ago

Samfox2 wrote:

I'm using this [[https://lowpowerlab.com/shop/index.php?_route_=EE-SY310_breakout]] photo reflectiv sensor to count light/dark difference of a cycling triangle on my water meter. Pulses are submitted wireless with a TinyTX and received on my raspberry (you can also use a wire if your water meter is not too far away from your domotiga server). A script calculates the flow volume and is submitting the value with a JSON call to a virtual domotiga device. I do the same with electricity and gas usage.

MMm that is interesting. (/)
My raspberry is located 2 meters away.
Are you able to share some insight configuration details :)

RE: Logging water/gas pulses - Added by danfos almost 5 years ago

If building something yourself is something for you you could also try http://www.mysensors.org/build/pulse_water.

Building a MySensors serial gateway and the two pulse sensors should not cost you roughly 50 Euro's but building it will take quite some time. The good things is that DomotiGa has MySensors support although it is not fully debugged yet.

@Samfox2: TinyTx looks nice! What are you using on the receiving/DomotiGa side?
Would be nice if the TinyTx could transmit something that RFXCom could receive...

RE: Logging water/gas pulses - Added by danfos almost 5 years ago

@sinze: If your Raspberry is only two meters away, can you use wires?

If so, things should become much easier, use a sensor like the TCRT5000 IR Barrier sensor or the EE-SY310 and connect the output to your Raspberry using http://wiringpi.com/. Then count the pulses using an Interrupt driver event counter

See also WiringPi although I think this has no support for counting pulses.

RE: Logging water/gas pulses - Added by sincze almost 5 years ago

danfos wrote:

@sinze: If your Raspberry is only two meters away, can you use wires?

If so, things should become much easier, use a sensor like the TCRT5000 IR Barrier sensor or the EE-SY310 and connect the output to your Raspberry using http://wiringpi.com/. Then count the pulses using an Interrupt driver event counter

See also WiringPi although I think this has no support for counting pulses.

Wiring is the least of my problems for this specific item :)
Configuring will be the next thing to beat.

RE: Logging water/gas pulses - Added by Samfox2 almost 5 years ago

2m is no problem for a wired connection btw. sensor/rpi. For my wireless setup I'm using this transceiver [[http://shop.openenergymonitor.com/rfm12pi-raspberry-pi-base-station-receiver-board/]]
If your gas meter has a rotating magnetic contact, you could also use a simple reed switch or a hall sensor.

RE: Logging water/gas pulses - Added by sincze almost 5 years ago

Samfox2 wrote:

2m is no problem for a wired connection btw. sensor/rpi. For my wireless setup I'm using this transceiver [[http://shop.openenergymonitor.com/rfm12pi-raspberry-pi-base-station-receiver-board/]]
If your gas meter has a rotating magnetic contact, you could also use a simple reed switch or a hall sensor.

Bit lucky. We received a smartmeter. GAS and Electrics are handled by the USB cable with RJ11 plug. Only thing left is the water meter.

Can I use piece of utp cable for wiring?

RE: Logging water/gas pulses - Added by Samfox2 almost 5 years ago

Utp should work, you need only 3 wires mass, power (3.3v is enough) and a signal line. So you can use 2 wires per line by swirling them together before soldering to improve the line a bit.

RE: Logging water/gas pulses - Added by Samfox2 almost 5 years ago

If many others use that kind of sensors it would be nice to have an integrated pulse counter plugin. It just needs to meassure time between pulses and a configurable "unit" field and it would be usable for all kinds of puls generating devices like gas/water/electicity. I started to write one but estimating the time delta was the point that I couldn't get (gambas plugin coding is really not my thing). So I ended up with python.

RE: Logging water/gas pulses - Added by danfos almost 5 years ago

If many others use that kind of sensors it would be nice to have an integrated pulse counter plugin.

Agreed!

How did you make the python script to count the pulses or ... measure the time between the pulses. Is that done interrupt based or are you polling?

On adding an interrupt driven pulse counter in Gambas/DomotiGa: somebody did already give it a try in the context of WiringPi not sure if he succeeded, but in the thread there is a good idea:

Make an application that:
  • Creates an internal pipe.
  • Returns the file descriptor of the other side of the pipe.
  • Creates an thread.
  • When an interrupt occurs, the thread writes a byte to the pipe.

Gambas/DomotiGa can then connect to the pipe and job done.

Looking around a bit more I see quite some example code doing the interrupt monitoring and creating pipes, can be likely also done from Python :)

RE: Logging water/gas pulses - Added by sincze almost 5 years ago

danfos wrote:

If many others use that kind of sensors it would be nice to have an integrated pulse counter plugin.

Agreed!

How did you make the python script to count the pulses or ... measure the time between the pulses. Is that done interrupt based or are you polling?

On adding an interrupt driven pulse counter in Gambas/DomotiGa: somebody did already give it a try in the context of WiringPi not sure if he succeeded, but in the thread there is a good idea:

Make an application that:
  • Creates an internal pipe.
  • Returns the file descriptor of the other side of the pipe.
  • Creates an thread.
  • When an interrupt occurs, the thread writes a byte to the pipe.

Gambas/DomotiGa can then connect to the pipe and job done.

Looking around a bit more I see quite some example code doing the interrupt monitoring and creating pipes, can be likely also done from Python :)

Looks like I have to buy some hardware soon :) and a soldering iron. (!)

RE: Logging water/gas pulses - Added by danfos almost 5 years ago

Looks like I have to buy some hardware soon :) and a soldering iron.

You do not need a soldering iron to experiment, for Arduino people use often Dupont jumper cables (initially), see for example http://www.mysensors.org/store#cables

If you order things from Ebay from China, keep in mind the shipping can take multiple weeks.

RE: Logging water/gas pulses - Added by Samfox2 almost 5 years ago

I'm using a quite simple (but working) approch. Getting time between ghe actual and last ping with time.clock() and calculate then the usage

RE: Logging water/gas pulses - Added by sincze almost 5 years ago

danfos wrote:

Looks like I have to buy some hardware soon :) and a soldering iron.

You do not need a soldering iron to experiment, for Arduino people use often Dupont jumper cables (initially), see for example http://www.mysensors.org/store#cables

If you order things from Ebay from China, keep in mind the shipping can take multiple weeks.

Ah yes, the experminent. ;)
I Searched the web yesterday for around 2 meter of Dupont cable (no-soldering) :).
What I could find was arount 20 - 30 cm per cable only.
A bit short to reach my watermeter.

RE: Logging water/gas pulses - Added by danfos almost 5 years ago

I would start really simple with the detector and a LED and make sure that the LED pulses in the rhythm of the watermeter.

RE: Logging water/gas pulses - Added by danfos almost 5 years ago

@Samfox2:

I'm using a quite simple (but working) approch. Getting time between the actual and last ping with time.clock() and calculate then the usage

Yes, that is easy to do, but I am wondering how you are monitoring the pulses. Are you waiting for an interrupt or polling?

RE: Logging water/gas pulses - Added by Samfox2 almost 5 years ago

As I mentioned before each sensor is connected to a tinytx. Whenever a pulse is detected, the tiny awakes it's transmitter and sends the ping. A recieving py script listens to /dev/ttyAMA0 and if something is detected it verifies the input and updates domotiga via JSON. The tiny is polling, but waiting for an interrupt is also possible. I'm using 3xAAA batteries and they now last for over 6 months.

RE: Logging water/gas pulses - Added by danfos almost 5 years ago

A recieving py script listens to /dev/ttyAMA0 and if something is detected

Aha, yes, should have concluded that but was mixing up things with WiringPI.

Okay, so that script is more or less waiting for the /dev/ttyAMA0 FIFO, that is exactly the solution that was also proposed to couple WiringPI interrupts to Gambas/DomotiGa.

Thanks!

RE: Logging water/gas pulses - Added by sincze over 4 years ago

danfos wrote:

A recieving py script listens to /dev/ttyAMA0 and if something is detected

Aha, yes, should have concluded that but was mixing up things with WiringPI.

Okay, so that script is more or less waiting for the /dev/ttyAMA0 FIFO, that is exactly the solution that was also proposed to couple WiringPI interrupts to Gambas/DomotiGa.

Thanks!

Hi Danfos, Can I start ordering hardware from E-Bay. :)

RE: Logging water/gas pulses - Added by danfos over 4 years ago

Can I start ordering hardware from E-Bay. :)

Yes, but it will be too late for Sinterklaas, maybe the Kerstman ;)

RE: Logging water/gas pulses - Added by sincze over 4 years ago

danfos wrote:

Can I start ordering hardware from E-Bay. :)

Yes, but it will be too late for Sinterklaas, maybe the Kerstman ;)

Ok, placed the order :)
Hopefully supported in .19 ;-)
[[http://www.ebay.com/itm/330924700585]]

RE: Logging water/gas pulses - Added by sincze over 4 years ago

danfos wrote:

Can I start ordering hardware from E-Bay. :)

Yes, but it will be too late for Sinterklaas, maybe the Kerstman ;)

Hi Danfos.

I received the items. Whats next :)
Christmas came early this year.

Sándor

RE: Logging water/gas pulses - Added by sincze over 4 years ago

danfos wrote:

@sinze: If your Raspberry is only two meters away, can you use wires?

If so, things should become much easier, use a sensor like the TCRT5000 IR Barrier sensor or the EE-SY310 and connect the output to your Raspberry using http://wiringpi.com/. Then count the pulses using an Interrupt driver event counter

See also WiringPi although I think this has no support for counting pulses.

Danfos, do you think I can wire the sensor directly to the raspberry (5v / gnd / gpio) without using a transistor and blow the port :) ?
The next step would be to retrieve some actual data.

RE: Logging water/gas pulses - Added by danfos over 4 years ago

The raspberry Pi GPIO's are 3.3 Volt so better not use 5 Volt but as far as I can see the TCRT5000 module can also be used with a working voltage of 3.3V to 5V, so why not choose 3.3 Volts.

So connect the VCC of the module to 3.3 Volts, GND to ground and D0 to a GPIO of the Rasperry and try if you see a difference in the value you read when there is no obstacle versus when you put a piece of paper at some distance from it.

(1-25/32)