voltage-to-tds

wayland/total-dissolved-solids/voltage-to-tds

Convert voltage measured by sensor to total dissolved solids (ppm).
voltage-to-tds
@/voltage-to-tds
Convert voltage measured by sensor to total dissolved solids (ppm).
Analognumber
Analog signal from TDS sensor.
V-Refnumber
Reference voltage. For the Arduino Uno/Mega the reference voltage is 5. For ESP32 the reference voltage is 3.3V.
TempCnumber
Temperature in degrees celsius.
voltage-to-tds
Analog
V-Ref
TempC
TDS
TDSnumber
Total dissolved solids (ppm).
To use the node in your project you should have the wayland/total-dissolved-solids library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

//Based on http://www.cqrobot.wiki/index.php/TDS_(Total_Dissolved_Solids)_Meter_Sensor_SKU:_CQRSENTDS01

#pragma XOD dirtieness disable

node {

    void evaluate(Context ctx) {
        auto analog = getValue<input_Analog>(ctx);
        auto refV = getValue<input_V_Ref>(ctx);
        float voltage = analog*refV;
        auto tempC = getValue<input_TempC>(ctx);
        float compensationCoefficient = 1.0 + 0.02 * (tempC-25.0);
        float compensationVoltage = voltage/compensationCoefficient;
        Number tds = (133.42 * compensationVoltage * compensationVoltage * compensationVoltage - 255.86 * compensationVoltage * compensationVoltage + 857.39 * compensationVoltage) * 0.5;
        emitValue<output_TDS>(ctx, tds);
    }
}