Example Code for Arduino-Analog Output

Example 1 uses Analog output mode

Wiring Diagram

Interface Description:

  1. "D/A" Output Signal Switch
    • "A": Analog Signal Output, the output value will decrease when in liquids with a high turbidity
    • "D": Digital Signal Output, high and low levels, which can be adjusted by the threshold potentiometer
  2. Threshold Potentiometer: you can change the trigger condition by adjusting the threshold potentiometer in digital signal mode.

Sample Code

void setup() {
  Serial.begin(9600); //Baud rate: 9600
}
void loop() {
  int sensorValue = analogRead(A0);// read the input on analog pin 0:
  float voltage = sensorValue * (5.0 / 1024.0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  Serial.println(voltage); // print out the value you read:
  delay(500);
}

Additional Information

This is a reference chart for the mapping from the output voltage to the NTU according to different temperature. e.g. If you leave the sensor in the pure water, that is NTU < 0.5, it should output “4.1±0.3V” when temperature is 10~50℃.

characteristic curve “Voltage ----Temperature

In the diagram, the unit measuring turbidity is shown as NTU, also it is known as JTU (Jackson Turbidity Unit), 1JTU = 1NTU = 1 mg/L. Refer to Turbidity wikipedia

Was this article helpful?

TOP