This reminds me of my favorite remote sensing story: it was determined that the cheapest, quickest, and most accurate solution to remote greenhouse temperature sensing was a large dial thermometer and a pair of binoculars.
Nice! Now you can install an esp32-cam with a telescope! No cables, no long range wifi, no LoRa, just a telescope, one cheap esp32-cam+AI, and a local wifi.
I work as a data scientist and one of the most important questions you always have to ask before using AI is: Can this be done without AI? If the answer is yes it is probably more reliable to do in a traditional way.
@@AndreasDelleske generally speaking, using AI to bypass HOA restrictions could be popular in a lot of tech savvy pockets that have sprung up in old money communities
Hi Andreas, great video! This is the developer of the AI-on-the-edge. The reason, why your analog counters are not detected correctly is indeed the inverted color (white on black). In contrast do the digits, this is not part of the training data yet. Have a look on the latest updates, now we can even detect the NaN values with then newest neural networks. Best regards, jomjol
Hello, I also have the AI solution for Gas and Watermeter and it works fine. But it took me some hours to do the correct setup. It it important, that the image is horizontal aligned and the scan area for the digital digits are large enough (larger than you wouId expect) , in 3:21 you see the 039 even includes the frames around the digits. This reduces the NaN results a lot and even recognized switching numbers. Also you must setup the initial value and a threshold to only overtake reasonable values (Values to low or big are thereby ignored). I mounted an angle iron on the wall 10 cm above the meter and taped the ESP32 below it. By twisting, you can move the glare point of the internal led to an area, which is not scanned, With this easy solution your energy provider can still read the values manually, if needed. Hope that help's to give it another try.
I agree with the above. I almost gave up on it as wel, but after adjusting and configuring for days it's been stable for weeks now. The documentation is very limited, but I can already see what you did wrong there (due to all my fails lol): 1. your camera is too far away or lens was not adjusted to have the best focus for the distance, 2. your rotation is slightly off (even 0.5 degrees makes a difference), 3. your reflection of the LED will hinder you a lot (experiment with different positions, angles, put a black sticker on the reflection point of your meter to limit the reflection, and if nothing else works, try soldering two small led's that you can position relative to the board) and then lastly, 4. your rectangles around your digits are too small. They need to be bigger (+-30% whitespace around each digit). If you do all of the above correct, I can almost guarantee that it will have it correct for 90% of the times and the rate limit should filter the other 10%. I can't speak for the analog ones as I didn't use those. The stability of the latest version was terrible, but the v9.2 was working fine. The camera drivers were changed in latest version and proved very buggy with my esp32 board type.
Seems I'am lucky, for me the AI on the edge solution works quite reliable since about 6 weeks now. It's reading all the 5 digital and 4 analog values of my watermeter properly. Three or four times I noticed errors. But those were detected and shown as error by the integrated plausibility check. So the sensor did not send any values until the readings made sense againt . The big advantage of the AI on the edge solution is, that there it's directly reading the watermeter. So it always gets back to the proper values. When counting impulses and calculatimg the values little errors will add up and the real value of the watermeter and the calculated value of the sensor will drift further and further apart by time.
Going the optical character recognition route, as was initially attempted would require a substantial amount of system training. You provide the images and supply the CORRECT digits in each case. Then after a while it will be able to do it reliably on it's own.
This is also the best solution to have the project running only for small amounts of time. But AI surely requires a lot of CPU power, and you can end up with a project which drains batteries faster than a proximity sensor one. I was also thinking about proximity sensors for smartphones: are those all of the reflective kind?
The training and the execution are separate tasks in AI. Training is done on big CPUs. But the execution (inference) does not need a lot of power and can be done on smaller machines.
@@AndreasSpiess that's true, but I assume that also the picture grabbing and processing, along with the energy needed to power up the LED would be high. In the meantime I was thinking about STM32's battery backup domain. This feature if I well remember should contain an event counter still working when the core is in deep sleep mode, which would be capable of turning on the system after some counting has reached a pre-programmed threshold. This could help, if you only need a rough value from time to time rather than a continuous monitoring.
@@AndreasSpiess You could train that simple model on decent 16 core desktop server, probably in a matter of days. The problem would be getting all the training images together, which would require multiple permutations. Those half digit images especially.
Retaining the model is actually very doable, even on a slower machine. Since you could use a pre trained model and only retrain the head. The problem here is that you need images of all the numbers in every position to account for the led glare
to eliminate the glare try polarizing film either over the meter face or on an angle below the LED. You can get the film from a damaged LCD screen/ display.
As always great video! The metal piece from the water meter is for inductive sensors like TI LDC0851, I have worked designing this kind of sensors for iot devices
Hahaha, let the MBAs do what already works… priceless! I’m sure your typical audience are mainly engineers so no one will take offence. Great video as always. Thanks!
That 3 letter degree provides more value than I can adequately communicate. But I cannot imagine a PhD in it. Oof. Though, having that in a concentration such as Operations could be fun. Sort of. ;-)
My meter has nothing like that and the digits don't align very well for image recognition, but most of these meters need to transfer the motion of some rotor inside the water to the measuring mechanism outside the area where water is, without allowing any water to escape. Almost all meters do this transfer of motion using magnetism, so that in turn means there is some changing magnetic field at the center of that mechanism when the rotor rotates. Sometimes that magnetic field might be sufficiently strong to measure with a Hall sensor, but with my meter - with metal housing - this didn't seem to work. But ... I then used a magnetic field / compass sensor glued to the meter body and from that get a vector that indicates the direction of the magnetic flux. When the meter turns, that vector also turns (in 3d) and by reading it out several times a second and tracking that movement (flattening out some jitter which will always be there with something like this), my esp8266 can measure the number of rotations the meter makes and convert that to actual cubic m of water gone through ... Within one rotation the accuracy is not perfect, but half rotations (so those inverting the vector) are detected fine.
Just a little tip: If your microcontroller doesn't have an ADC pin or you can't spare another ADC for just a simple sensor, you can read it with a digital pin. We can accomplish that with example a PNP transistor on the output of the sensor and with a relative low base and collector resistor, that will make the output clip between gnd and 5v, like a digital signal.
I made a project like that, reading 8bit segment digits from an aquarium meter. Used ESPcam to take pictures, then a raspberry with OpenCV to locate the digits and tweak the image, then tesseract, trained version for digits. It works nice in the end, i still get some wrong numbers but im able to filter then out.
I have same counter in Vaud but the water supplier add the remote sensor by default. The M-Bus can be read on 868.625M from your favorite SDR gear and RTL soft. They do that so they don't have to ask you to check the counter. use Izar protocol and NOKEY param.
A very interesting video. The way to approach the sine wave to process it is brilliant. My water metter is very similar to the one from the project, but has some kind of wireless communication as this is a flat with central hot water (same goes for the heating). I wish I had enough knowledge to work it with the SDR radio to get the numbers in the same way I get the 433 weather sensors.
It is two years ago modern, so sure it will be. Too bad, but thank you for pointing it :) I could follow the AI path, as my model is very similar to the one from the project. Before that I´ll try asking the provider to get direct access to the API and feed Nodered with it, or even try to process the very unusable user website I have with poorly arranged information.
I tried exactly the same with my heating central at the attic and my house power meter. I ended up kicking the pattern recognition in both cases. The fresh installed smartmeter (power) provides a blinkig LED, 5000 ticks per kWh. Easy enough to read using a lightsensor. For the central heating I just tried to find out how often the flame was ignited. I ended up using a lightsensor as well, using the "flame is on" LED of the heating central. I would love to read gas consumption and water consumption as well, but here my problems are more real life related: no power to drive anything around those installations. Seems, the guy that planned installation in this house did not have any digital stuff in mind at all. Still, I need to stick my head into that tensorflow pattern recognition. And many thanks for not calling pattern recognition AI. I hate that buzzword bingo that is happening nowadays.
You know: I am an engineer and like to name things correctly ;-) Using secondary things for measurements often needs some creativity but can lead to good solutions (as in your case). These counters need some power because they have to be always on and, in my case, also need an LED. So, 100mA is needed. I have electricity there so it will not be a problem.
I like the more practical approach to the measurement - using pattern recognition is good idea for some events, but reliability is a big problem. So using something like you did is far better, I think.
For me, it was interesting in diving into the matter. What does the counter do if one number is between two numerics? What if 2 or three are in this position? Not easy to solve if the counter was not made to be read by a machine. Or if I cannot read one of the dials? How to solve that?
Polarizing filters may help, but the angle of the reflectet should be in the neighborhood of the so called Brewster angle (the closer the better). If the angle of the reflected light is close to zero degrees (vertical incidence) a polarizing filter doesn't help. I such cases two polarizing filters may help: the 1st filter in front of the LED, the 2nd in front of the camera. The two filters must be 'crossed'.
This seems another method if your counter does not have this reflective part. I only tried this part with the hall sensor. So I do not know if my counter would also have such a metallic part.
@@AndreasSpiess Yours works. In the end that's what counts (no pun intended). I have considered the AI solution as well but found it unreliable/too error prone
Instead of changing magical number for the initial value, can also let ESP subscribe to a mqtt topic so you can adjust without needing to recompile/reupload
I've been working an AI agricultural system to read 24k analog meters. When trained with a custom dataset from our meters we've achieved excellent recognition and conversation at the edge. Using a priori information about the meters prior state we can deal with many other edge case issue since we know meters only increase over time.
Some meters actually use magnet to trigger reed switch and the reader head either sends a pulse or it's smart enough to keep the count and report the current number
I think for having better results from the AI, it would be necessary to train it with pictures from the watermeter which is actually used. In German magazine "Make" there is currently a series of articles on how to do this ("AI for ESP32" or "KI für den ESP32" in German, unfortunately behind a paywall). The AI is trained on a PC with python, only the result is transferred to the ESP32. Didn't do it myself, but I would except much better results.
The articles in the German Make are actually by the same author as the water meter project. By the way, this runs extremely reliably for me. But it's true: You should reduce complexity wherever possible if you want reliability. However, I bet that 99% of the viewers here don't do that, because in that case we would have to do without our ESPs and Raspis and switch the light on and off at the switch instead ;-)
Glad the installation works with you. Your counters are much more "clean" than ours. Only one level and nothing covered. Fortunately, I get the "Make" every month. But training my project would have been too much time consuming. And the main problems still would be there (glare, 2 dials covered, number between two numerics). So I learned a lot and wait for the next shot.
I guess that metal 'D' plate was designed for a specific optical sensor unit from the OEM with a shaped and focussed beam which probably made the electronic signal processing a bit easier. we've got portable label printers at work that use IR to count and align the label paper by black marks printed on the back of the paper and they do a really good job under a lot of conditions.
Engineering at it's best Andreas! ;-) I'm using a setup where I'm not really interested in the actual numbers but trying to detect water flow vs no water flow to react on broken pipes, hanging valves etc. My theory is that in 2 hours there should always be 10 minutes with absolute no water usage - at least in my household. If not I use a central valve to close the entire water flow for the house. Works great so far, f.e. detecting hanging toiletts or similar. Had just one false alarm in 5 years. I also have added a ESP32 CAM .. but basically to just allow me to get a "video" or static picture from the counter (that's what the default firmware of the ESP32 CAM does). My water supplier (10 years ago) offered a special device for ~60 euro that is able to put out a open collector contact for every liter water. Imho there is a spinning magnet inside the water meter itself which they plug on. Easy way to get the "real" numbers of water usage. And btw: The "central valve" just a pure mechanical construct which uses an old cordless drill to manually close the central valve ;-) Cheers!
My new decalcification system has this feature, too. You know how I discovered it? For the tests in this project, I had to let the water run constantly for some time. Suddenly it stopped :-( This device checks if the water flow is the same for a certain time and then cuts it...
To get rid of the glare, best is to put the camera to read at 45 degrees to the surface, but anything will see improvement. That will take the LED and bounce the light away from the camera. I thought you had to train tensorflow. Would it have better results if ran much longer to train it?
Also a good idea. I developed this way when I had more variables to store. And often, I do not know how many variables must be stored at the end of a project ;-)
Thanks for this video. You didn't talk about training the neural net for the failed image recognition phase of the project. Did you just use a generically trained NN? The training phase of NN development will almost certainly be a really important tool for future makers. Perhaps you should take a closer look at this... Note that training this type of numerical recognition system where the numbers always appear in the same location in a picture is one of the easiest to train because you can get immediate and unequivocal feedback on whether the NN output is correct or not. This is generally not the case, which makes training in the general case much more difficult and explains why it is such a hot current research area.
This project was trained with the German counter (and seems to work ok). Training for only one counter was too much work for me. Therefore, I did not look at it. I just hoped it would work with my counter, too.
@@AndreasSpiess I tried 2 for my water meter and they both work although one was rated as low as 6V it still works reliably at 5V. And if you take the NPN version it will not hurt the micro because it only grounds the output. Being digital signal its much easier and reliable to work with. Costs as low as 3-4 euro from China
Cool project, I have something similar in mind for several months now but my ESP32-CAM boards got lost on their way to me 😁 BTW, using the VoltLink USB to serial adapter, would not require pushing any buttons for programming the ESP devices as it handles that automatically 👍
Both solutions have their set of problems on which they are useful. Thank you! Edit: I'm having a lot of fun reading the comments, so many clever ideas.
What about capacitively sensing the grey plate? Looking at the design of the grey plate, I am reminded of a tunable capacitor. Is it made of metal, plastic, or since other material? Capacitively sensing the plate might allow you to get more of an analog/positional reading, instead of a single pulse per revolution. It would also be significantly more reliable if the meter is exposed to sunlight (something that I believe the manufacturer may have anticipated).
I do not know if this plate is metal or just painted plastic. Sunlight is rare at the place it is mounted (usually in the basements). But I do not know how they do the reading and if they use a different method. As you saw, I also get an analog signal and could do some mapping. But one turn is 1 liter. That is good enough for me.
To read the metal piece you need to use LC sensor. The Hal of course will not work. And the IR in the field will going to have problems because of the moisture and the water around the meter. Using LC sensor will eliminate that problems and is very robust. Use two LC sensor to find also the rotation direction of the disk. By the way very nice video!!! I'm waiting to see one using LC sensor, there is plenty of documentation out there from ST, IT and meany more.
In the meantime I tried such a sensor and you are right, it works. Unfortunately, mine needed at least 6 volts. So I stick with IR. My place is clean and dry, so I do not expect problems. For now it is reliable.
Still nice to experiment with AI. For the water meter, I have created one a year ago, using a hall sensor. A few hints for those who want to create one too: - as my meter has a metal spinning disc, a hall meter does work in my case - I created an MQTT message from which I can update the reading after a reboot. Also, I keep track if an update was done. - I had to use a condensor and a resistor to avoid false reading. They were rare, but completely eliminated with that small circuit added.
Thanks for the tips! Other viewers suggested avoiding the absolute count on the device and only keeping it on the Raspberry. That is what I will do. Only transfer the consumption.
I attempted a similar project in the past, reading a water meter on a rotating dial. It was a spoked wheel with many more theeth on the outside. Reading it optically worked super well, to a theoretical accuracy of a few ml per tooth. Unfortunately the water meters were replaced with ones that have only the numbers visible. I was unable to find a rotating magnetic piece, or a detectable piece of metal inside.
If the project supports training then based on your own images then it really should be possible to get perfect recognition of the main digits at least. Constructing and training on synthetic images of the digit transitions might well be reliable too. I always prefer the simple pulse counting and interval timing approaches though as they're perfect for smaller uC's such as PICs.
Hi, thanks for amazing video, very instructive. I have a question: why don't use a Smith trigger to signal conformation to have a 0 and 1 digital signal? Thanks and see you next
A hardware schmitt trigger would add complications but it could be done in software with an adaptive threshold detector that was largely immune to changing bias. Andreas's approach is neat though and has the potential benefit of being able to do some error handling or error correction.
Exactly. I wanted the sensor to be able to adjust automatically. The curve is not as neat as I showed (a sine was easy to draw) and its middle is not at 1.6 volts (it also changed with slightly different adjustments). But you are right. I most probably could have done it a little simpler. But I also wanted to be a little educational for other cases.
Andreas another great instruction video. I enjoyed the water usage analysis. I got thinking, you should add some control to the project and slowly reduce the available hot water after a certain time frame. The idea to minimize water consumption. Results could be water savings but …. 😉😉
Thank you for these excellent videos. I love the clear thinking and explanation you bring to them. So, as AI has transitioned from its early mechanistic approaches (e.g., expert systems, etc.) to the current models based on non-parametric statistics, there is also a subtle change in its successful application. The current models are more about being 'less wrong' than 'exactly right in the instance'. This is encouraged by its alignment with large number theory and other assumptions (e.g., Bayesian Analysis, etc.). Given this, we might best think of modern AI technique as most suitable as part of a 'problem-space reduction' tool that gets bolstered and completed by more traditional, deterministic kinds of algorithms, rather than as a central part of some core algorithm. AI's real mission, IMHO, is about abstracting 'the smart' from from everyday good engineering, and this will require a different kind application with different kinds of value produced. I like to think of AI as a kind 'context manager' for whatever problem(s) I am trying to understand and solve. Still, this was a bold and valuable attempt. Bravo to Andreas Spiess, The Guy with Swiss Accent.
I only used AI for the UA-cam algorithm. Otherwise I call this use case "pattern recognition". I still think that, if we take out the sales speak, a lot of valuable "AI" is pattern recognition, sometimes on a high level. I also never know how much programmed "expert system" is in the applications. I use a spelling and grammar checker for my scripts and always wonder how good it is. But I fear there is a lot of standard programming behind it. Even if the leaflet calls it "AI"...
Yup, if water meters where not leaded 😉 we could glue a tiny magnet on the dial arm. Anyway there are also sold water meters with built-in pulse output, but then you had to buy it self and let register and lead it again at the water supplier.
Sure could have used one of these a few months ago, my water bill went through the roof. The water department told me to check if my water meter's needle was spinning, it sure was, non-stop.
@@AndreasSpiess Leaking toilet overflow valve did not turn off water flow, imperceptible leak that I was unaware of until I saw that meter needle spinning.
How did you do the aggregating in Grafana at position 0:42? I tried "field(value) last() difference()" and "group by time(1h)". But a) this does not work for months and b) fill(previous) doesn't work, so I always have spikes like in fill(linear)
Grafana does not show the aggregations if the data is not here for the whole period. I did not use fill(previous). It would not make a lot of sense for consumption. But I also have to try till it looks good.
using EEPROM is good but since you have connection via MQTT ( RPI ) and then to Influx DB, why not in startup get the last values from DB instead. Let the DB be your master source of data But awesome project for sure
You could also publish with retain and subscribe to the same topic then you will be updated at startup. To be fully persistent remember to set the mqtt server to save the retain messages on disk
You compared pears with apples. In the traditional approach you were able to choose the right tools and write a program to make them work. The equivalent process with such a focused AI tool is training it with your images and your labels (e.g. black background, rotating reflector, ...) After that and maybe some lighting adjustment, the camera-powered solution can be far more reliable than the traditional one (e.g. being able to recover from outage/disaster and being able to store some pictures for periodic manual verification)
Of course I compared apples with pears! And I liked apples more in the end. Comparing apples with apples often does not provide good solutions because your search is too narrow. I know that the system can be trained. But for one meter?
@@AndreasSpiess you are right, the answer is not obvious, in the economy of such a model it is probably more appropriate to train for a class of objects, let's say the black background meters. I'm saying that a data scientist will find easier to train for your specific meter while sticking to "simple" camera hardware like an old smartphone, compared to developing a dedicated module with opto-things etc. Same things applies to your "traditional" solution if you compare it to a 40 years ago flip-flop based counter, the trend is the same, always more powerful hardware and always more easy to write software for it
Hi I lived the solution implemented by you and am trying to buld one At 8.03 min I see you have suggested connecing 2 resistors 330 ohm between vcc and emitter and 10K one between Gnd & Diode What power rating should I use for them?
@2:07 - That trigger button made me think of one of those vintage accordion plate cameras (on a tripod/stand) which has a cord and "button" to trigger the snapshot. Maybe as a project you should make a retro version of that style camera using an esp32-cam and cord. ;)
Very interesting. I like your solution much better than the AI solution. I am curious why you chose to setup the reflective sensor in an emitter follower configuration. I am sure you had to tweak your LED current to come up with such a nice sine wave. Phototransistors are hard to keep in a linear region.
Lovely treasure boxes :) I'm affraid all we have similar number of goods at our workshops. Great idea with phototransistor. I've tried AI on the edge and after hours or experiments I have to chose another solution due to big difference between mine water counter and the example one. Great content! Appreciate your work very much.
I enjoyed the final solution. More investigation of the camera system would have been interesting, but can't disagree with simple, low power, and reliable solutions.
In situations where water meter locations usually lack access to power, is there a viable option to adapt this project by implementing RF for low-power signal transmission using batteries? The goal would be to receive these signals on a gateway and subsequently publish the data to MQTT. Thank you for the great videos and the moments of humour.
At around 4:30, the glare problem. Can I suggest three things? 1) introduce a polarizing filter between the camera lens and the meter (this may well solve the problem), 2) Degrade the video signal to monochrome or use a monochrome camera, don't need the colour and 3) Ignore the decimal digit, it doesn't add much information but creates a lot of problems, after all the water company doesn't include this in their billing do they and it wouldn't be evident in your resultant usage graph either?.
@@AndreasSpiess Yes I can see and accept that, if what you've got is doing the job then why reinvent the wheel? There is an adage that you use the simplest system to do the job. Just out of interest though, have you seen the Nicla Vision from Arduino, looks like it could do this task whilst having the electronic equivalent of standing on it's head? A bit expensive though!😁
90% of what is sold as "AI/ML" is indeed a pattern recognition algorithms. Either detecting the pattern or using detected patterns to detect further anomalies. From computer system monitoring to driver assistance fall in that category.
They could also be using a metal detector. i.e. An inductive proximity sensor. Alternatively, a hall sensor and a biasing magnet. Inductive proxies are good for any metal, foil if non-ferrous, while hall and magnet is only good for ferrous targets.
Is there any mechanism that we can measure AC voltage level, in my flat the voltage fluctuations are common and the AC stops working and gives 88 error which is during high or low voltages. Please make a video if feasible. Thanks
You can use any AC meter to measure the voltage. If you want to read it via Wi-Fi you get power meters with built-in Wi-Fi (e.g. Sonoff). They measure voltage, too. I already made a similar video.
Wow, great project and test of "AI" (CNN) vs reflectance counter. I wonder how effective traditional image processing would work, e.g . bitmap matching and arrow angle analysis. Probably you could have retrained the NNs and tweaked the alignment to get it to work, but that's a lot of work. I have a friend who wants to monitor water heater status lights, and seems like an ESP-Cam would work well. I was thinking of using simple image analysis (AI seems harder). You could have written image analysis to detect the spinning disk, but you could have a low power solution (battery) with your reflectance sensor monitored by the ULP peripheral.
I could also have trained Tensor flow for my setup. But the effort was too big for me. But for other scenarios this setup could be good. Training for a few LEDs probably would be simple...
Using a correlation filter would have been much simpler to implement and probably more reliable, considering that the setup has fixed lighting conditions
Fascinating! I hadn't thought of using a camera on an analog meter when I went this route. Like you I already had electrical monitoring into Influxdb (thanks Iotawatt!). So I started to wonder about water. I already had some cheap hall sensors on my outdoor water lines to verify that the irrigation system keeps our garden watered. But what about the house itself? Here in Canada (Vancouver) we don't pay for our water, so it's not metered, so I didn't have an analog meter to start with. Digital water meters were pricey, and usually meant for high-volume, so not very precise. Then about a year ago EKM Metering released a version of their pulse water meter that pulses every 0.283 litres. You can hardly turn a tap on without a pulse. Plug the pulse output into a Sonoff running Tasmota, and tada! A count published to MQTT every minute. The meters are cheap enough that I bought two: I still need to put the second one on my hot water line, but soon I'll know water the hot:cold ratio is for my shower. I have yet to convince my partner why this is useful. :-)
Andreas nice video! Why do you need the analog input. You can also use a "flip-flop" or? Do you know there are different esp-cam modules are on the market?
1. I wanted that the sensor adjusts its values automatically. The middle value is not at 1.6 volts and the curve is not a sine as I showed (for simplification). But implementing a threshold could have worked, too. I agree.
what about placing a piezo sensor to the water pipe? when there is a flow it should create some vibration and with some calibration there may be good results :)
I would not want to try it because I do not know what it would do with the plastic and if it could be removed later. And I need the counter for the next few years ;-) I use hairspray for my 3D printer, BTW. But on a metal plate.
pretty much all out water and EL meters here, have an IR LED under the clear cover, so that the 'meter man' can simply place a reader on top to take the reading, eliminating human errors. Well that was until recently, now the wast majority of our meters have been replaced by IoT meters and read online anyway.
Hi Andreas.. as usual solution is generally simple..when sought out. AI is needed where normal I wont work ;). Btw.. i have been playing with this cam since quite a while. One way to reduce glare is 3D print diffuser.. other control intensity, lastly as you did rightly.. external LED. But my major challenge is... how do we get rid of that glue.. never managed to remove or losen that focusing lens... any thoughts?
Maybe take photos from the ESP32's camera and send them to a more powerful computer (Raspberry Pi). There do the AI processing and then send the results to a database to later be able to see the data using Grafana.
There are ultrasonic clamp on sensors available who measures water flow by the doppler effect. Didn’t have such yet, but would be my way to solve. Maybe they can be DIY build with transducers?
I think I have such modules in my lab (i was fascinated when I saw them). But I always wondered how they can do this through metal tubes (here everything is metal at the entry of the home.
@@AndreasSpiess solid iron pipes here too. I think they couple trough, like a stethoscope work. But i donno, cause i dont have such to goof around with it. But this would be a very interesting topic right now on grown energy costs and everybody will cut expenses.
Thanks again for a very interesting and informative video. So many valuable nuggets of valuable information from a seasoned engineer ! If your wife had so many stashes youd probably call her a hoarder :-), so its ok if she is cleaner than you. So the AI solution you found is quite brittle, it breaks when bent to a slightly different problem. I also thought it would be straightforward to take images of my oil tank level and automatically remind me when to reorder ... 3m later Im still going into the basement to read the guage directly. Yes the ESP32-CAM is an amazing device, but requires work to do real-world tasks different from any open source available. Introductory solutions can be found with only 50 lines of code, more featured ones are several thousand lines of rarely commented code.
Instead of using a magic number which overcomplicates things, store the crc of the number or some other calculated value based on the reading to be saved and check for that instead.
hello in order to improve IA result, in your cas you could try to nomalize input image in a different way to help neural network in his recognition work, binary color and gaussian could be a start. you can try to treshold you pixel value range, over a long time (find min max, of a pixel zone) Add physically some light reflector to help with changing luminosity. may i suggest you to try tesseract in python, quite effective
I only have one meter and only tried this project because it already had a trained model. I agree that your proposals could solve some of the issues. But the effort would be too high for me.
Noce way to solve the problem! However I'm not sure why you hadn't just used current analog check since it's metal plat, you can print a simple adapter and it would work like a charm. Moreover you can else just glue a tiny magnet and use magnetic field sensor using i2c ( not hall sensor ) which should be a bit more reliable. There's a video somewhere who explain Tesla door, they do something similar but with door. :)
If you like to use ai, than you can use Edge Impulse and explore se AI (pattern recognition). It is a greater start to explore this topic for beginners. An easy sensor is an Gyroscope. Maybe you are interested and give it a try.
I know Jan, the founder... But I needed a trained project for my meter. I would never have tried it if I had to do the training. Too much effort for one meter :-(
Sali Andreas, ich feiere echt all deine Videos, genial - mach bitte immer weiter so! Zum ESP32-CAM mit AI on the edge watermeter Ansatz kann ich Dir berichten, dass dies bei mir erstaunlich gut funktioniert. Vielleicht wurde mittlerweile der Algorithmus auch weiterentwickelt. Mein Wasserzähler hat ebenfalls weisse rollierende Buchstaben auf schwarzem Grund, und die werden recht zuverlässig erkannt und interpretiert. Ebenso die analogen Zeigerchen. In Home Assistant sehe ich per MQTT präzise den Wasserverbrauch. Das Gefummel bis Kamerabild und Licht stimmten, war aber schon e chli en Murks.. :)
"An engineer's work always starts when something does not work, the other things can be done by the MBA's". That hits harder than it should hahaha, preach!
This reminds me of my favorite remote sensing story: it was determined that the cheapest, quickest, and most accurate solution to remote greenhouse temperature sensing was a large dial thermometer and a pair of binoculars.
Cool!
Nice! Now you can install an esp32-cam with a telescope! No cables, no long range wifi, no LoRa, just a telescope, one cheap esp32-cam+AI, and a local wifi.
@@guatagel2454 Brilliant idea!
🤣
I work as a data scientist and one of the most important questions you always have to ask before using AI is:
Can this be done without AI?
If the answer is yes it is probably more reliable to do in a traditional way.
Thank you for the additional insight!
Well then you might have to convince all other members of a co-owned housing compound to let you change just one water counter and why...
@@AndreasDelleske generally speaking, using AI to bypass HOA restrictions could be popular in a lot of tech savvy pockets that have sprung up in old money communities
@@AndreasDelleske
That means you can't do it (or can't do it without a significant amount of effort).
-> use case for AI
the term "AI-washing" comes to mind, similar to greenwashing for environmental issues.
Hi Andreas,
great video! This is the developer of the AI-on-the-edge. The reason, why your analog counters are not detected correctly is indeed the inverted color (white on black). In contrast do the digits, this is not part of the training data yet.
Have a look on the latest updates, now we can even detect the NaN values with then newest neural networks.
Best regards,
jomjol
Cool that I have so important viewers on the channel! Even if it did not work for me, it still is a very good project!
Hello, I also have the AI solution for Gas and Watermeter and it works fine. But it took me some hours to do the correct setup. It it important, that the image is horizontal aligned and the scan area for the digital digits are large enough (larger than you wouId expect) , in 3:21 you see the 039 even includes the frames around the digits. This reduces the NaN results a lot and even recognized switching numbers. Also you must setup the initial value and a threshold to only overtake reasonable values (Values to low or big are thereby ignored). I mounted an angle iron on the wall 10 cm above the meter and taped the ESP32 below it. By twisting, you can move the glare point of the internal led to an area, which is not scanned, With this easy solution your energy provider can still read the values manually, if needed. Hope that help's to give it another try.
I agree with the above. I almost gave up on it as wel, but after adjusting and configuring for days it's been stable for weeks now. The documentation is very limited, but I can already see what you did wrong there (due to all my fails lol): 1. your camera is too far away or lens was not adjusted to have the best focus for the distance, 2. your rotation is slightly off (even 0.5 degrees makes a difference), 3. your reflection of the LED will hinder you a lot (experiment with different positions, angles, put a black sticker on the reflection point of your meter to limit the reflection, and if nothing else works, try soldering two small led's that you can position relative to the board) and then lastly, 4. your rectangles around your digits are too small. They need to be bigger (+-30% whitespace around each digit). If you do all of the above correct, I can almost guarantee that it will have it correct for 90% of the times and the rate limit should filter the other 10%. I can't speak for the analog ones as I didn't use those. The stability of the latest version was terrible, but the v9.2 was working fine. The camera drivers were changed in latest version and proved very buggy with my esp32 board type.
Seems I'am lucky, for me the AI on the edge solution works quite reliable since about 6 weeks now. It's reading all the 5 digital and 4 analog values of my watermeter properly.
Three or four times I noticed errors. But those were detected and shown as error by the integrated plausibility check. So the sensor did not send any values until the readings made sense againt .
The big advantage of the AI on the edge solution is, that there it's directly reading the watermeter. So it always gets back to the proper values. When counting impulses and calculatimg the values little errors will add up and the real value of the watermeter and the calculated value of the sensor will drift further and further apart by time.
Going the optical character recognition route, as was initially attempted would require a substantial amount of system training. You provide the images and supply the CORRECT digits in each case. Then after a while it will be able to do it reliably on it's own.
This is also the best solution to have the project running only for small amounts of time. But AI surely requires a lot of CPU power, and you can end up with a project which drains batteries faster than a proximity sensor one. I was also thinking about proximity sensors for smartphones: are those all of the reflective kind?
The training and the execution are separate tasks in AI. Training is done on big CPUs. But the execution (inference) does not need a lot of power and can be done on smaller machines.
@@AndreasSpiess that's true, but I assume that also the picture grabbing and processing, along with the energy needed to power up the LED would be high. In the meantime I was thinking about STM32's battery backup domain. This feature if I well remember should contain an event counter still working when the core is in deep sleep mode, which would be capable of turning on the system after some counting has reached a pre-programmed threshold. This could help, if you only need a rough value from time to time rather than a continuous monitoring.
@@AndreasSpiess You could train that simple model on decent 16 core desktop server, probably in a matter of days. The problem would be getting all the training images together, which would require multiple permutations. Those half digit images especially.
Retaining the model is actually very doable, even on a slower machine. Since you could use a pre trained model and only retrain the head.
The problem here is that you need images of all the numbers in every position to account for the led glare
to eliminate the glare try polarizing film either over the meter face or on an angle below the LED. You can get the film from a damaged LCD screen/ display.
I agree, polarization could help. I will try it once.
As always great video! The metal piece from the water meter is for inductive sensors like TI LDC0851, I have worked designing this kind of sensors for iot devices
Thanks for the info! Mine did not work with my hall sensor. So I thought it is not metal...
In the meantime I checked with the LJ18A3-8-Z/BX sensor and it works. So it must be metal, but not magnetic.
Hahaha, let the MBAs do what already works… priceless! I’m sure your typical audience are mainly engineers so no one will take offence.
Great video as always. Thanks!
Anyway, as an owner of an MBA and a PhD in Business Administration I thought that this joke was ok ;-)
That 3 letter degree provides more value than I can adequately communicate.
But I cannot imagine a PhD in it. Oof. Though, having that in a concentration such as Operations could be fun. Sort of. ;-)
My meter has nothing like that and the digits don't align very well for image recognition, but most of these meters need to transfer the motion of some rotor inside the water to the measuring mechanism outside the area where water is, without allowing any water to escape. Almost all meters do this transfer of motion using magnetism, so that in turn means there is some changing magnetic field at the center of that mechanism when the rotor rotates. Sometimes that magnetic field might be sufficiently strong to measure with a Hall sensor, but with my meter - with metal housing - this didn't seem to work. But ... I then used a magnetic field / compass sensor glued to the meter body and from that get a vector that indicates the direction of the magnetic flux. When the meter turns, that vector also turns (in 3d) and by reading it out several times a second and tracking that movement (flattening out some jitter which will always be there with something like this), my esp8266 can measure the number of rotations the meter makes and convert that to actual cubic m of water gone through ... Within one rotation the accuracy is not perfect, but half rotations (so those inverting the vector) are detected fine.
Cool! I like that you did not give up!
Just a little tip: If your microcontroller doesn't have an ADC pin or you can't spare another ADC for just a simple sensor, you can read it with a digital pin. We can accomplish that with example a PNP transistor on the output of the sensor and with a relative low base and collector resistor, that will make the output clip between gnd and 5v, like a digital signal.
Good idea!
I made a project like that, reading 8bit segment digits from an aquarium meter. Used ESPcam to take pictures, then a raspberry with OpenCV to locate the digits and tweak the image, then tesseract, trained version for digits. It works nice in the end, i still get some wrong numbers but im able to filter then out.
Cool project!
Thank you for the video.
Getting interested in tensorflow now :)
You can also use mqtt retain to store the counter value.
Works great for me.
Cool. This was my first encounter...
I have same counter in Vaud but the water supplier add the remote sensor by default. The M-Bus can be read on 868.625M from your favorite SDR gear and RTL soft. They do that so they don't have to ask you to check the counter. use Izar protocol and NOKEY param.
Cool! Here we are asked to read the counter once a year.
A very interesting video. The way to approach the sine wave to process it is brilliant.
My water metter is very similar to the one from the project, but has some kind of wireless communication as this is a flat with central hot water (same goes for the heating). I wish I had enough knowledge to work it with the SDR radio to get the numbers in the same way I get the 433 weather sensors.
If these meters are more modern they often are encrypted :-(
It is two years ago modern, so sure it will be. Too bad, but thank you for pointing it :)
I could follow the AI path, as my model is very similar to the one from the project.
Before that I´ll try asking the provider to get direct access to the API and feed Nodered with it, or even try to process the very unusable user website I have with poorly arranged information.
I tried exactly the same with my heating central at the attic and my house power meter. I ended up kicking the pattern recognition in both cases. The fresh installed smartmeter (power) provides a blinkig LED, 5000 ticks per kWh. Easy enough to read using a lightsensor. For the central heating I just tried to find out how often the flame was ignited. I ended up using a lightsensor as well, using the "flame is on" LED of the heating central. I would love to read gas consumption and water consumption as well, but here my problems are more real life related: no power to drive anything around those installations. Seems, the guy that planned installation in this house did not have any digital stuff in mind at all. Still, I need to stick my head into that tensorflow pattern recognition. And many thanks for not calling pattern recognition AI. I hate that buzzword bingo that is happening nowadays.
You know: I am an engineer and like to name things correctly ;-)
Using secondary things for measurements often needs some creativity but can lead to good solutions (as in your case).
These counters need some power because they have to be always on and, in my case, also need an LED. So, 100mA is needed. I have electricity there so it will not be a problem.
For power, if money was no object a power over Ethernet (PoE) setup sounds nice, or just run speaker wire with either 5v or 12v as supply
@@gregw1076 sadly, not working there. No way to get a cable there, if it not look like a barbarian attack :)
I like the more practical approach to the measurement - using pattern recognition is good idea for some events, but reliability is a big problem. So using something like you did is far better, I think.
For me, it was interesting in diving into the matter. What does the counter do if one number is between two numerics? What if 2 or three are in this position? Not easy to solve if the counter was not made to be read by a machine. Or if I cannot read one of the dials? How to solve that?
Try an inductive proximity sensor instead of the IR sensor.
Why should I? It works now ;-) But others suggested inductive sensors, too. So maybe good to know for others.
The needle mechanisms are magnetically coupled to the turbine so you can for sure use hall effect sensor if you remove the lid and gears completely.
Good to know. But I did not want to destroy the top. I think the meter belongs to water supplier, not to me...
Polarizing filters may help, but the angle of the reflectet should be in the neighborhood of the so called Brewster angle (the closer the better). If the angle of the reflected light is close to zero degrees (vertical incidence) a polarizing filter doesn't help. I such cases two polarizing filters may help: the 1st filter in front of the LED, the 2nd in front of the camera. The two filters must be 'crossed'.
Good idea! Maybe I will give it a try (out of curiosity and to learn).
Two interesting approaches. i am using an inductive proximity sensor placed above a rotating metal semidisc to pick up a signal
This seems another method if your counter does not have this reflective part. I only tried this part with the hall sensor. So I do not know if my counter would also have such a metallic part.
@@AndreasSpiess Yours works. In the end that's what counts (no pun intended).
I have considered the AI solution as well but found it unreliable/too error prone
In the meantime I checked the LJ18A3-8-Z/BX sensor and it worked. So it must be metal. Now I have the choice...
@@AndreasSpiess great
Thanks for video!!
Good content, as usual.
In my project, I used a coffee cup to mount the camera. I loved it, cheap and recycled.
Good idea!
Instead of changing magical number for the initial value, can also let ESP subscribe to a mqtt topic so you can adjust without needing to recompile/reupload
Good point. Or, as other viewers suggested: Only transfer the consumption and store the absolute value on the Raspberry. That is what I will try.
I've been working an AI agricultural system to read 24k analog meters. When trained with a custom dataset from our meters we've achieved excellent recognition and conversation at the edge. Using a priori information about the meters prior state we can deal with many other edge case issue since we know meters only increase over time.
Good to know. I assume you were able to invest a little more time for 24k meters than me with only one ;-)
Some meters actually use magnet to trigger reed switch and the reader head either sends a pulse or it's smart enough to keep the count and report the current number
I changed the concept now and only transfer the impulse. The rest is done in Node-Red...
I think for having better results from the AI, it would be necessary to train it with pictures from the watermeter which is actually used. In German magazine "Make" there is currently a series of articles on how to do this ("AI for ESP32" or "KI für den ESP32" in German, unfortunately behind a paywall). The AI is trained on a PC with python, only the result is transferred to the ESP32. Didn't do it myself, but I would except much better results.
The articles in the German Make are actually by the same author as the water meter project. By the way, this runs extremely reliably for me. But it's true: You should reduce complexity wherever possible if you want reliability.
However, I bet that 99% of the viewers here don't do that, because in that case we would have to do without our ESPs and Raspis and switch the light on and off at the switch instead ;-)
Glad the installation works with you. Your counters are much more "clean" than ours. Only one level and nothing covered.
Fortunately, I get the "Make" every month. But training my project would have been too much time consuming. And the main problems still would be there (glare, 2 dials covered, number between two numerics). So I learned a lot and wait for the next shot.
I guess that metal 'D' plate was designed for a specific optical sensor unit from the OEM with a shaped and focussed beam which probably made the electronic signal processing a bit easier.
we've got portable label printers at work that use IR to count and align the label paper by black marks printed on the back of the paper and they do a really good job under a lot of conditions.
Well possible that they wanted more accuracy. Or wanted to save on BOM cost and only added a simple sensor and no MCU.
Engineering at it's best Andreas! ;-) I'm using a setup where I'm not really interested in the actual numbers but trying to detect water flow vs no water flow to react on broken pipes, hanging valves etc. My theory is that in 2 hours there should always be 10 minutes with absolute no water usage - at least in my household. If not I use a central valve to close the entire water flow for the house. Works great so far, f.e. detecting hanging toiletts or similar. Had just one false alarm in 5 years. I also have added a ESP32 CAM .. but basically to just allow me to get a "video" or static picture from the counter (that's what the default firmware of the ESP32 CAM does). My water supplier (10 years ago) offered a special device for ~60 euro that is able to put out a open collector contact for every liter water. Imho there is a spinning magnet inside the water meter itself which they plug on. Easy way to get the "real" numbers of water usage. And btw: The "central valve" just a pure mechanical construct which uses an old cordless drill to manually close the central valve ;-) Cheers!
My new decalcification system has this feature, too. You know how I discovered it? For the tests in this project, I had to let the water run constantly for some time. Suddenly it stopped :-(
This device checks if the water flow is the same for a certain time and then cuts it...
To get rid of the glare, best is to put the camera to read at 45 degrees to the surface, but anything will see improvement. That will take the LED and bounce the light away from the camera. I thought you had to train tensorflow. Would it have better results if ran much longer to train it?
This project includes trained files. But not for my meter. Training it for only one meter would be too much effort for me.
Well, if you're storing a single eeprom variable at a time, you can always store it's complementarity, alongside it, to check for writing errors
Also a good idea. I developed this way when I had more variables to store. And often, I do not know how many variables must be stored at the end of a project ;-)
Thanks for this video. You didn't talk about training the neural net for the failed image recognition phase of the project. Did you just use a generically trained NN? The training phase of NN development will almost certainly be a really important tool for future makers. Perhaps you should take a closer look at this...
Note that training this type of numerical recognition system where the numbers always appear in the same location in a picture is one of the easiest to train because you can get immediate and unequivocal feedback on whether the NN output is correct or not. This is generally not the case, which makes training in the general case much more difficult and explains why it is such a hot current research area.
This project was trained with the German counter (and seems to work ok). Training for only one counter was too much work for me. Therefore, I did not look at it. I just hoped it would work with my counter, too.
You can use induction sensor for reading the water meter, super easy and accurate!
You are right. But the Lj1234A does not work off 5V. It needs more :-(
@@AndreasSpiess I tried 2 for my water meter and they both work although one was rated as low as 6V it still works reliably at 5V. And if you take the NPN version it will not hurt the micro because it only grounds the output. Being digital signal its much easier and reliable to work with. Costs as low as 3-4 euro from China
I have LJ12A3-4-Z/BX and PL-08N, both work at 5v, the second one I've been using for almost 3 months now
Cool project, I have something similar in mind for several months now but my ESP32-CAM boards got lost on their way to me 😁 BTW, using the VoltLink USB to serial adapter, would not require pushing any buttons for programming the ESP devices as it handles that automatically 👍
Good to know. I forgot to use it. I am an old man and have my habits :-(
Both solutions have their set of problems on which they are useful. Thank you!
Edit: I'm having a lot of fun reading the comments, so many clever ideas.
Exactly!
What about capacitively sensing the grey plate?
Looking at the design of the grey plate, I am reminded of a tunable capacitor. Is it made of metal, plastic, or since other material?
Capacitively sensing the plate might allow you to get more of an analog/positional reading, instead of a single pulse per revolution. It would also be significantly more reliable if the meter is exposed to sunlight (something that I believe the manufacturer may have anticipated).
I do not know if this plate is metal or just painted plastic. Sunlight is rare at the place it is mounted (usually in the basements). But I do not know how they do the reading and if they use a different method. As you saw, I also get an analog signal and could do some mapping. But one turn is 1 liter. That is good enough for me.
In the meantime I checked the LJ18A3-8-Z/BX sensor and it worked (one pulse/revolution). So it must be metal. Now I have the choice...
I believe it would be better to send whole image to RPI and use openCV or similar to distinguish the numbers directly on RPI
Easier to develop probably... but even more power used and additional complexity on top of what's already unnecessary complexity!
Maybe. But I am not sure if it would solve the glare problems. And probably also would need some training.
To read the metal piece you need to use LC sensor. The Hal of course will not work. And the IR in the field will going to have problems because of the moisture and the water around the meter. Using LC sensor will eliminate that problems and is very robust. Use two LC sensor to find also the rotation direction of the disk. By the way very nice video!!! I'm waiting to see one using LC sensor, there is plenty of documentation out there from ST, IT and meany more.
In the meantime I tried such a sensor and you are right, it works. Unfortunately, mine needed at least 6 volts. So I stick with IR. My place is clean and dry, so I do not expect problems. For now it is reliable.
Still nice to experiment with AI.
For the water meter, I have created one a year ago, using a hall sensor.
A few hints for those who want to create one too:
- as my meter has a metal spinning disc, a hall meter does work in my case
- I created an MQTT message from which I can update the reading after a reboot. Also, I keep track if an update was done.
- I had to use a condensor and a resistor to avoid false reading. They were rare, but completely eliminated with that small circuit added.
Thanks for the tips! Other viewers suggested avoiding the absolute count on the device and only keeping it on the Raspberry. That is what I will do. Only transfer the consumption.
I attempted a similar project in the past, reading a water meter on a rotating dial. It was a spoked wheel with many more theeth on the outside. Reading it optically worked super well, to a theoretical accuracy of a few ml per tooth. Unfortunately the water meters were replaced with ones that have only the numbers visible. I was unable to find a rotating magnetic piece, or a detectable piece of metal inside.
That is what the call "Innovation" ;-)
If the project supports training then based on your own images then it really should be possible to get perfect recognition of the main digits at least. Constructing and training on synthetic images of the digit transitions might well be reliable too. I always prefer the simple pulse counting and interval timing approaches though as they're perfect for smaller uC's such as PICs.
They offer a training possibility. But only for one meter, the effort was too much for me...
Great, thanks for sharing. "We want more" is one of the main reasons I watch this channel
:-)
Hi, thanks for amazing video, very instructive.
I have a question: why don't use a Smith trigger to signal conformation to have a 0 and 1 digital signal?
Thanks and see you next
A hardware schmitt trigger would add complications but it could be done in software with an adaptive threshold detector that was largely immune to changing bias. Andreas's approach is neat though and has the potential benefit of being able to do some error handling or error correction.
@@makers_labThanks for answer, you are right
Exactly. I wanted the sensor to be able to adjust automatically. The curve is not as neat as I showed (a sine was easy to draw) and its middle is not at 1.6 volts (it also changed with slightly different adjustments). But you are right. I most probably could have done it a little simpler. But I also wanted to be a little educational for other cases.
@@AndreasSpiess Thanks Andreas for answer. See you next
You can use the ESP32 Preferences API which is much simpler, the EEPROM API is marked as deprecated anyway :)
You are right. But only for one number, I did not think of it.
Andreas another great instruction video. I enjoyed the water usage analysis. I got thinking, you should add some control to the project and slowly reduce the available hot water after a certain time frame. The idea to minimize water consumption. Results could be water savings but …. 😉😉
We will see how this will work out. It is in operation now and I will do some analysis...
Thank you for these excellent videos. I love the clear thinking and explanation you bring to them.
So, as AI has transitioned from its early mechanistic approaches (e.g., expert systems, etc.) to the current models based on non-parametric statistics, there is also a subtle change in its successful application. The current models are more about being 'less wrong' than 'exactly right in the instance'. This is encouraged by its alignment with large number theory and other assumptions (e.g., Bayesian Analysis, etc.). Given this, we might best think of modern AI technique as most suitable as part of a 'problem-space reduction' tool that gets bolstered and completed by more traditional, deterministic kinds of algorithms, rather than as a central part of some core algorithm. AI's real mission, IMHO, is about abstracting 'the smart' from from everyday good engineering, and this will require a different kind application with different kinds of value produced. I like to think of AI as a kind 'context manager' for whatever problem(s) I am trying to understand and solve.
Still, this was a bold and valuable attempt. Bravo to Andreas Spiess, The Guy with Swiss Accent.
I only used AI for the UA-cam algorithm. Otherwise I call this use case "pattern recognition". I still think that, if we take out the sales speak, a lot of valuable "AI" is pattern recognition, sometimes on a high level.
I also never know how much programmed "expert system" is in the applications. I use a spelling and grammar checker for my scripts and always wonder how good it is. But I fear there is a lot of standard programming behind it. Even if the leaflet calls it "AI"...
I wonder if a circular polarizing lens over the camera lens would knock out the glare?
Plus a polarizer on the LED. At least this is what others suggested. Mybe I will give it a try.
@@AndreasSpiess
I just know that photographers use circular polarizing lens adapters on their lenses to reduce glare.
Hello Andreas, regarding the photo transistor, how about a Schmidt trigger to take the sinewave and generate a pulse?
That would also work if it is truly a sine Here it is only a sinusoid. And I wanted to be sure and completely automatically.
Works like a charm!!Tested it on my water meter and worked on the first try! Makes me wonder what I did wrong...🙃
Which version?
Yup, if water meters where not leaded 😉 we could glue a tiny magnet on the dial arm. Anyway there are also sold water meters with built-in pulse output, but then you had to buy it self and let register and lead it again at the water supplier.
Ours is also owned by the water supplier and we must not change anything.
Sure could have used one of these a few months ago, my water bill went through the roof. The water department told me to check if my water meter's needle was spinning, it sure was, non-stop.
The meter is now life and I wonder about some peaks, too. I will have to see where the water goes.
@@AndreasSpiess Leaking toilet overflow valve did not turn off water flow, imperceptible leak that I was unaware of until I saw that meter needle spinning.
"An engineer's work always start when something does not work"
Nice adage, thank you.
You are welcome!
How did you do the aggregating in Grafana at position 0:42? I tried "field(value) last() difference()" and "group by time(1h)". But a) this does not work for months and b) fill(previous) doesn't work, so I always have spikes like in fill(linear)
Grafana does not show the aggregations if the data is not here for the whole period.
I did not use fill(previous). It would not make a lot of sense for consumption. But I also have to try till it looks good.
using EEPROM is good but since you have connection via MQTT ( RPI ) and then to Influx DB, why not in startup get the last values from DB instead. Let the DB be your master source of data
But awesome project for sure
You could also publish with retain and subscribe to the same topic then you will be updated at startup. To be fully persistent remember to set the mqtt server to save the retain messages on disk
Both are good ideas! Then I only would transfer the consumption. Thanks.
You compared pears with apples. In the traditional approach you were able to choose the right tools and write a program to make them work. The equivalent process with such a focused AI tool is training it with your images and your labels (e.g. black background, rotating reflector, ...) After that and maybe some lighting adjustment, the camera-powered solution can be far more reliable than the traditional one (e.g. being able to recover from outage/disaster and being able to store some pictures for periodic manual verification)
Of course I compared apples with pears! And I liked apples more in the end. Comparing apples with apples often does not provide good solutions because your search is too narrow.
I know that the system can be trained. But for one meter?
@@AndreasSpiess you are right, the answer is not obvious, in the economy of such a model it is probably more appropriate to train for a class of objects, let's say the black background meters. I'm saying that a data scientist will find easier to train for your specific meter while sticking to "simple" camera hardware like an old smartphone, compared to developing a dedicated module with opto-things etc. Same things applies to your "traditional" solution if you compare it to a 40 years ago flip-flop based counter, the trend is the same, always more powerful hardware and always more easy to write software for it
Hi I lived the solution implemented by you and am trying to buld one
At 8.03 min I see you have suggested connecing 2 resistors
330 ohm between vcc and emitter
and 10K one between Gnd & Diode
What power rating should I use for them?
just small ones. Nearly no power should be dissipated if you chose the right one.
@2:07 - That trigger button made me think of one of those vintage accordion plate cameras (on a tripod/stand) which has a cord and "button" to trigger the snapshot. Maybe as a project you should make a retro version of that style camera using an esp32-cam and cord. ;)
You are right. And if I remember right, they were mechanically connected to the button on the cameras...
Very interesting. I like your solution much better than the AI solution.
I am curious why you chose to setup the reflective sensor in an emitter follower configuration. I am sure you had to tweak your LED current to come up with such a nice sine wave. Phototransistors are hard to keep in a linear region.
You are right. The curve I showed was only symbolic.
Boy this sounds like fun, wish I had time to start another project.
Maybe later ;-)
Lovely treasure boxes :) I'm affraid all we have similar number of goods at our workshops. Great idea with phototransistor. I've tried AI on the edge and after hours or experiments I have to chose another solution due to big difference between mine water counter and the example one. Great content! Appreciate your work very much.
I liked the project and was a little disappointed when I saw that my counter is hugely different... But now the problem is solved, and it works.
I enjoyed the final solution. More investigation of the camera system would have been interesting, but can't disagree with simple, low power, and reliable solutions.
Training would have solved some of the problems. But just for one meter it was too much work for me.
In situations where water meter locations usually lack access to power, is there a viable option to adapt this project by implementing RF for low-power signal transmission using batteries? The goal would be to receive these signals on a gateway and subsequently publish the data to MQTT. Thank you for the great videos and the moments of humour.
You could use a LoRa module to transport data. They have a longer range than WiFi (they are also used by utility companies)
At around 4:30, the glare problem. Can I suggest three things? 1) introduce a polarizing filter between the camera lens and the meter (this may well solve the problem), 2) Degrade the video signal to monochrome or use a monochrome camera, don't need the colour and 3) Ignore the decimal digit, it doesn't add much information but creates a lot of problems, after all the water company doesn't include this in their billing do they and it wouldn't be evident in your resultant usage graph either?.
Your tips would certainly help. But there is still the problem that I do not see all digits. I am quite happy with the current setup...
@@AndreasSpiess Yes I can see and accept that, if what you've got is doing the job then why reinvent the wheel? There is an adage that you use the simplest system to do the job. Just out of interest though, have you seen the Nicla Vision from Arduino, looks like it could do this task whilst having the electronic equivalent of standing on it's head? A bit expensive though!😁
@@icarossavvides2641 No, I do not know the Nicla Vision.
90% of what is sold as "AI/ML" is indeed a pattern recognition algorithms. Either detecting the pattern or using detected patterns to detect further anomalies. From computer system monitoring to driver assistance fall in that category.
I agree. This is why I only use "AI" for the UA-cam algorithm...
They could also be using a metal detector. i.e. An inductive proximity sensor. Alternatively, a hall sensor and a biasing magnet. Inductive proxies are good for any metal, foil if non-ferrous, while hall and magnet is only good for ferrous targets.
I am even not sure if it is metal or only colored plastic :-(
@@AndreasSpiess Even if it is metalized film an inductive prox sensor can pick it up. It just needs to be conductive.
In the meantime I checked the LJ18A3-8-Z/BX sensor and it worked. So it must be metal. Now I have the choice...
Is there any mechanism that we can measure AC voltage level, in my flat the voltage fluctuations are common and the AC stops working and gives 88 error which is during high or low voltages. Please make a video if feasible. Thanks
You can use any AC meter to measure the voltage. If you want to read it via Wi-Fi you get power meters with built-in Wi-Fi (e.g. Sonoff). They measure voltage, too.
I already made a similar video.
@@AndreasSpiess Danke
Sir I am trying to develop a similar project with IR sensor. Can you help me with the part as to how to save the waterticks to the microsdcard.
Just google for an SD example code.
Wow, great project and test of "AI" (CNN) vs reflectance counter. I wonder how effective traditional image processing would work, e.g . bitmap matching and arrow angle analysis. Probably you could have retrained the NNs and tweaked the alignment to get it to work, but that's a lot of work.
I have a friend who wants to monitor water heater status lights, and seems like an ESP-Cam would work well. I was thinking of using simple image analysis (AI seems harder). You could have written image analysis to detect the spinning disk, but you could have a low power solution (battery) with your reflectance sensor monitored by the ULP peripheral.
I could also have trained Tensor flow for my setup. But the effort was too big for me. But for other scenarios this setup could be good. Training for a few LEDs probably would be simple...
Using a correlation filter would have been much simpler to implement and probably more reliable, considering that the setup has fixed lighting conditions
I do not know why the "inventor" used this way and if he tried others.
Fascinating! I hadn't thought of using a camera on an analog meter when I went this route.
Like you I already had electrical monitoring into Influxdb (thanks Iotawatt!). So I started to wonder about water. I already had some cheap hall sensors on my outdoor water lines to verify that the irrigation system keeps our garden watered. But what about the house itself?
Here in Canada (Vancouver) we don't pay for our water, so it's not metered, so I didn't have an analog meter to start with.
Digital water meters were pricey, and usually meant for high-volume, so not very precise. Then about a year ago EKM Metering released a version of their pulse water meter that pulses every 0.283 litres. You can hardly turn a tap on without a pulse.
Plug the pulse output into a Sonoff running Tasmota, and tada! A count published to MQTT every minute.
The meters are cheap enough that I bought two: I still need to put the second one on my hot water line, but soon I'll know water the hot:cold ratio is for my shower. I have yet to convince my partner why this is useful. :-)
Indeed, it is not easy to convince somebody of the usefulness of measuring a free good ;-) That is what I call a hobby. Useless, but fun!
Andreas nice video! Why do you need the analog input. You can also use a "flip-flop" or? Do you know there are different esp-cam modules are on the market?
1. I wanted that the sensor adjusts its values automatically. The middle value is not at 1.6 volts and the curve is not a sine as I showed (for simplification). But implementing a threshold could have worked, too. I agree.
Hello Andreas, can this be included into Home Assistant, the raspberry pi project? And is the Peters Scargill solution better for home automation?
I do not use HA. My home automation is based on MQTT and on IOTstack. MQTT can be integrated in HA.
I just love your sense of humor! I cracked up when you mentioned an engineers work begins....
Glad you enjoyed it!
Really love all that amassed "treasure".
Me too ;-)
How is current consumption of the ESP version with battery support ?
The battery only will be for backup. It consumes around 100mA.
what about placing a piezo sensor to the water pipe? when there is a flow it should create some vibration and with some calibration there may be good results :)
These counters are precise (because they are part of a contract). So I would not want to invent what was already invented (and paid and installed) ;-)
Just in time, been on my list for a few months now. Next : eBus from Vaillant 😉
If it is not encrypted...
Where I am at water meters transmit its readings wirelessly. Do you have to get your reading manually for billing???
Yes, once per year.
@@AndreasSpiess Interesting system of billing for water once a year.
In the past I heard hair spray may help to avoid reflections.
I would not want to try it because I do not know what it would do with the plastic and if it could be removed later. And I need the counter for the next few years ;-)
I use hairspray for my 3D printer, BTW. But on a metal plate.
pretty much all out water and EL meters here, have an IR LED under the clear cover, so that the 'meter man' can simply place a reader on top to take the reading, eliminating human errors. Well that was until recently, now the wast majority of our meters have been replaced by IoT meters and read online anyway.
We are old-fashioned here. I as the owner has to read the meter once a year and send this info to the community. Water here still comes from them.
@@AndreasSpiess Funny enough our meters in the middle east are Landis+Gyr :)
I have an IR sensor module do you think it would work with this code or should I go for cny70 only ?
You have to do your measurements. But I assume it should work with the right resistors.
@@AndreasSpiess Thanks sir Do I take that WaterMeterV3 code is the most accurate and updated code to work with?
Found a typo in the red banner: "AI vs Tradtional" - should be "Traditional" (missing an i)
Thank you. Corrected
What kind of Hall sensor did you use? Linear or digital one? That plate is plastic or some metal?
Now I checked again. It is metallic but not magnetic.
@@AndreasSpiess Linear Hall sensor (like EG49A) could potentially detect it. Digital Hall sensor (like GH1248) is useless for this.
The LJ123A works, but needs at least 6 volts...
Hi Andreas.. as usual solution is generally simple..when sought out. AI is needed where normal I wont work ;).
Btw.. i have been playing with this cam since quite a while. One way to reduce glare is 3D print diffuser.. other control intensity, lastly as you did rightly.. external LED.
But my major challenge is... how do we get rid of that glue.. never managed to remove or losen that focusing lens... any thoughts?
I used one of my sharp knives and had no problems. Maybe I was willing to sacrifice one and used a little force ;-)
Hi, did you try a capacitive sensor? That semicircle looks metallic
No. It worked and I was happy ;-)
In the meantime I checked the LJ18A3-8-Z/BX sensor and it worked, too. So I have the choice ;-)
Hello Andreas, why don't you use visual micro or platformio, I am sure it would be really fun.
For the channel I use the Arduino IDE because everybody has one. I made videos on both other possibilities.
Maybe take photos from the ESP32's camera and send them to a more powerful computer (Raspberry Pi). There do the AI processing and then send the results to a database to later be able to see the data using Grafana.
That is a good idea!
There are ultrasonic clamp on sensors available who measures water flow by the doppler effect. Didn’t have such yet, but would be my way to solve. Maybe they can be DIY build with transducers?
I think I have such modules in my lab (i was fascinated when I saw them). But I always wondered how they can do this through metal tubes (here everything is metal at the entry of the home.
@@AndreasSpiess solid iron pipes here too. I think they couple trough, like a stethoscope work. But i donno, cause i dont have such to goof around with it. But this would be a very interesting topic right now on grown energy costs and everybody will cut expenses.
Can you give me a recommendation for such sensors and wich to buy?
I never used these sensors. So I cannot recommend anything :-(
I can only connect my esp cam to the programmer with the jumper on 5v. 3.3v causes connection issues.
I do not power the ESP32-cam with the USB-Serial adapter.
Thanks again for a very interesting and informative video. So many valuable nuggets of valuable information from a seasoned engineer ! If your wife had so many stashes youd probably call her a hoarder :-), so its ok if she is cleaner than you. So the AI solution you found is quite brittle, it breaks when bent to a slightly different problem. I also thought it would be straightforward to take images of my oil tank level and automatically remind me when to reorder ... 3m later Im still going into the basement to read the guage directly. Yes the ESP32-CAM is an amazing device, but requires work to do real-world tasks different from any open source available. Introductory solutions can be found with only 50 lines of code, more featured ones are several thousand lines of rarely commented code.
I made a video about pressure meters where many viewers reported that they use such a sensor for their oil tanks...
Instead of using a magic number which overcomplicates things, store the crc of the number or some other calculated value based on the reading to be saved and check for that instead.
Thank you for the tip!
Great, so now you probably can detect leaks to command valve to close.
Should be possible. This is done by my decalcification machine.
Hi! Can you make a video for water level monitoring through ai camera..it will help a lot..thanks
I have no such plans. However, I made two videos about "standard" water level measuring.
@@AndreasSpiess thank you..
hello in order to improve IA result, in your cas you could try to nomalize input image in a different way to help neural network in his recognition work, binary color and gaussian could be a start.
you can try to treshold you pixel value range, over a long time (find min max, of a pixel zone)
Add physically some light reflector to help with changing luminosity.
may i suggest you to try tesseract in python, quite effective
I only have one meter and only tried this project because it already had a trained model. I agree that your proposals could solve some of the issues. But the effort would be too high for me.
where did you get the power source for the esp32-cam, sir?
Usually from AliExpress
Great video as always 👍😀
Great tricks
Thanks for sharing your experience with all of us 👍😀
You are welcome!
Straight to the point, as always!
State machine rulez 😁👍
Indeed, I like this concept!
Excellent and attractive approaches ❤
Thank you!
Noce way to solve the problem!
However I'm not sure why you hadn't just used current analog check since it's metal plat, you can print a simple adapter and it would work like a charm.
Moreover you can else just glue a tiny magnet and use magnetic field sensor using i2c ( not hall sensor ) which should be a bit more reliable.
There's a video somewhere who explain Tesla door, they do something similar but with door. :)
If you cut a hole in the meter to put a magnet onto the disk the water police will have you for meter tampering.
Indeed, the meter is not mine :-( And I am quite happy with my solution. This sensor does not cost a lot if I remember right.
If you like to use ai, than you can use Edge Impulse and explore se AI (pattern recognition).
It is a greater start to explore this topic for beginners.
An easy sensor is an Gyroscope.
Maybe you are interested and give it a try.
I know Jan, the founder... But I needed a trained project for my meter. I would never have tried it if I had to do the training. Too much effort for one meter :-(
Sali Andreas, ich feiere echt all deine Videos, genial - mach bitte immer weiter so! Zum ESP32-CAM mit AI on the edge watermeter Ansatz kann ich Dir berichten, dass dies bei mir erstaunlich gut funktioniert. Vielleicht wurde mittlerweile der Algorithmus auch weiterentwickelt. Mein Wasserzähler hat ebenfalls weisse rollierende Buchstaben auf schwarzem Grund, und die werden recht zuverlässig erkannt und interpretiert. Ebenso die analogen Zeigerchen. In Home Assistant sehe ich per MQTT präzise den Wasserverbrauch. Das Gefummel bis Kamerabild und Licht stimmten, war aber schon e chli en Murks.. :)
Vielen Dank für deine Rückmeldung. Ich weiss nicht, ob sie etwas geändert haben.
"An engineer's work always starts when something does not work, the other things can be done by the MBA's". That hits harder than it should hahaha, preach!
I am an MBA, too. So I thought I can say this ;-)