Basic Usage 2

Read data from soil moisture sensor

This is the basic experiment for learning the plant watering kit, it will help you to know about the pinout of electronics components onboard and help you understand how to use those components individual.

OK, let’s begin the basic learning.

In this experiment, we are going to read raw data from soil moisture sensors on the plant watering hat board.

Hardware Overview

The shield provides the following interfaces:

  • 3 x Soil Moisture Sensors (Analog Inputs A0, A1, A2)
  • 3 x NTC Temperature Sensors (Analog Inputs A4, A5, A6)
  • 3 x 3.3V Relay Modules (Digital Outputs 2, 3, 4)
  • 3 x Mini Water Pumps
  • 1.3-inch IPS RGB TFT Screen (ST7789 Controller)

Soil Moisture sensor Details

soil_moisture

Pinout Chart

  • Details of the expansion board.
Plant Watering Kit Hat Board Arduino UNO R4 WiFi Board
HUMI3 A0
HUMI2 A1
HUMI1 A2
TEMP3 A3
TEMP2 A4
TEMP1 A5
IR_RSV D5
Relay 1 D2
Relay 2 D3
Relay 3 D4
TFT_SCLK D13
TFT_MOSI D11
TFT_CS D10
TFT_DC D9
TFT_RST D8
RX TX->1
TX RX<-0
Green LED D6
Red LED D7

Circuit Diagram

circuit Diagram

Soil moistrue socket position

soilmoisture

Connecting the Shield

  • place the arduino uno r4 on a flat surface.
  • align the shield with the headers of the arduino board and gently press it down until it clicks into place.
  • plug the plant watering hat board on top of arduino uno r4 on gpio pins.

Programming

Open arduino IDE and create a new sketch by clicking file-> New Sketch

new sketch

Define LED Pin number

#define HUMI3 A0 
#define HUMI2 A1
#define HUMI1 A2

Initializing Pin and Serial port for monitoring.

void setup() {
    Serial.begin(9600);  // Initializing Serial monitor 
}

Modify loop section

void loop() {
    int HUMI1_Raw_data = analogRead(HUMI1);
    int HUMI2_Raw_data = analogRead(HUMI2);
    int HUMI3_Raw_data = analogRead(HUMI3);

    Serial.print("Soil Moisture sensor raw data:");
    Serial.print("CH1: ");
    Serial.print(HUMI1_Raw_data);
    Serial.print("CH2: ");
    Serial.print(HUMI2_Raw_data);
    Serial.print("CH3: ");
    Serial.println(HUMI3_Raw_data);
    delay(1000); //wait for a second.
}

Upload the sketch to Arduino UNO R4 WiFi board.

  • Connect the Arduino UNO R4 WiFi board to your computer via USB-C cable on USB port

  • Select the serial device on your arduino IDE and click upload icon as following figure:

upload sketch1 upload sketch2 upload sketch3

Open Serial monitor

  • Click this icon on right up cornner to open serial monitor.

openserialmonitor openserialmonitor

Demo Code Sketch Download

Basic_2_demo_code_sketch_download

Finally

  • Check if the three channel has outputs on the serial monitor, and try to put one of them into the water, and observe the output data on screen. If you can see the data changed when you insert the sensor into water, it means you finished this task. Let us remove to next chapter.