The YL-83 Module LM393 is a soil moisture sensor designed to measure the moisture content in soil. It utilizes the LM393 comparator to provide a digital output signal that indicates whether the moisture level has crossed a certain threshold. This sensor is commonly used in gardening projects, automated plant watering systems, and environmental monitoring.
Pin | Description |
---|---|
VCC | Connect to 3.3V or 5V power supply |
GND | Connect to ground |
D0 | Digital output pin; goes high or low based on threshold |
A0 | Analog output pin; outputs voltage proportional to moisture level |
// Define the sensor's digital and analog pins
const int sensorDigitalPin = 2; // Digital output from sensor
const int sensorAnalogPin = A0; // Analog output from sensor
void setup() {
pinMode(sensorDigitalPin, INPUT); // Set digital pin as input
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
int sensorDigitalValue = digitalRead(sensorDigitalPin); // Read digital value
int sensorAnalogValue = analogRead(sensorAnalogPin); // Read analog value
// Print the values to the serial monitor
Serial.print("Digital Value: ");
Serial.print(sensorDigitalValue);
Serial.print(" | Analog Value: ");
Serial.println(sensorAnalogValue);
delay(1000); // Wait for 1 second before reading again
}
Q: Can the YL-83 Module LM393 be used with a 3.3V system? A: Yes, the sensor can operate at 3.3V, making it compatible with both 5V and 3.3V systems.
Q: How do I know if the sensor is working correctly? A: You can test the sensor by inserting it into soil with known moisture levels or by using it to detect water in a cup.
Q: Is the sensor waterproof? A: The sensor probe is water-resistant, but the electronic components are not waterproof. Protect the module from water damage when used outdoors.
Q: How long can the sensor be left in the soil? A: The sensor can be left in the soil for extended periods; however, prolonged exposure to moisture can lead to corrosion. Regular inspection and maintenance are recommended.