Friday, April 28, 2023
HomePython🌿 Greenhouse Half 1: Utilizing Yl-69 Soil Sensor With Arduino

🌿 Greenhouse Half 1: Utilizing Yl-69 Soil Sensor With Arduino


Hello pretty individuals! πŸ‘‹ When you have learn any of my different articles you is likely to be conscious that I’m working with electronics proper now. After studying the fundamentals of Arduino, I made a decision to work on a comparatively formidable venture. I made a decision to make a greenhouse monitoring system. I’m going to write down a sequence of posts introducing you to all the sensors one after the other and by the tip of this sequence, we may have a totally practical, tremendous fundamental, greenhouse monitoring system.

On this publish, I’ll introduce you to the YL-69 Soil Moisture Sensor. It is a very fundamental and low cost soil moisture sensor and will be purchased from oddwires.

Step 1: Wiring up the circuit

Let’s begin off by establishing the circuit. I’m utilizing:

  • Arduino UNO
  • Breadboard
  • YL-69 Soil Moisture Sensor
  • Jumper Wires

Wire up the circuit like this:

YL-69 fritzing
Notice: Click on on the picture to view a bigger model

The output from the moisture sensor adjustments based mostly on how a lot water is within the soil. It ranges from 0 to 1023. 1023 signifies that there isn’t any water and 0 means there’s excellent conductivity and therefore loads of water.

Step 2: Coding the Arduino

int moisturePin = A0;
int threshold = 750;

void setup(){
    pinMode(moisturePin, INPUT);
    Serial.start(9600);
}

void loop(){
    int sensorValue = analogRead(moisturePin);    
    Serial.print(sensorValue);    
    if (sensorValue < threshold){
        Serial.println(" - Plant does not want water");
    } else {
        Serial.println(" - Plant wants water!");
    }
    delay(1000);
}

The code is simple. We first outline the moisturePin as A0. That is the place the enter from our moisture sensor is coming in. Then we set the edge worth to 750. This worth dictates what we assume to be one of the best soil moisture degree. You would possibly wish to change it to one thing else based mostly on private testing. After that, we use the analogRead perform to learn the worth from pin A0 and based mostly on the studying we ship some info to the serial monitor.

Lastly, we add a delay for one second in order that we are able to get dependable and paced readings. There isn’t any use in taking a studying each millisecond.

And that’s it! Join the Arduino to your laptop computer, add the code and take a look at placing the sensor in soil! It ought to provide you with an output like this within the serial monitor:

Soil Moisture Sensor Readings

Within the subsequent article, we’ll discover ways to measure temperature and lightweight depth utilizing the Arduino. See you then! ❀️


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments