Forgive me I am having a brain fart and cannot think of a good way to code a script to sense pressure values from a 100 psi sensor and when it goes below 30 psi a digital pin will go high and when 40 psi is reached that digital pin goes low.I know this should be a simple thing but I just cannot remember how it's done so any help here would be appreciated greatly
I have a few Arduino nanos and unos and also some of those Wemos D1 boards with the esp wifi radios on them also which IMO may be better suited for this since it has only one analog GPIO and a few digital GPIOs.
I am not good at choices. Make a wiring diagram of your intended devices, and we'll go from there.
Something like this?
add the sensor and the setup code and maybe some loose ends.
void loop()
{
float pressure = sensor.getPressure();
if (pressure < 30) digitalWrite(pin, HIGH);
if (pressure > 40) digitalWrite(pin, LOW);
}
I guess pin should go LOW again only when it was HIGH before and psi is over 40.
So a an additional bool var could track that which is set when psi goes below 30.
we have those switches and they keep failing and there is no failsafe or fall back currently for when the pump stays on which does happen due to leaks out in the water system or the current pressure switch sticking.
If your sensor outputs analog voltage and wifi can offer you some advantage, that would use resources quite well.
Which sensor? What type of signal does it output?
I’ve seen those switches fail as well, but it was due to a design fault where the switch was overloaded or undersized for its application.
The Arduino will do what you need, but you'll have to protect it from the environment. I like the D1 boards; I have a bunch of them, and aside from a few minor errors on my part, they’ve been great. Just be sure to check the I/O pins, as they aren’t always what they initially appear to be. I’m running CAN and I2C on one without any problems.
I'm guessing either poorly sized switches or environment it is working in to be the reason for the now failing switches.
Environment is the main reason, the other reason is people sticking things in them to keep them open or closed/.
In America, we have a saying "putting lipstick on a pig". Meaning you still have a pig, no matter what you do to beautify it. You a have a badly designed water system and no matter how you do something to it you still have a badly designed water system.
Fix the whole system so it works properly for years and you will all be happy and will be less expensive in the long run.
Yes it is a bad system but I am not the owner of it, I was merely called upon to analyze the boost pump situation nor am I a plumber, My field is Electrical, electronics, control systems, and RF.
The owner of this disaster comes off as a slumlord type cause the type of tenants he has are some shady types indeed..
IDK I think I'm going to gracefully decline this job due to the fact that everything in this system is janky AF, dangerous and The chance's of me actually getting my invoice paid in full is slim. Just a feeling I have but I am fairly certain that there is an active meth lab nearby if not on this property and I dont desire getting inadvertently wrapped up in a drug bust while working on this PVC nightmare. Besides that I can see the invoice payment being drug out for months.
