Float controlling AdBlue pump + magnetic switch for heating. Possible?

Hello! I am working on a school project which just got a bit more complicated. I have zero experience previously on electronics but this has taught me a lot, with lots more left to learn. My father is an oldschool coder so helped me a lot too.

Basic principle of the project is:
-24V system in a truck for power.
-Pump liquid from main tank, to a smaller tank.

Pump I am using is Facet 40304 fuel pump.

When the liquid level in the smaller tank reaches the low level, Arduino controls the pump on, and when it fills up, shuts it off. Repeat this in a loop. I’ve based this idea around how surge tanks works in a race car. Shown in this GIF I made:

I followed this schematic I found on the internet for the breadboard(Although I don’t need the LCD for final version):

My code at the moment:

#include <LiquidCrystal.h>  
int level1=A1;
int level2=A2; 
int motor=6; 
int a;
int b;
int r; 
int z=111; //  0...1023, (111/1023)*5V=0,50V

 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 

void setup()
{
pinMode(level1,INPUT); 
pinMode(level2,INPUT);
pinMode(motor,OUTPUT); 
lcd.begin(16, 2); 
lcd.clear();
}

void loop()
{
r=digitalRead(motor);
a=analogRead(level1);
b=analogRead(level2);

if(b>z) //top sensor out of water
{
{
digitalWrite(motor,LOW);
}
lcd.setCursor(1,0);
lcd.print("100% FULL");
}

else
{
if(a>z) 
{
lcd.setCursor(2,0);
lcd.print("33% FULL");
}

else
{
{if(a<z) // all up from water -> lcd prints EMPTY -> pump on
{
{
digitalWrite(motor,HIGH);
}
lcd.setCursor(3,0);
lcd.print("0% FULL");
}

}}}
if(r==LOW)
{
lcd.setCursor(0,1);
lcd.print("PUMP (OFF)");
}

else 
{
lcd.setCursor(0,1);
lcd.print("PUMP (ON)");
}
{
delay(1500); // arduino refresh rate in milliseconds
lcd.clear();

}}

This one works fine, but now we found a float unit that is perfect for real world use:



Since I live in Northern Europe where winters are cold, the AdBlue needs some sort of warming to keep it from freezing (Freeze point for AdBlue is around -11°C / +12 F).

The good things about this pump:
It’s designed for AdBlue which dissolves most metals and plastics. Has a float in it with 5 “rough” steps of measuring (resistance value change is not linear). I measured them with a multimeter @20kΩ setting and the results are:
-Lowest point: 0,25
2/5: 4,90
3/5: 9,40
4/5: 13,10
Highest point: 16,20 (these have to be multiplied by 10 000 to get the correct resistance.)
It also has a magnetic opening valve to let coolant of the truck flow through, for warming up!! Oops, didn’t remember correctly. It has a 3.3kΩ @25°C / +77 F 25 NTC as a temperature sensor, with 35kΩ @ -7°C / +1.4 F. Coolant flow was operated by the truck itself.

Finally to my question!

-Can my code be modified to accept floats’ resistance values as inputs, for when pump needs to be on or off? Also is some kind of smoothing filter easily applied to get rid of rapid value changing due to liquid sloshing in tank? (Tank is a small cylinder, around 2L / 68oz, not a lot of sloshing but still)

This is probably possible(?) I’ve read a lot of threads about this, but most information seems to be about those cheap floats, which are basically on/off switches. I found one about smoothing too.

About smoothing: https://forum.arduino.cc/index.php?topic=171041.0 I am still translating this, and I’m having a bit hard time understanding this.

About float+arduino: https://forum.arduino.cc/index.php?topic=419609.0

-Is it possible at the same time control the magnetic valve for shutting off/on the coolant flow after AdBlue gets warm enough/cools too much? It is possibly possible as a standalone project, as seen on this thread: Arduino Playground - SolenoidTutorial But can arduino do two things at the same time?

-Is it possible to control pump to only work when -7°C / +1.4F is reached, so that the pump wont operate when AdBlue is solid? The magnet solenoid is operated by the truck itself, and the coolant flow operates independently.

I hope I am abiding the posting rules! And if this is asking too much, the school gave me a budget and I have some left to give as a monetary tip for working solutions.

Thanks in advance!
-LSHF

-Can my code be modified to accept floats' resistance values as inputs, for when pump needs to be on or off?

Welcome to the forum, and good job with code tags and inline images on your first post. :slight_smile:

Yes. Your new sensor is a resistance ladder, and it is very common to use these with an Arduino and analogRead() as a level sensor or as a multi switch detector using only one analog input.

Here's some references to get you started.

As a general recommendation, do not use single letter variable names, but give them descriptive names related their functions.

Not quite sure what you are pumping, but I would be concerned about corrosion in a fuel pump when used for water.

That diagram shows a common design blunder, showing level-sensing electrodes connected to 5 V with pull-downs to ground. it is a singularly bad idea to connect such external things to your 5 V supply, the reference electrode should be ground, and the level electrodes pull-ups to 5 V, the pull-ups being mounted close to the Arduino or just using INPUT_PULLUP.

cattledog:
Welcome to the forum, and good job with code tags and inline images on your first post. :slight_smile:

Yes. Your new sensor is a resistance ladder, and it is very common to use these with an Arduino and analogRead() as a level sensor or as a multi switch detector using only one analog input.

Here's some references to get you started.
Arduino ESP32 DIY Water Level Sensor and DIY Level Indicator - Arduino Project Hub

Ignorant of Things: The perfect multi-button input resistor ladder

As a general recommendation, do not use single letter variable names, but give them descriptive names related their functions.

Thank you for the reply and informative threads, I will start tinkering with the float today.

Paul__B:
Not quite sure what you are pumping, but I would be concerned about corrosion in a fuel pump when used for water.

That diagram shows a common design blunder, showing level-sensing electrodes connected to 5 V with pull-downs to ground. it is a singularly bad idea to connect such external things to your 5 V supply, the reference electrode should be ground, and the level electrodes pull-ups to 5 V, the pull-ups being mounted close to the Arduino or just using INPUT_PULLUP.

Thanks for the reply!

-AdBlue is the additive for diesel cars/trucks. When sprayed to the exhaust with a certain type of catalysator, it reduces emission up to 90%. Made out of 67,5% water, 32,5% urea. The pump was chosen based on the stainless steel internals, which in theory should be able to withstand AdBlue. It has also been stress tested for couple days straight by circulating AdBlue, I hope it will last couple days more, which would correlate to about 500 000km real world driving.

-Ah, I read something about this in some youtube comments but didn't quite understand it. Main concern they seemed to have was about corrosion, but since the only material I can use is stainless, I wasn't worried about it. I will flip them around and change the code a bit.

Stainless steel may be stainless, but is not necessarily resistant to electrolysis. :astonished:

Observing the corrosion on a stainless steel dive knife one day, another diver remarked “That’s why they call it stain less”.