Diesel Heater Fuel Burn Totaliser RPi/Ardunino

van Rix

Forum Member
I have a 12 lt external diesel fuel tank for my Chinese diesel heater and I would like to keep track on the amount of fuel that I have used. The tank is remote and inaccessible, and for various reasons, I do not want to use a traditional float measurement.

I am thinking of using a Raspberry Pi or Arduino to count the number of fuel pump pulses and convert the number of pulses into litres. Ultimately, this would count down from the full volume and be displayed on a simple LCD display. The calculated volume would be remain in memory when the power was cut and when reinstated, carry on counting down from the last point.

As each pump pulse delivers 0.02 ml, it would be straight forward to convert this into volume (see (832) Chinese Diesel Air Heaters Part 3 - Fuel Consumption - YouTube).

I have used RPi's before and was thinking of using a Pi Zero (or Pico). I do not wish to re-invent the wheel and would like to know if anyone has undertaken a similar project. If not, help with the project would be appreciated.

My van still requires plenty of work, so I am thinking this is a project should go on my wish list. If you have any ideas or suggestions, I would be interested in your input.

Thx

Richard

PS I also have a inline water flow meter that I was planning to do the same as above.
 

wildebus

Forum Member
I did this with my Chinese Heater, linking it to the Victron Setup I had installed.

Using a Victron Venus GX (so running the standard Venus OS), I setup one of the IO ports to work as a pulse meter
1612635446542.png


I called that Input "Kerosene Heater" (I ran it on Kerosene, not Diesel ;) )
1612635535760.png


You say it delivers 0.02ml per pulse. I found it - or at least mine - was different. From memory, after I did test, on the Victron setup, I set mine to 0.012500 per pulse, which equated to 0.0125ml/pulse ( the choice of volume was a bit limited)
(I came up with the value after setting the pump up to fill a container and measured the volume after a certain number of pulses and did the maths).
1612635609467.png


On the GX, I used an Iso-isolator to deal with the voltage difference (GX wanted 3.3V, Pump is a 12V unit).
Not using it now as changed vehicles and moved kit and this was all over 6 months ago so Eons ago for my memory.
Also, the new Cerbo GX (In case you were interested in the Victron route) does not apparently support a Pulse Meter. I have not yet checked if that is correct, but if it is, you would need the GX. The RPi with an IO board would likely work if you found the right input - While I've installed RPi's with the Victron OS, I've never added any IO so don't know on that score. Another Forum Member has done that kind of thing though.
 

xsilvergs

Forum Member
I have a 12 lt external diesel fuel tank for my Chinese diesel heater and I would like to keep track on the amount of fuel that I have used. The tank is remote and inaccessible, and for various reasons, I do not want to use a traditional float measurement.

I am thinking of using a Raspberry Pi or Arduino to count the number of fuel pump pulses and convert the number of pulses into litres. Ultimately, this would count down from the full volume and be displayed on a simple LCD display. The calculated volume would be remain in memory when the power was cut and when reinstated, carry on counting down from the last point.

As each pump pulse delivers 0.02 ml, it would be straight forward to convert this into volume (see (832) Chinese Diesel Air Heaters Part 3 - Fuel Consumption - YouTube).

I have used RPi's before and was thinking of using a Pi Zero (or Pico). I do not wish to re-invent the wheel and would like to know if anyone has undertaken a similar project. If not, help with the project would be appreciated.

My van still requires plenty of work, so I am thinking this is a project should go on my wish list. If you have any ideas or suggestions, I would be interested in your input.

Thx

Richard

PS I also have a inline water flow meter that I was planning to do the same as above.

Saw your post and knew I'd looked at this only a few weeks ago. The code below was written for an Arduino to simulate counting pump pulses and then fool a Victron Venus GX into displaying tank level. Using PWM the voltage level drops, this would normally be across the sender. I hope some of it makes sense and ignore the bits associated with temperature.

/*
For dosing pump with 0.02ml stroke
10 Litres / 0.02 = 500,000 pulse from full to empty

*/
int Tank1CH4 = 6; // pin for tank 1 sender level
int level; // 0 = EMPTY to 255 = FULL
long pulses = 500000; // pulses to pump 10 litres
int percent;
unsigned long previousMillis = 0; // will store last time
const long interval = 50; // simulates interval pump pulses

//#################################
int sensorPin = A0;
int sensorValue = 0;
int Temperature;
int Temp1CH5 = 5;
unsigned long previousMillisTempOne = 0;
const long intervalTempOne = 1000;
//#################################
void setup() {
Serial.begin(115200); // Serial Monitor baud rate
pinMode(Tank1CH4, OUTPUT); //
pinMode(Temp1CH5, OUTPUT);
}

void loop() {
tempOne();
fuel();
//level = map(pulses, 500000, 0, 255, 0); // map pulses to fuel guage


}
void fuel() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
pulses--; // each time pump pulses decrement // rem out this out to calibrate
//#################################
// Use this to set potentiometer value to achieve 99% in Control panel ~1.05volts,
// it takes a long time to settle. MINUTES!!!!!
//pulses = 495000; // 99% fuel capacity.
//#################################
// Use this to set resistor value to achieve 1% in Control panel adjust using last value in map
//pulses = 5000; // 1% fuel capacity.
//#################################
// These can be used to check other values
//pulses = 400000; // 80% fuel capacity.
//pulses = 250000; // 50% fuel capacity.
//###################################
level = map(pulses, 500000, 0, 255, 4); // map pulses to fuel guage in panel
analogWrite(Tank1CH4, level); // write PWM to pin/MCP3208
// Next 3 lines are for visual check in terminal monitor
percent = map(pulses, 500000, 0, 100, 0);
Serial.print("Tank Level = "); Serial.print(percent); Serial.println("%");
Serial.println("");
}
if (pulses == 0) {
pulses = 500000;
}
}

void tempOne() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillisTempOne >= intervalTempOne) {
previousMillisTempOne = currentMillis;
sensorValue = analogRead(sensorPin);
//Serial.print("Sensor Value = "); Serial.println(sensorValue);
Temperature = map(sensorValue, 0, 408, 160, 240);
analogWrite(Temp1CH5, Temperature);
}
}
 
Last edited:

xsilvergs

Forum Member
I use an RPi running the Venus ported code.
From memory: To this I added an MCP3208 ADC which gives tank levels etc. and set its Vref to 1.8 volts. Arduino outputs 0 to 5v for PWM (on an UNO) so simple resistor divider to loose 3.8v, therefore 1.2v for full tank, 0v for empty.

The Venus - Cerbo large image for Node-Red + SignalK is worth looking at but I never got the ADC to work with the large image.

My advice would be run the Large Image on a later Venus or Cerbo or RPi, Node-reds Dashboard can be accessed via the Victron Portal. Use Wemos D1 Mini's to count pump pulses, sense lights, water pump, temperature etc, these communicate with RPi. You can then see your tank levels remotely, turn on lights, etc, etc through the Victron Portal. Here you can see Node_Red's dashboard in a browser, to the left are 3 buttons to select/de-select Water Pump, Outside Light and Panel Power. Unfortunately you can't see the state indicators in this image. Another D1 can measure battery temperature and turn on heaters should they drop below x*C. If you had a diesel heater you could get to RPi to send an email when the van dropped below a temperature and you could remotely turn the heater on. I've not looked at a way to turn our Truma on yet, I'm not paying for iNet!

Screenshot at 2021-02-06 21-09-31.png
 

van Rix

Forum Member
Many thanks wildebus and xsilvergs for taking the time to reply to my question. You both have provided some very useful information.

I was aware of the Victron software but I did not realise that it could be adapted for your own needs. I did not know about the Cerbo GX. I only have a Victron charger and unless I am missing something, the bluetooth interface does not do a great deal. I might change my MPPT to a Victon at a later date so having everything on one (Victron) system would be beneficial.

I can see that this project of mine is going to take some working out, but your info is a very good starting point. It might be a while before I come back asking questions as today, I have to cut some furniture board and carry on with the conversion. Shame I can't sit in the warm and consider this project.. !

BTW. I also have a Truma 4 and I won't be paying for iNet! The fuel 0.02 ml per stroke output was the figure given in the video link I gave. Given the very small volume, I can see why there might be slight differences.

Thx again

Richard
 

Nabsim

Forum Member
Seeing a bit of code almost makes me want to start doing a bit, not sure my interest could be sustained though. It is nice to see what you folks are doing/trying to do though, keep it up :)
 

van Rix

Forum Member
Since posting my question, I have been wondering if I might just use a Hall sensor on the pump wire to detect a signal or perhaps use a ADC712 board. But i would need to look a bit more into the these. Perhaps these questions are not really of interest to Motorhome Builders, so I may have to post elsewhere when I get some 'study' time !

Nabsim: you can do the coding in the comfort of you own home and not even go out ! No risk of covid exposure and it passes the time !
 

xsilvergs

Forum Member
Since posting my question, I have been wondering if I might just use a Hall sensor on the pump wire to detect a signal or perhaps use a ADC712 board. But i would need to look a bit more into the these. Perhaps these questions are not really of interest to Motorhome Builders, so I may have to post elsewhere when I get some 'study' time !

Nabsim: you can do the coding in the comfort of you own home and not even go out ! No risk of covid exposure and it passes the time !

I don't have a diesel heater but would guess the pump is pulsed by the controller with 12v.

Arduino's have either 5v or 3.5v digital inputs. In its simplest form a divider of two resistors to reduce the 12v down would give you a signal to count.

If the Arduino had an SD card attached the count total could be saved. On restart the Arduino would know how much fuel remains in the tank.

A single push button to another digital input could be used to reset the count to 500000 or 0 (depends if you count up or down).

Alternatively forget the Arduino, use a RPi running Node-Red and have a visual display (back to RPi running Venus GX Large Image again).
 

van Rix

Forum Member
xsilvergs
Thx. Yes I had thought of the resistor route and that does sound like a good idea and less interface(s) to deal with. I think I will stick to the Ardunio approach and keep it as a standalone project. It is a also a way for me to learning something new at the same time.

Anyway, thank you for your ideas. They are much appreciated. I can see that I have some background reading to do !
 

xsilvergs

Forum Member
xsilvergs
Thx. Yes I had thought of the resistor route and that does sound like a good idea and less interface(s) to deal with. I think I will stick to the Ardunio approach and keep it as a standalone project. It is a also a way for me to learning something new at the same time.

Anyway, thank you for your ideas. They are much appreciated. I can see that I have some background reading to do !

The Arduino has the issue of not remembering the last fuel level when it's switched back on, unless you intend to leave it on all the time. If you add an SD card you could write the count value to a .txt file each pump pulse, then on start read the .txt file back and carry on decrementing.
 

Users who viewed this discussion (Total:0)

Top