INPUT DEVICES

GROUP ASSIGNMENT

INDIVIDUAL ASSIGNMENT

MOISTURE SENSOR

For this week's assignment we were tasked to measure something, to plug in a sensor to a PCB we have previously designed. For this one I decided to use a moisture sensor which is normally used testing moisture content in the soil.

schematic

COMPONENTS USED

  • PCB (DESIGNED ON WEEK 6)
  • JUMPER WIRES
  • SOIL MOISTURE SENSOR

I started off by connecting the sensor to analog pins in my board,

  • VCC connected to 3V3
  • GND connected to GND
  • AO connected to PIN A0 (D26)
  • The connection was like this: connection

    Then Arduino IDE was launched and then programmed the moisture to start taking readings and print them on the serial monitor. The code I used is shown below:

    
    int sensorPin = A0;
    int sensorValue;
    
    void setup() {
      Serial.begin(9600);
      pinMode(sensorPin, INPUT);  // Optional; analog pins default to INPUT
    }
    
    void loop() {
      sensorValue = analogRead(sensorPin);  // Read the analog value from the sensor
      Serial.print("Moisture Reading: ");
      Serial.println(sensorValue);          // Print the value to Serial Monitor
      delay(1000);                           // Optional: wait 1 second before next read
    }
    
    							 

    The moisture readings were printed in the serial monitor as shown below:

    reading

    FILES

  • MOISTURE SENSOR CODE