Here is the rewritten article:
I tried, while using an extension the sensor always spat out garbage values. So I am not going to try reverse engineer this black magic wire and instead keep it simple by grabbing my backup sensor and using an extension cable at the driver board side which I of course tested and it works perfectly fine.
So I grabbed myself a small water resistant junction box that is so small that it fits inside the tube, but big enough so that the driver fits inside snugly. Next I pushed the sensor wire inside there and added a cable bushing on the other side through which I pushed my CAT 7 extension cable. And after wiring everything up and closing it up, it was time to design an enclosure for the sensor and 3D print that with some PETG filament.
And then it was finally time to do the installation inside the cistern which means mounting the enclosure, pushing the sensor in there and then pushing the wire and ultimately the junction box inside the tub which worked out beautifully. Last but not least I connected the driver board extension wires back to a microcontroller to make sure that everything still worked and it did.
Now at this point we could finish this project quickly by simply adding an LCD and calling it a day. But since I recently created my own Home Assistant Smart Home Control Screen, link to the video in the description, I would love to present the water level value on there. To do that I grabbed myself an ESP microcontroller, flashed the ESP Home firmware onto that and then hooked it up to the driver board according to this wiring diagram.
Now the great thing is that ESPHome which is an application for Home Assistant actually supports this ultrasonic sensor. The only bad thing is that I had to fish out the driver board out of the tube once again in order to add a 47kohm resistor here to enter mode 4 which is mandatory to make it work with ESP Home.
But with that out of the way; I wrote a bit of code for my ESP board, uploaded that and thus pretty easily got the water level values I was after. That means it was time to finish my project and to do that, I installed some conduit in my garage in order to guide the extension wire to my big distribution box.
Inside there I then added an enclosure for the microcontroller as well as a 5V power supply to power it all. And by the way even though I feel like a broken record here, I have to say that working with such mains voltage can be dangerous and should only be done by professionals. But anyway after the initial wiring was done, I did a small test which turned out successful and thus put the microcontroller permanently in its enclosure prison and just like that my niche project was complete and functional.
And when we do the math and include everything that was required for my DIY version then I would say that the price is not too bad. Now comparing my DIY version to a commercial version is not simple to do though because it is very customizable when it comes to the hardware and software side. But when we compare it to average WiFi solutions out there, then I certainly saved quite a bit of money there.
And I think that is the beauty when it comes to such niche electronics projects because if you have some idea of what you are doing then you can certainly save a bit of money while of course investing a bit of your time. And that is why the winner for me this time is definitely DIY. But what do you think? Let me know in the comment section below.
As always I hope you enjoyed this video and if you want to see more then consider supporting this how on Patreon. Don't forget to like, share, subscribe and hit the notification bell. Stay creative and I will see you next time.
WEBVTTKind: captionsLanguage: enSo here is the thing; if you have a need for something nowadays then you can pretty easily get your hands on a perfectly fitting product which can be for example a video door bell or wireless temperature sensor or something else. But sometimes your need or problem is so niche, that there is no good buy option out there. Case in point would be the cistern in my garden which is basically a huge reservoir put into the ground into which all the rain water from my roofs flow. As you can see it is filled to the brim right now and since there is a submersible pump in there, I can simply power that and water my garden with rain water which is pretty awesome. Only problem is that I have no idea how much water is left in this reservoir meaning I need something like a water level sensor.But no matter how long I searched online, I could either only find not suitable options or way too expensive ones. So in this episode of DIY or Buy, I will not only show you why available buy options sometimes kind of suck, but also create my own DIY alternative which will hopefully be functional and a lot cheaper.Let's get started!This video is sponsored by JLCPCB who are currently running a promotion meaning you get a $20 discount for their 6-Layer PCBs including free via-in pad and free 2u ENIG finish. And in case you are wondering what via-in-pad means, then let me tell you that you can literally place vias directly in pads which shorts traces, saves board space and solves routing challenges. So give them a try. Other than that JLCPCB is still holding their Mid-Year-Promotion; so click the links below to get a chance to win awesome prizes and coupons worth up to 250$. Don't miss out on this! Now first off let's have a closer look at the buy options and here it seems like they are either using an ultrasonic sensor or a hydrostatic sensor. And let me tell you that the latter one really feels like high quality with its stainless steel sensor head and rather heavy weight.The idea of this sensor is that it measure the underwater pressure which gets bigger and bigger the deeper the sensor goes. My version here outputs 0 to 3.3V over a range or depth of 2m which equals around 0.165V per 10cm. To verify that, I powered this thing with 5V and then had a look at the output pin. And yes; it seems to be pretty accurate and due to its heavy duty construction, it is often used for industrial applications or with more aggressive liquids. That is why such a sensor is not really cheap and therefore products that come with it are obviously also not cheap.But thankfully there are also these ultrasonic sensors whose non waterproof alternative is pretty popular I would say. The way this works is that one of these speakers sends out a 40kHz Ultrasonic Wave which bounces back once it hits an object and the other speaker then notices that. And since we know how fast the sound wave travelled and how long it took to return, we can very simply calculate the distance to the object.I mean it is so simple that such sensors are often included in Arduino beginners kits and the wiring for them is done in seconds as well as writing a short piece of code for them. And by doing some testing here, I can say that the measured distances are pretty accurate and definitely good enough for my cistern which by the way works with this sensor because water also reflects the ultrasonic sound wave.But of course when it comes to water, then we should use this waterproof ultrasonic sensor which now only comes with one so called transducer that can obviously acts as a transmitter and receiver. And wiring this one up is pretty much the same deal as before; I mean we can even use the same code and get pretty similar good results; except that this time the minimum distance is 20cm. And best off, this sensor is dirt cheap in comparison to the one before. But when they are featured in products, then they are either too expensive if I want a customizable wireless solution or they want me to mount it in some place weird. So can we DIY a solution?To find that out, I firstly had a closer look inside my cistern and realized that at a water level of 94cm, the reservoir is at max capacity with 10.000L.I also found this removable screw here which is a perfect spot to mount the sensor and at a height of around 30cm above the max water level, it should be in range of what the sensor can do.That means a distance of 30cm would represent 100% water and 124cm would represent 0% water left.And luckily for me I also got a tube here through which the power wire for the pump travels into my garage and needless to say there is lots of space inside this tube that we can use.So next I pushed a string in there in order to ultimately determine what distance the sensor wire has to bridge and as it turns out it is around 3.3mSadly though the sensor wire is only 2.5m long; but no problem for me is what I thought; I can simply extend that. Yeah; long story short extending the ultrasonic sensor wire is not easily possible. I mean I tried two different types of shielded wire with thick enough conductors and got as close as possible to the sensor itself as well as the driver board. But not matter what I tried, while using an extension the sensor always spat out garbage values.So I am not going to try reverse engineer this black magic wire and instead keep it simple by grabbing my backup sensor and using an extension cable at the driver board side which I of course tested and it works perfectly fine. So I grabbed myself a small water resistant junction box that is so small that it fits inside the tube, but big enough so that the driver fits inside snugly. Next I pushed the sensor wire inside there and added a cable bushing on the other side through which I pushed my CAT 7 extension cable.And after wiring everything up and closing it up, it was time to design an enclosure for the sensor and 3D print that with some PETG filament. And then it was finally time to do the installation inside the cistern which means mounting the enclosure, pushing the sensor in there and then pushing the wire and ultimately the junction box inside the tub which worked out beautifully.Last but not least I connected the driver board extension wires back to a microcontroller to make sure that everything still worked and it did.Now at this point we could finish this project quickly by simply adding an LCD and calling it a day. But since I recently created my own Home Assistant Smart Home Control Screen, link to the video in the description, I would love to present the water level value on there. To do that I grabbed myself an ESP microcontroller, flashed the ESP Home firmware onto that and then hooked it up to the driver board according to this wiring diagram. Now the great thing is that ESPHome which is an application for Home Assistant actually supports this ultrasonic sensor.The only bad thing is that I had to fish out the driver board out of the tube once again in order to add a 47kohm resistor here to enter mode 4 which is mandatory to make it work with ESP Home.But with that out of the way; I wrote a bit of code for my ESP board, uploaded that and thus pretty easily got the water level values I was after.That means it was time to finish my project and to do that, I installed some conduit in my garage in order to guide the extension wire to my big distribution box.Inside there I then added an enclosure for the microcontroller as well as a 5V power supply to power it all. And by the way even though I feel like a broken record here, I have to say that working with such mains voltage can be dangerous and should only be done by professionals. But anyway after the initial wiring was done, I did a small test which turned out successful and thus put the microcontroller permanently in its enclosure prison and just like that my niche project was complete and functional.And when we do the math and include everything that was required for my DIY version then I would say that the price is not too bad. Now comparing my DIY version to a commercial version is not simple to do though because it is very customizable when it comes to the hardware and software side. But when we compare it to average WiFi solutions out there, then I certainly saved quite a bit of money there.And I think that is the beauty when it comes to such niche electronics projects because if you have some idea of what you are doing then you can certainly save a bit of money while of course investing a bit of your time. And that is why the winner for me this time is definitely DIY. But what do you think? Let me know in the comment section below. As always I hope you enjoyed this video and if you want to see more then consider supporting this how on Patreon.Don't forget to like, share, subscribe and hit the notification bell.Stay creative and I will see you next time.