Page 1 of 1

piface: forwarding sensor data from input --> output

Posted: Fri Sep 25, 2015 8:41 am
by yos2000
Hello,

I've been measuring my water-usage for a year now with a line-sensor and that worked perfectly.
Since a few days my watercompany installed a sensor on the meter, and sends the data to a I-Care gateway (from http://www.energq.com)
Since there is no local webserver on the gateway I lost my own signal to domoticz.

Now I want to connect the sensor to my piface and forward the input to an output, so I can connect the output to the I-Care gateway. (So we're all happy)

Can anyone tell me how to configure this in the piface? (The Python part...)

Re: piface: forwarding sensor data from input --> output

Posted: Sat Sep 26, 2015 4:28 am
by ghp
Hello,

do you have an idea about how the specific sensor works used on your meter ? In some threads here people reported reed contacts or hall sensors with open collector outputs.

Best you measure voltage levels and then design an adapter circuit (the 'magical measurement adapter') which 'measures' the sensor signals and converts them to a voltage level/protocol for your home automation.

No need to break up the path from the meter to the gateway device then. Best case there should be no influence from the adapter backward to the meter when adapter is powered/unpowered and it should provide isolation between the circuits.

If this magical adapter is producing 3.3V-logic signal levels, then you can feed this into a piface. Or GPIO directly.

Hope this helps
Gerhard

Edit: when there is a hall sensor used in the sensor, why not place a second hall sensor to the meter and take this signal as an input for your automation system ?

Re: piface: forwarding sensor data from input --> output

Posted: Sat Sep 26, 2015 5:14 am
by yos2000
Thanx for the answer.
I don't have a problem breaking up the path. It's pretty easy to restore...
Is it possible to just read the input on the piface en tell the output to send the same signal?

Re: piface: forwarding sensor data from input --> output

Posted: Sat Sep 26, 2015 5:22 am
by ghp
Basically yes. But the problem is to adapt (sensor to piface) and (piface to gateway). The voltage levels most probably will not match.
And you need a small program, which copies the signals .
And when pi is down, so signals are going to gateway.

So simpler to leave (sensor to gateway) as it is and just convert signal to piface. And look for some circuit isolation too.

Can you provide some details on the type of sensor used ? The links you provided are not going too much into details and my language skills are limited.

Re: piface: forwarding sensor data from input --> output

Posted: Sat Sep 26, 2015 9:15 am
by yos2000
I can't give more details about gateway and sensor as there are no documented specs available.
I think they are using some kind of magnetic sensor which detects the little iron plate turning on the meter.

(When I used my own sensor I used a IR photoreflective sensor, that worked a lot better :D )

As far as I can see the sensor swtiches from 0V (low) to 3.3V (high).

You're suggesting to just put an extra wire on the sensor and connect that to my PiFace-input?

Re: piface: forwarding sensor data from input --> output

Posted: Sat Sep 26, 2015 10:15 am
by ghp
Hello,
either you use (A1)(A2) existing sensor, or just place (B) another sensor 'in parallel'.
Just to give a sketch on how this could look like:

(A1) if on sensor there are 3.3V, take GND and SIGNAL and connect to PI. Add a series resistor to limit current ( 10k or so ) and voltage limiter: add two schottky diodes reverse to 3,3V of PI and GND. Do not use internal pullup resistor when having large series resistor. although possible, I would not recommend this solution.

(A2) The hall sensor has GND, SIGNAL and V+. If V+ <15V, power a CMOS CD4011 or alike from this V+ and drive a (low power) optocoupler LED with this. Input is SIGNAL, provide large resistor to V+ (100k). On transistor side of coupler connect PI (use pullup). Circuits are isolated. And Pi is not broken when something on sensor side goes wrong. Takes few mA from the gateway power supply.

(B) just add your own hall sensor to the meter in parallel to the other one. If mechanical situation allows this. Provides isolation, and nobody can claim you messsed up something. This would be the most elegant solution.

Re: piface: forwarding sensor data from input --> output

Posted: Sun Sep 27, 2015 10:48 am
by yos2000
And you need a small program, which copies the signals .
Still this is the part I'm interrested in...
Who can help me write such a program in Python, since my program skills are really basic...

Re: piface: forwarding sensor data from input --> output

Posted: Sun Sep 27, 2015 5:58 pm
by ghp
Hello, from http://www.piface.org.uk/guides/Install ... al_Python/

Code: Select all

import time
import pifacedigitalio as p
p.init()
while True:
    state = digital_read(pin_number)
    digital_write(pin_number, state)
    time.sleep(0.01)
Untested. Place pin numbers as needed. If you go with GPIO , solutions differ.

Regards,
Gerhard

Re: piface: forwarding sensor data from input --> output

Posted: Tue Sep 29, 2015 7:38 am
by yos2000
Ok tried that script. (with a little changes) but the Gateway didn't recieve the data.
I heard the relais click, but voltage levels are probably not the same.
Thanks for the help. I'll try a few other things!