Turbidity Sensor Problem.
jeron.xiao 2026-11-09 05:23:01 7 Views0 Replies I have followed all of the steps to make the turbidity sensor. The parts are all tucked, and they are not flipped. But, my voltage has been stuck at 1.50 and below and doesn't move. What do I do? The ntu stays at 3,000 because there isn't sufficient voltage from the arduino to the sensor for the turbidity sensor to create a data value. I have legit tried everything. Here is my code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // Corrected library name
// Initialize the LCD with the I2C address (0x27) and screen dimensions (16 columns, 2 rows)
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int sensorPin = A1; // Reads physical pin A0 due to board label swap
void setup() {
Serial.begin(9600);
lcd.init(); // Correct method to initialize the I2C LCD screen
lcd.backlight(); // Turns on the LCD backlight so you can see the text
lcd.setCursor(0, 0);
lcd.print("Turbidity Test");
delay(1500);
lcd.clear();
}
void loop() {
// 1. Take ONE reading and calculate voltage immediately
int rawValue = analogRead(sensorPin);
float voltage = rawValue * (5.0 / 1024.0);
// 2. Calculate NTU
float ntu = 0.0;
if (voltage >= 2.5) {
ntu = -1120.4 * (voltage * voltage) + 5742.3 * voltage - 4353.8;
if (ntu < 0) ntu = 0;
} else {
ntu = 3000.0;
}
// 3. Print the EXACT SAME values to Serial Monitor
Serial.print("Raw: ");
Serial.print(rawValue);
Serial.print(" | Volt: ");
Serial.print(voltage, 2);
Serial.print("V | NTU: ");
Serial.println(ntu, 1);
// 4. Print the EXACT SAME values to LCD Screen
lcd.setCursor(0, 0);
lcd.print("Volt: ");
lcd.print(voltage, 2);
lcd.print("V "); // Spaces clear trailing characters
lcd.setCursor(0, 1);
lcd.print("NTU: ");
lcd.print(ntu, 1);
lcd.print(" "); // Spaces clear trailing characters
delay(1000);
}
The sensors are all brand new, and I had bought two of the same sensor, which has all shown the same thing.

