Replacing a mechanical pressure switch with a digital one (for owners of wells)

When I first encountered in order to adjust the mechanical pressure switch with springs, I realized that I needed a call to a friend, or rather to my father, because the mechanism, though well thought out and fault tolerance at a high level, is lacking even a one-off adjustment on the face .



image






image






I ask under the cat, there is interesting;)



I sort of figured out and I even managed to adjust, but I spent time and nerves on this. Then I realized that the digital relay would be great, just pressed the buttons and set the right one. Of course, many can condemn me on several articles:



- you are a fool that you can not deal with the simplest pressure switch and two springs.

- the mechanics rules, it will work forever.

- why is there something to regulate: once a plumber set up for XX * (the course of the country) rubles and all



No problem, you can continue the list for a long time, but by the nature of your engineering, I would like to develop and improve everything around you, and not twist the springs and think when the contacts of the mechanical relay are burning there and the thermal protection relay of the pump starts when you are all covered in soap: D, and even better is your wife :)



I must pay tribute, the mechanical relay has been working for me for the fourth year and with it (pah pah pah) Nothing serious has happened so far, just had to rebuild, clean the contacts, started to spark and these “SHELK!” In the garage were a little tense and… scared my little mouse, so that he had to escape.



The escape




Since I enjoy automation and have gone from 1-wire to arduino through esp, I can and do various crafts in the house, more precisely, devices, to facilitate life. The circle of friends knows about the list of projects that I try to complete and implement, but there’s no time at all. That construction bath will turn up for the whole summer (750 hours), then the snow will pile :), and here New Year is coming!



image






Many people also “love” to gossip me, especially from the IT sphere. But it only fun, life is an interesting thing and without it in any way. Also, many thanks to all those who support me - without your kind words, the drive would not be the same. Thank you my wife for understanding the love of my motherboards)



From the lyrics, jump into reality. I turned in search of a digital relay and realized that it was very difficult in this direction, either foreign under $ 100 and not at all as I would like ... either a $ 15 mechanic. I bring in $, as it has long been known, if we switched to $ - even the grandmothers did not steam, as with coins. And I'm such a scoundrel - the house is connected to the Internet, but the pressure switch is not - crazy!



Theme for trolls: I started working with Arduino of Chinese origin, not original, but Chinese, they work the same way, where there are minor errors, but they don’t touch me so much to spew negative lava and shake esp8266, which dies faster than static you will plug it into your computer, and with 3.3 power supply, which you need to go and find), if it is not only the NodeMCUs that I adore.



I love both esp8266 and Arduino and people, but in order to sit down like this quickly assemble a working and STABLE device for automation - arduino is an indispensable thing + Wiring C-shny language really helps to quickly realize what is required. (no one here will reproach that you wrote in the scripting language Lua). esp8266 (my opinion) - good where you don’t need to measure the ADC and need the Internet. Although its “combustion / dampness” is very disappointing.



We return to our sheep, that is, the relay :)



As a result, I found in China a sensor for $ 5, with an ADC of 0-5V and decided to try it. Even not so, I stupidly caught fire to use it and assemble the device. Immediately went wild erotic fantasies, as LEDs will blink) and press the buttons to adjust, and on the Chinese iconic blue screen will be cherished tsiferki and it will all work with real pressure in our comb.



Pondered, described, drew, planned, ordered and began to write code, until the erotic was gone from thoughts.



When the sensor arrived, I realized that the sensor was very well made.



image






Further, I realized that it starts to show data not from scratch, but from 0.5V to 4.5V. from 0 to 12Bar. I was very happy, because I was pleased to realize the singularity of this device, you can track when the sensor dies and will not show the coveted 0.5 at the output.



Insertion of the sensor into the current system, leaving mechanics “just in case”.



image






One thing is sad, there was no data on the sensor, how to cheat its readings, but since there was a linear straight line on the graph, I had to (I am ashamed, but I confess) to open the ALGEBRA textbook and learn anew, to remember how they build a direct linear relationship in :) on two points and a miracle, I quickly got (you can shame me) a cherished simple formula, in which, after converting the ADC signal to VOLTS, I understood how much pressure I had in Bar. Since the sensor itself produced from 0 to 1.2Mpa, it is not difficult to transfer to Bar - knowing that:



1 Pa = 1.0E-5 bar

Ie 1200000Pa = 12Bar

Since we have pressure from the pump does not exceed 4Bar - this sensor is enough for the eyes!



Then I took the Arduino Uno - it lay in my spare, I usually use it for quick attachments to design, check, and then use the Arduino Nano, since it is deprived of the left body kit and its size is 3 times smaller! And may arduinschiki of Chinese origin forgive me, it was a pity for me to watch how she was lying idle, we need to put it into the device! I thought and bought a small plastic IP55 box, drank a hole for the screen, which I bought 4 years ago! Charles! And then I did not guess that this LCD 16 * 2 would go into such a useful business. I took 2 auto buttons on the car market, soldered the wires, I didn’t even design the board separately, as I do for the Nano - since Uno is stupidly big and not at all for such purposes.



image



The algorithm is quite simple and is still undergoing field tests, the project code for closer inspection is located here .



I am not ashamed to lay it out, if there is constructive criticism, I am ready to make changes, since it is open for any discussions.



I tried to put the following principles into the algorithm:



- Initialization of data: at startup, all variables for operation are checked and initiated

- Primary interrogation of the sensor: checked if the sensor has not failed (in the event of an exit, just in case the pump-relay is cut down) data are calculated and transferred to the current pressure in the comb (distribution comb, to which the neighbors are connected + arrival from the pump + accumulator) if everything is within the lower and upper set pressure, then we continue to listen and calculate the data

- The data is displayed visually on the screen as:



lower pressure - current pressure - high pressure

pressure drop index - [blocks, show system pressure]



This allows you to quickly assess the situation that is happening.



image



- If the current pressure is below the DOWN: the 15A solid state relay (checked for years) is turned on and the pump quietly, quickly, without sparks and clicks, turns on and supplies water. UPPER pressure disconnects the relay. The pump will never turn on and will necessarily turn off if there is something with sensor readings that go beyond what is reasonable. This is safety.



- I calculate the pressure drop index when half of the pressure remains in the comb and every 10 seconds the previous and current is checked, if the difference is less than the default value of 0.05 - then the current index changes and the pump turns ON FORWARD, then the water is fast, and that to predict the inclusion of the pump, I use this logic. The logic does not work yet at 100%, since I am still testing this moment, there are flaws related to millis () timing of Arduin itself, here it is a little annoying for me, but I will find a solution for a clear calculation. The logic is triggered at the beginning, and then the index drops to 0.01 and the logic no longer works, but this does not affect the on and off of the pump. Here you can holivarit on the topic “the pump should turn on a certain number of times per hour and no more” - you have the right to do so), I will not argue - this topic is being analyzed.



- there are side buttons that allow you to set the LOW and HIGH threshold to turn the pump on and off DYNAMICALLY, without rebooting, just stupidly on the fly - look at the screen and press the side buttons…. convenient-on! the data is immediately written to the EEPPROM and when the block is turned on, it is loaded from there (it is such a permanent memory for writing numbers from 0 to 255 byte type, a little but enough for minor whims). At the same time, there is a moment that the floating point numbers are so difficult and hemorrhoid to write that it was simply decided on my part: knowing that the number x.x0 is a pressure of float type, it can be easily converted into byte if multiplied by 10 and write to memory, ie: example: 1.80 * 10 = 18 - after multiplying the number, float discards the last zero automatically and we get a number that fits into the type byte, when reading, we divide it by 10.0 and get the inverse form for our system and type float.



- All the good will be available for "reading only" outside the home, which will allow you to understand the situation with the pressure not only arterial, but also in the pipes!



image



Well, everything seems to be, I'm sorry, who is strained by the details of the code, wacky TYPES of data and intimate details of loading data from memory, skip it, because, knowing that there are people from the IT sphere, they will ask all sorts of questions or, on the contrary, laugh from my simple algorithms that do not use trendy AI \ ML and other mega cool and big data algorithms. Hopefully, the engineers will also understand other parts related to the mechanical part.



In general, the conclusion is: you can do everything, you can do it easily, do it in interest and as one of my favorite commentator once said: you can be an adult and “play with children's toys”.



image






field trials




Your cap, automator, capable guy and good day to you!



Weeds:



- I continue to test the pressure drop index for premature start

- Arduino uno (China) - problems with the millis timer () have emerged - I will check for arduino nano (there was no such thing before, I assume a curve model) (I didn’t order it, so I don’t))

- The error is stated 1.5% - from 1.2Bar - this is 0.18Bar - to the fact - I have somewhere around 0.3 relative to my manometer, but I do not know how much he is lying ... therefore 2% admit the error max - you can put in the algorithm (as I do) the error And it will be more or less like the truth. Do not launch satellites - come down)



upd: the price tag in the region of $ 15-18 was the total for the product.



Happy New Year! May all your plans come true, BANI will be built, there will be HEAT in the house and all your friendly family will be with you! Let the new year be only good news.



All Articles