Getting NTU from Turbidity Sensor on 3.3v

I'm powering the DFRobot SEN0189 with an ESP32 @ 3V3, and I'm in the same boat as you. There are 3 points on the graph, so I used multiple-variable algebra and solved.

TL;DR:

3V3 quadratic equation:
y = -2572.2x² + 8700.5x - 4352.9


I'll post my work, so you can catch me if I'm wrong.

First, we need to transform the X-axis from 5V to 3V3:

5V 3.3V
2.5V 1.65V
3.9V 2.574V
4.2V 2.772V

Now to transform the quadratic equation from 5V to 3V3:

y = -1120.4x² + 5742.3x - 4352.9

Replace the coefficients with a, b, and c

y = -ax² + bx - c

Now, substitute in the three points:

3000 = -a(1.650)² + b(1.650) - c
1000 = -a(2.574)² + b(2.574) - c
0 = -a(2.772)² + b(2.772) - c

Represent c, as values of a and b:

c = -a(2.772)² + b(2.772)

Replace c:

1000 = -a(2.574)² + b(2.574) - (-a(2.772)² + b(2.772))

1000 = 1.058508a - 0.198b

1000 + 0.198b = 1.058508a

a = 0.187055743b + 944.725972784

Represent c in terms of b:

c = -1.437333336b - 7259.259259259 + 2.772b

c = 1.33466664b - 7259.259259259

Substitute and solve for b:

3000 = -0.50925926b - 2572.016460904 + 1.650b - 1.33466664b + 7259.259259259

3000 = -0.1939259b + 4687.242798355

0.1939259b = 1687.242798355

b = 8700.451040088

Solve for c:

c = 1.33466664 * 8700.451040088 - 7259.259259259

c = 4352.9424969

Solve for a:

a = 0.187055743 * 8700.451040088 + 944.725972784

a = 2572.195306523

3V3 quadratic equation:
y = -2572.2x² + 8700.5x - 4352.9

The new equation works for the 3V3 points:

  • 3000.11 = -2572.2×1.65² + 8700.5×1.65 - 4352.9
  • 1000.14 = -2572.2×2.574² + 8700.5×2.574 - 4352.9
  • 0.14 = -2572.2×2.772² + 8700.5×2.772 - 4352.9

As well as (3.5, 2000) from the original graph:

3.5V => 2.31V

2019.74 = -2572.2(2.31)² + 8700.5(2.31) - 4352.9

2 Likes