So I am reading from ADC and I need to convert this into a liquid level. I have this working in C++ but trying to work out in ESP.
#dataVoltage = analogRead(ANALOG_PIN)/ 1024.0 * VREF;
##dataCurrent = dataVoltage / 120.0; //Sense Resistor:120ohm
#depth = (dataCurrent - CURRENT_INIT) * (RANGE/ DENSITY_WATER / 16.0); //Calculate depth from current readings
#define ANALOG_PIN A2
#define RANGE 5000 // Depth measuring range 5000mm (for water)
#define VREF 5000 // ADC's reference voltage on your Arduino,typical value:5000mV
#define CURRENT_INIT 4.00 // Current @ 0mm (uint: mA)
#define DENSITY_WATER 1 // Pure water density normalized to 1
#define DENSITY_GASOLINE 0.74 // Gasoline density
#define PRINT_INTERVAL 1000
I beleive i have to use filter, and lambda but im struggling with below
lambda: return x / 120 - 4 * (5000 / 0.74 / 16.0) ;
Can anyone help an old dog out