Kevin, Thanks for the video. I have been working on a similar measurement project only using a QMC5883 magnetometer. Yes, filtering is the biggest challenge and I wanted to share the simple method I built for you and your users. Interesting to see that your sensor output was sinusoidal as I would have thought it to be a square wave like your process output. My sensor output is entirely sinusoidal and noisy. As shown in the code below, my approach was to test for an upbeat followed by a downbeat in the sine curve given by the rotating magnet in the meter. (In calculus terms, I am testing for a negative-to-positive change in the first derivative.) These upbeat/downbeats are compared to a threshold that the user needs to set based on testing. I only take action after the upbeat with the routine called EventAction(). In that routine the elapsed time can be captured and recorded for computing flow in needed. (I’m using an SD card and my MCU is a Atmega386-based Nano). I discovered that it was important to test for small, but dithering sensor changes. You don’t know if the water meter is going to stop on a pole, or between poles. When the meter is stopped, then I go through a process of quieting the upbeat/downbeat test variables, maxDelta and minDelta, by resetting them to zero. I found this to help because sometimes the noise was big enough to trigger a false cycle. The code below is a small extract from my program loop but captures the essence of my approach. To first explain the variables: x, y, and z are the magnetometer sensor readings. I choose to use x. maxDelta is collecting upward curve movement minDelta is collecting downwared curve movement Delta_Threshold is set by experimentation with curve characteristics flag_DownHappened & flagUpHappened are testing for completion of a curve period, (or pulse)
void loop() { int x,y,z; qmc.read(&x,&y,&z); if ((x - x_last) >= 0) {maxDelta = (maxDelta + (x - x_last)); minDelta = 0;} if ((x - x_last) < 0) {minDelta = (minDelta + (x - x_last)); maxDelta = 0;} if((maxDelta > (Delta_Threshold)) && (flag_DownHappened == true)) // up beat - Pulse occured { flag_DownHappened = false; //reset for one-shot flag_UpHappened = true; //ready for down beat EventAction(); //Take some action on the completed event maxDelta = 0; //reset for next cycle } else if((minDelta < (-1*Delta_Threshold)) && (flag_UpHappened == true)) // down beat { flag_UpHappened = false; //reset for one-shot flag_DownHappened = true; //ready for up beat minDelta = 0; //reset for next cycle } x_last = x; delay(5); } }
I'm guessing that some of that signal noise from that analog Hall Effect sensor could be from EM interference. Maybe try using shielded cabling from the sensor to the ESP32? Anyway, cool project. Hey, please reveal how this solved your water bill mystery in the next video.
I used to work in metering. We'd get a lot of complaints of "the metering is running fast" which is literally impossible. Meters run slower over time, if anything. They don't look at their toilet that never stops running, needs a $15 part available anywhere, and is pretty literally flushing hundreds of dollars down the drain every month.
did you use the same wiring diagram as the instructable? I noticed you use a different sensor and instead of the 5v you're using the 3.3v, I am currently working on a project with meter monitoring and I am a little out of my element with the electrical side of things. Thanks in advanced.
I have successfully used a HMC5983 Triple Axis Compass Magnetometer (as it is cheap and readily available) to detect the water meter. The filtering is the key here as @Kevin Darrah points out. I do come across two issue, 1, in long term when the surrounding of the water meter changed (e.g. you put some stuff close to the meter) that may affect the baseline of the magnetic flux (the whole wave will go higher or lower). So the filtering will have to deal with that (e.g. recenter). 2, there are back and forth movement in the water meter when there is no water use (I assume external change of water pressure caused that) and sometime that movement triggers many false pulses. I imagine the only way to overcome that is to employ a second sensor to create a quadrature signal (at 90 degree of the first sensor). Note that the back an forth can be more than half a turn in my experience.
@Sai To Wang. Excellent. I am now configuring a QMC5883 magnetometer to do the same thing. The QMC is on a board marked HW-127. It appears that the Z-axis is most sensitive to the flux change as the magnet spins. And that would allow the HMC/QMC boards to be simply mounted face-to-meter so the Z-axis is perpendicular to the mount position on the meter. I noticed that in this orientation the spin direction can be detected by a leading/lagging X-axis or Y-axis curve, or more obviously, the reversal of the curve on the Z-axis (down then up vs. up then down). The use of X or Y-axis depends on the mounting orientation on the meter. That may solve detecting the backwards flow problem. I just tested this on the bench by passing a magnet back and forth over the sensor and indeed the Z-axis curve flip flops depending on which direction I pass the magnet.
hi good job....but i think you should use deep sleep mode for esp32 ...because if you donot flush the waster the esp should go to sleep to save power consumption...
Good work, so this is bascialy a pure software solution. I ordered a few DRV5056A1 as well, good sensor. I think your water meter is quite special, it produces a strong magnet field than other meters. Have you ever measure the voltage change from the sensor output pin with a multimeter? My water meter, and the water meter in the Instructable project, only produces super weak field, so my DRV5056A1 output pin voltage only varies from lowest 0.600V to highest 0.605V, I don't think the ESP32 ADC 12bit can deal with this kind of tiny voltage change, not reliably anyway . therefore, the instructable project did use an OpAmp for a good reason, his voltage change is about the same, only 5mv change. When you have time, could you please help to measure the voltage change of the sensor pin ? much appreciate it!
Hey Kevin , i love the way you explain ,just one thing : can you paste the link to the video that explain how to hide passwords that are coded in String format in our sketch ,because flash encryption is very difficult and no video that explain exactely how to proced , thank you again and waiting for the link soon.
Hi, I'm trying to set this up for my water meter. I came across many version of DRV5056 with different sensing range for the magnet inside the water meter. Which one did you use in the video? Thanks
Sir , I am trying to put it to sleep triggered by a water detector sensor to wake up the esp32 from deep sleep. Since in such a case the loop part of the code never gets executed. Would moving the code in the loop section to setup before the sleep is triggered work ? I am new to this so would appreciate your guidance in this regard.
how about using a pipe with a turbine on one side connected to a magnet and a sensor at the top. it could clean the installation process. In my country, we don't have water meters, Also, we have to buy it from private companies there's no water line in my area, I and landlord are sharing the tank so there's always a kerfuffle about who is using most water right now we have a system of per head usage. but watching this I might as well try this.
Hi Kevin , This is interesting. I have been doing this atmega 328 barebones and deepsleep. Basically count interrupts and periodically send the data through lorawan. I am interested however on how to do deep sleep and still get interrupts to count the pulses and periodically send the data over the internet using esp 32 which I realize I have some gaps since I don't want it always waking up when an interrupts comes in but just increase the counter and the do timed wakeups for transmission, kindly help in guiding how I can make it work with esp32.
rofl... Do they actually come check the meter in person where you live? If so they might not be overjoyed and think you are trying to influence the meters operation.
Hey sorry for the re-upload... had an editing error in that last one I had to fix
Hi Kevin, thank you for showing us this. Where is the code for it? Thanks again, Joe
i just wanted to say this is brilliant and i take comfort knowing I wasn't the only one with an idea to do something exactly like this!!
Love that "remove after installation" sticker
Kudos for figuring out the way to instrument that meter. Outstanding.
Kevin,
Thanks for the video. I have been working on a similar measurement project only using a QMC5883 magnetometer. Yes, filtering is the biggest challenge and I wanted to share the simple method I built for you and your users. Interesting to see that your sensor output was sinusoidal as I would have thought it to be a square wave like your process output. My sensor output is entirely sinusoidal and noisy.
As shown in the code below, my approach was to test for an upbeat followed by a downbeat in the sine curve given by the rotating magnet in the meter. (In calculus terms, I am testing for a negative-to-positive change in the first derivative.) These upbeat/downbeats are compared to a threshold that the user needs to set based on testing. I only take action after the upbeat with the routine called EventAction(). In that routine the elapsed time can be captured and recorded for computing flow in needed. (I’m using an SD card and my MCU is a Atmega386-based Nano).
I discovered that it was important to test for small, but dithering sensor changes. You don’t know if the water meter is going to stop on a pole, or between poles. When the meter is stopped, then I go through a process of quieting the upbeat/downbeat test variables, maxDelta and minDelta, by resetting them to zero. I found this to help because sometimes the noise was big enough to trigger a false cycle.
The code below is a small extract from my program loop but captures the essence of my approach. To first explain the variables:
x, y, and z are the magnetometer sensor readings. I choose to use x.
maxDelta is collecting upward curve movement
minDelta is collecting downwared curve movement
Delta_Threshold is set by experimentation with curve characteristics
flag_DownHappened & flagUpHappened are testing for completion of a curve period, (or pulse)
void loop()
{
int x,y,z;
qmc.read(&x,&y,&z);
if ((x - x_last) >= 0) {maxDelta = (maxDelta + (x - x_last)); minDelta = 0;}
if ((x - x_last) < 0) {minDelta = (minDelta + (x - x_last)); maxDelta = 0;}
if((maxDelta > (Delta_Threshold)) && (flag_DownHappened == true)) // up beat - Pulse occured
{
flag_DownHappened = false; //reset for one-shot
flag_UpHappened = true; //ready for down beat
EventAction(); //Take some action on the completed event
maxDelta = 0; //reset for next cycle
}
else if((minDelta < (-1*Delta_Threshold)) && (flag_UpHappened == true)) // down beat
{
flag_UpHappened = false; //reset for one-shot
flag_DownHappened = true; //ready for up beat
minDelta = 0; //reset for next cycle
}
x_last = x;
delay(5);
}
}
im trying to use the qmc5883l i am having alot of issues. are you able to help me?
I'm guessing that some of that signal noise from that analog Hall Effect sensor could be from EM interference. Maybe try using shielded cabling from the sensor to the ESP32?
Anyway, cool project.
Hey, please reveal how this solved your water bill mystery in the next video.
Love these small start-to-finish projects!
I used to work in metering. We'd get a lot of complaints of "the metering is running fast" which is literally impossible. Meters run slower over time, if anything. They don't look at their toilet that never stops running, needs a $15 part available anywhere, and is pretty literally flushing hundreds of dollars down the drain every month.
time to make videos for hassio 😃 love your videos!
Wow! Excellent Job and explanation! Many Thanks!
I can see that you have processing. nice ;)
Have you thought. about using an optical sensor on the small x.001 cadran ?
might also be possible to use a photo sensor to detect the black stripe on the small red dial
My water meters have a metallic, very reflective cogwheel in them that would allow to optically get those impulses.
You are a life saver. Thanks for making this video!
Excellent 👌
did you use the same wiring diagram as the instructable? I noticed you use a different sensor and instead of the 5v you're using the 3.3v, I am currently working on a project with meter monitoring and I am a little out of my element with the electrical side of things. Thanks in advanced.
Great project as always :-)
Thanks for sharing
I have successfully used a HMC5983 Triple Axis Compass Magnetometer (as it is cheap and readily available) to detect the water meter. The filtering is the key here as @Kevin Darrah points out. I do come across two issue, 1, in long term when the surrounding of the water meter changed (e.g. you put some stuff close to the meter) that may affect the baseline of the magnetic flux (the whole wave will go higher or lower). So the filtering will have to deal with that (e.g. recenter). 2, there are back and forth movement in the water meter when there is no water use (I assume external change of water pressure caused that) and sometime that movement triggers many false pulses. I imagine the only way to overcome that is to employ a second sensor to create a quadrature signal (at 90 degree of the first sensor). Note that the back an forth can be more than half a turn in my experience.
@Sai To Wang. Excellent. I am now configuring a QMC5883 magnetometer to do the same thing. The QMC is on a board marked HW-127. It appears that the Z-axis is most sensitive to the flux change as the magnet spins. And that would allow the HMC/QMC boards to be simply mounted face-to-meter so the Z-axis is perpendicular to the mount position on the meter. I noticed that in this orientation the spin direction can be detected by a leading/lagging X-axis or Y-axis curve, or more obviously, the reversal of the curve on the Z-axis (down then up vs. up then down). The use of X or Y-axis depends on the mounting orientation on the meter. That may solve detecting the backwards flow problem. I just tested this on the bench by passing a magnet back and forth over the sensor and indeed the Z-axis curve flip flops depending on which direction I pass the magnet.
@@craiglarson2346 did you ever have any luck with this? i am having some issues using the qmc5883l
anyway you could help?
i am having issues with the qmc5883l are you able to help me?
Perhaps an idea to add a time stamp in the code together with the data from the sensor. That way you could easily graph monthly usages and so
hi good job....but i think you should use deep sleep mode for esp32 ...because if you donot flush the waster the esp should go to sleep to save power consumption...
Good work, so this is bascialy a pure software solution. I ordered a few DRV5056A1 as well, good sensor. I think your water meter is quite special, it produces a strong magnet field than other meters. Have you ever measure the voltage change from the sensor output pin with a multimeter? My water meter, and the water meter in the Instructable project, only produces super weak field, so my DRV5056A1 output pin voltage only varies from lowest 0.600V to highest 0.605V, I don't think the ESP32 ADC 12bit can deal with this kind of tiny voltage change, not reliably anyway . therefore, the instructable project did use an OpAmp for a good reason, his voltage change is about the same, only 5mv change. When you have time, could you please help to measure the voltage change of the sensor pin ? much appreciate it!
There is a hall sensor in ESP32, can we use it for this situation?
Is it possible to just install a flow meter which the esp can read? in the pipe after the actual meter
Any idea on how the ECR thingy registers how much water is used?
How does it work when the GPIO input of the esp only has 3.3V max. It will. That sensor operates at 5V. Will it damage the esp quickly?
Hey Kevin , i love the way you explain ,just one thing : can you paste the link to the video that explain how to hide passwords that are coded in String format in our sketch ,because flash encryption is very difficult and no video that explain exactely how to proced , thank you again and waiting for the link soon.
this is really cool!
did you try to shield your hall sensor from outside... magnetic material like a tin can or more effective with permalloy foil ?
shield from outside the sensor...
Good work
Hi, I'm trying to set this up for my water meter. I came across many version of DRV5056 with different sensing range for the magnet inside the water meter. Which one did you use in the video? Thanks
Sir ,
I am trying to put it to sleep triggered by a water detector sensor to wake up the esp32 from deep sleep. Since in such a case the loop part of the code never gets executed.
Would moving the code in the loop section to setup before the sleep is triggered work ? I am new to this so would appreciate your guidance in this regard.
Hi. this is a great project. I am getting a variable or field 'handleMessage' is void error. Any ideas.
Very nice.
how about using a pipe with a turbine on one side connected to a magnet and a sensor at the top. it could clean the installation process. In my country, we don't have water meters,
Also, we have to buy it from private companies there's no water line in my area, I and landlord are sharing the tank so there's always a kerfuffle about who is using most water right now we have a system of per head usage.
but watching this I might as well try this.
Hi Kevin , This is interesting. I have been doing this atmega 328 barebones and deepsleep. Basically count interrupts and periodically send the data through lorawan. I am interested however on how to do deep sleep and still get interrupts to count the pulses and periodically send the data over the internet using esp 32 which I realize I have some gaps since I don't want it always waking up when an interrupts comes in but just increase the counter and the do timed wakeups for transmission, kindly help in guiding how I can make it work with esp32.
Hi you can use STM32L series mcu. and count with DMA. So you can periodically send data wake up from RTC
rofl... Do they actually come check the meter in person where you live? If so they might not be overjoyed and think you are trying to influence the meters operation.
Nice project. Is the source code available somewhere?
I'm sure that most wives or teenage daughters would really be interested in this.
Great project as usually. Are you planning to share the code?
yep, check description
@@ronaldomartire7934 oh wow, my bad... thought I had it up there. It's there now
@@Kevindarrah Thanks a lot!!! Again, you've done a great job and have inspired many people!