I am trying to make an automation controller with Arduino to fill and discharge a water storage tank. I am new to programming and need some guidance. I plan on using a submersible level sensor as my AI and control a relay board module to open a solenoid valve to fill and close when sensor senses tank is full.
Then, using a pressure transducer to control a signal to a VSD to power a water pump to discharge from water storage tank. Just a basic Start/Stop signal to call for VSD to run between a pressure threshold.
Can this be done with Arduino? I am not sure out to start or how to begin the programming, if its even possible. Any help is appreciated. TIA.
I would start with some of the provided examples and some basic examples for controlling a relay. Look for examples around the sensor you want to use and try them. After several simple learning projects you'll have a good idea where to start on the more complicated thing you want.
The level sensor is a 2-wire 24VDC, 4-20ma and the pressure transducer is a 3-wire, 0.5-4.5V. I plan to use a current to voltage converter module for the level sensor.
You may need a second solenoid valve to stop siphoning of the tank water when the pump is turned off. Do you have any safety controls when the tank filling doesn't work and the pump runs out of water?
Good. Which controller are You using? 5volt logic or 3.3 volt logic? (Vcc)
Feed the current through a resistor that has the value of 3.3/0.020 = 165 Ohm, or 5.0 / 0.020 = 250 Ohm. Connect the sensor signal line to an analog input and the resistor other end to GND.
So, I've been digging deep into this and haven't done any conversions for sensors, yet.
But I've been testing the code through a simulator and having issues with the loop.
I suspect it has to do with the delay in the serial printing but then level goes low, alarm appears, and pump digitaloutput goes out.
When put into the simulator, it has a blip and digital output (relay1) turns on then off. I want it to stay off while in "alarm". Any advice how I can fix this or suggestions? Again, still learning. Thanks in advance!
const int lvlSensor = A1;
const int relay1 = 8;
const int presSensor = A2;
const int relay2 = 7;
const int alarm = 13;
void setup() {
Serial.begin(9600);
//relay and sensor outputs
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(lvlSensor, INPUT);
pinMode(presSensor, INPUT);
pinMode(alarm, OUTPUT);
void loop() {
//serial printing for analog inputs readouts
int lvlSensor = analogRead(A1);
Serial.println(lvlSensor);
int presSensor = analogRead(A2);
Serial.println(presSensor);
delay(2000);
//if Tank Level is below 25%, then alarm goes off and Pump is Off until alarm clears
if(analogRead(A1) <255) {
digitalWrite(13, HIGH);
digitalWrite(8, LOW);
} else if (analogRead(A1) >255){
digitalWrite(13, LOW);
}
}
How do I go about doing that? I'm not familiar with all the functions. Could you point me in the right direction to do some further research? Thank you for the suggestion.
You want it to stay off in "alarm". What is alarm and where is it set and where is it reset? What is "alarm" in your code? Include the "alarm" status before deciding to turn on the pump. Likely there are NO FUNCTIONS involved!
I will try to explain what I'm trying to do. If it would help, I can send the whole code of what I have so far.
I'm taking an analog Input (A1), reading and printing the information. When A1 gets below 25% value, it goes into alarm (turns on a buzzer on a DO) and also turning off A1 at the same time. When it reaches above 25%, Alarm is off and pump is back on.
What I have so far works, somewhat. My question is... when I put it into a simulator to run and test the code, the output for Pump (A1) turns on every, I'm assuming every 2500ms, due to the delay in the serial printing readout. Adjusting the delay doesn't work. And I've been trying to code BWD for the serial printing but failing to make it work properly.
I want it to stay off, completely, until the value reaches above 25%. I'm just trying to wrap my head around where I'm going wrong with it and If there's a better way to command the alarm.
//serial printing for analog inputs readouts
int lvlSensor = analogRead(A1);
Serial.println(lvlSensor);
int presSensor = analogRead(A2);
Serial.println(presSensor);
delay(2500);
///if tank level is below 100% (pump on), if level is greater than 25% (pump off)
if (analogRead(A1) < 1023) {
digitalWrite(8, HIGH);
} else if (analogRead(A1) > 154){
digitalWrite(8, LOW);
}
///if Tank Level is below 25%, then alarm goes off and Relay1 off
if(analogRead(A1) <255) {
digitalWrite(13, HIGH);
digitalWrite(8, LOW);
} else if (analogRead(A1) >255){
digitalWrite(13, LOW);
}