22 const int16_t sensor_length_mm = 40;
23 const int16_t max_voltage_when_dry = 20;
24 const int16_t voltage_at_min = 1000;
25 const int16_t voltage_at_max = 3300;
27 const int16_t voltage_diff = voltage_at_max - voltage_at_min;
29 if (mV < max_voltage_when_dry)
31 if (mV < voltage_at_min) {
36 return ceilf(((
float) mV - (
float) voltage_at_min) * ((
float) sensor_length_mm / (
float) voltage_diff));
int16_t voltage_to_mm(uint16_t mV)
err_t read_voltage(T &mV)
Read voltage level of input.
Rain40x16(driver::ADC *adc)
Rainlevel sensor 40mmx16mm DC3-5V Currently hardcoded for 3.3V.
Analogue digital converter.
err_t get_water_level(uint16_t &water_level_in_mm) override
Get water level in millimeters of the sensor.