const int SENSOR_PIN = A0; // Analog pin connected to the sensor
void setup() {
Serial1.begin(9600); // Initialize serial communication
pinMode(SENSOR_PIN, INPUT); // Set the pin as input
}
void loop() {
int rawValue = analogRead(SENSOR_PIN); // Read the 12-bit ADC value
// Scale the 12-bit value to a 10-bit range (if needed)
// int scaledValue = map(rawValue, 0, 4095, 0, 1023);
// Convert to percentage for a 12-bit ADC
float percentage = (rawValue / 4095.0) * 100;
Serial1.print("Raw Sensor Value: ");
Serial1.print(rawValue);
Serial1.print(" | Moisture Level: ");
Serial1.print(percentage);
Serial1.println("%");
delay(1000); // Delay for readability
}