This is my first Arduino project, and I am trying to do something very simple but it's just not clicking, even after watching videos and reading. I am trying to create a water tank with a level sensor that turn on a pump motor when the sensor gets low and turns it off when it is high. And this I got working well. But I also want to have a safety sensor that will override what the other sensor is doing and turn the water off so there is no chance of overflow should the first water sensor ever fail. I am testing on Tinkercad and on my Arduino/IDE.
Thanks in advance.
const int waterSensor=12 ; //tank water sensor
const int waterSensorS=11 ; //safety water sensor
const int pumpMotor=2 ; //waterpump
int switchState=0 ;
int sensorValue=digitalRead(waterSensor);
void setup () {
pinMode(pumpMotor,OUTPUT);
pinMode(waterSensor,INPUT);
pinMode(waterSensorS,INPUT);
}
void loop () {
switchState=digitalRead (waterSensor) ;
if (switchState==LOW) {
digitalWrite(pumpMotor,HIGH) ;
switchState=digitalRead (waterSensorS) ;
if (switchState==LOW) {
digitalWrite(pumpMotor,LOW) ;
}
else {
digitalWrite(pumpMotor,LOW);
delay(5000);
}}
Safety circuits are done in hardware, not software. Put in a NC overflow switch that cuts power to the pump and/or opens the spill valve. Its called a "safety" circuit because it operates when all else fails.
Keep in mind that the Arduino is completely inert and unresponsive while executing delay(). Avoid using delay during critical tasks.
Finally, as already mentioned, if the pump controller is stuck ON for any reason, the only way to stop the pump is to disconnect the pump power source. A completely independent float switch could serve that purpose.
Personally, I’d put the safety switch before the high-level switch.
That way it has no reason to turn the pump on if the level is already at the overflow point.
Please post a pic of a hand-drawn wiring diagram, with pins, connections and parts clearly labeled. Also, post links to the pump, pump power supply and pump controller.
When you physically build this system, HOW will the tank be filled? From the bottom, the side, or the top? IF from the top. waves and splashing will make the limit switch rapidly go on and off.
It will be filled from a tank sitting on the floor below, the water is pumped up with a small 9v .5A submersible pump, because of motion was the reasoning for the 5 second delay to engage the pump.
I was initially going to try Wokwi but it didn't have motors or other items I thought I could use so I went with Tcad instead since it had more options. Here is a screenshot of what I have.
Yes but Wokwi doesn't have external power supply's or battery's either and I don't want to power everything from the 5 volt source. I tested several simulators and it's just too lacking to bother with.
I don't particularly like Tinkercad either but it fits my need best for this project.
Hi,
Can you please draw a proper schematic diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.
How have you got your switches wired?
If you are switching input to 5V, have you got a 10K pull down resistor on the input pin to gnd?
If you are switching input to gnd, have you got a 10K pull up resistor on the input pin to 5V?
You cannot leave an input pin open circuit and assume it is at gnd.