-
• #2
A magnetometer senses a magnetic field, so in order to sense water you'd have to maybe have something like a float with a magnet on it.
But yes you can do that and in fact I did do that as an example in a talk I did once.
Another option is if you have a float attached to a lever, you can put the Puck on that lever and use the accelerometer to measure the angle of the lever.
-
• #3
Or are you talking about connecting the Puck to the front of a household water meter and sensing where the magnet is on that?
If so, yes, you can do that. I did try with mine and it seemed doable, but then soon after the water company replaced it with a digital one!
-
• #4
Yes, was thinking about sitting it on top of a meter. Currently using a Cyble pulse sensor like this one
https://strongcast.com.au/product/water-meter/cyble-sensor-pulse-output/
But was thinking that puck would be a nice thing to use for a few days of data when weather permits -
• #5
Yes, it should work fine - at least on mine the dial of the meter with a magnet on never really moved that fast, so you could get away with keeping the magnetometer running at it's default 0.63 sec period, and with that it's ~8uA so you'd hope the Puck would be able to run for 6 months reasonably easily, possibly more if you're careful with the code.
-
• #6
Thanks! Would give it a go. You would not have any old code samples by chance? =)
-
• #7
Something like this should help:
var Vec3 = require("Vec3"); var magMin = new Vec3(); var magMax = new Vec3(); Puck.magOn(); Puck.on('mag', function(xyz) { //console.log(xyz); // {x:..., y:..., z:...} var v = new Vec3(xyz); magMin = magMin.min(v); magMax = magMax.max(v); var diff = v.sub(magMax.add(magMin).mul(0.5)); var ang = Math.atan2(diff.y, diff.x)*180/Math.PI; console.log(diff, ang); });
So that'll output the x/y/z and also an angle (assuming you had the Puck mounted flat against the meter with the magnetometer where the middle of the meter hand is). It'll only do it reliably once the hand has gone around one whole rotation (so it can set up the min/max values).
Then each time, I guess you just want to check the angle against what it was last time, and if it's moved clockwise then you add that onto what you have for the amount of water that was consumed.
-
• #8
Much appreciated!
Hello
Anyone tried to use puck.js as a water meter, since it had a magnetometer?