TS-300B Turbidity Sensor

TS-300B Turbidity Sensor

This section deals with the configuration of the TS-300B turbidity sensor.

Application

The intention is to use the TS-300B sensor to measure the turbidity of the water output from an aerated wastewater treatment system (AWTS). It's not clear at the moment, however, whether or not having the sensor permanently located in this environment, taking periodic measurements, will be practical.

Details pending

Configuration

Source material:

Details pending

Hardware

The TS-300B is a 5V sensor that generates an output in the 0~4.5V range. This must be taken into account when configuring an MCU with an ADC that works on a smaller input range. In the present case, as discussed in the section on battery management, both the CubeCell and ESP32 platforms require the use of voltage dividers to bring this range back to 0~2.4V and 0~3.3V respectively. For the CubeCell platform, a 200kΩ/220kΩ combination will bring 4.5V back to 2.4V and, for the ESP32, a 100kΩ/220kΩ combination will bring the maximum output voltage back to 3.1V, avoiding the use of the notoriously non-linear top end of the ESP32 ADCs.

CubeCell / TS-300B Hardware Configuration

CubeCell Plus / TS-300B Electrical Circuit

WiFi LoRa 32 (V3) / TS-300B Hardware Configuration

WiFi LoRa 32 (V3) / TS-300B Electrical Circuit
Pin Configurations
CubeCell Plus WiFi LoRa 32 (V3) TS-300B
Vin 5V VCC
ADC2 GPIO48 OUT
GND GND GND

Details pending

Software

Details pending, but in the interim...

The following is a simple code example from this CircuitDigest project.


#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 16);
int sensorPin = A0;
void setup()
{ 
  Serial.begin(9600);
  lcd.begin();
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
}
void loop() {
  int sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);
  int turbidity = map(sensorValue, 0, 750, 100, 0);
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print("turbidity:");
  lcd.print("   ");
  lcd.setCursor(10, 0);
  lcd.print(turbidity);
  delay(100);
  if (turbidity < 20) {
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    lcd.setCursor(0, 1);
    lcd.print(" its CLEAR ");
  }
  if ((turbidity > 20) && (turbidity < 50)) {
    digitalWrite(2, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    lcd.setCursor(0, 1);
    lcd.print(" its CLOUDY ");
  }
  if (turbidity > 50) {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    lcd.setCursor(0, 1);
    lcd.print(" its DIRTY ");
  }
}
19-07-2026