Project: Detection of rain and soil moisture measurement using Intel Galileo

  • Dec 26, 2019
click fraud protection

In this article you will learn how to use analog sensors with Intel Galileo. I'll show you how to use a simple sensor of rain and soil moisture sensor.

This project can be used on the farm: to take better decisions about when to water growing crops, as well as very useful to have information on how much rain fell, and the level of humidity soil.

Despite the fact that I have used in the Intel Galileo project, you could also use the same code and the connection with Arduino.

The components that I have used:

  1. Intel Galileo - 1 pc.
  2. Layout type IB401 experiments with 400 points and ridges
  3. Soil Moisture Sensor - 1 pc.
  4. Rain sensor FC-37 - 1 pc.

How does the soil moisture sensor?

Soil Moisture Sensor is very simple.

It measures the resistance of the soil and converts it into voltage of 0 to 5 V. You can read this value via the analog outputs Intel Galileo board.

Soil moisture sensor
Soil moisture sensor

This will give you an integer from 0 to 1024 in your code.

On the information page of the Soil Moisture Sensor, you can see that the sensor will give you the following output for the dry soil, moist soil and water:

instagram viewer
  • The sensor in the dry soil: 0 ~ 300
  • The sensor in a moist soil: 300 ~ 700
  • The sensor in the water: 700 ~ 950

Different plants need a level of moisture. You can measure in real reference value - and then use it in your project.

How does the rain gauge?

Out of such a sensor is also a simple voltage value from 0 to 5 V. And you can read it with one of the analog inputs Intel Galileo your board.

Rain sensor FC-37
Rain sensor FC-37

The sensors also have a digital output. It will be high when the level of humidity exceeds a certain threshold. You can control the threshold using the integrated potentiometer.

But since it's easy to do in your code, you can skip this conclusion and only use the analog output of the project.

Step 1: Connect the components

Connect the connecting wires from the 5 V and GND from Galileo to the two empty rows on the layout.

Use the connecting cables for connecting the VCC and GND from the soil moisture sensor to 5V and GND in the layout.

And connect a jumper from contact SIG sensor soil moisture to the terminal A0 on Intel Galileo board.

Do the same with rain sensor: connect the VCC and GND to 5V and ground on the layout.

And connect A0 from the rain sensor to the A1 on Galileo.

Connect power the Intel Galileo board, and when the USB indicator lights up, connect the USB cable from the computer to Galileo.

You are now ready for programming.

Step 2: Download the code to read values ​​from the sensor of soil moisture

Check the soil moisture sensor by downloading the following code:

int sensorPin = A0; // select the input pin for the sensor
void setup () {
// Initialize serial port
Serial.begin (9600);
}
void loop () {
// read values ​​from the sensor
int sensorValue = analogRead (sensorPin);

// Display the value
Serial.println (sensorValue);

// delay of 200 ms.
delay (200);
}

Then touch your fingers to the two contacts of the sensor to ensure that there is a reaction. If you see a change in the values ​​when you touch the two contacts, which means that everything is working.

Step 3: Check the rain sensor

Now change the code in order to check the rain gauge.

Use the same code as above, but instead change the variable sensorPin on A1. You can check the rain gauge, for example, using a wet sponge.

Step 4. Combine the code in one

Finally, combine all of the code for these two sensors into one program and make serial output more enjoyable:

int sensorPinSoil = A0; // input PIN for soil moisture sensor
int sensorPinRain = A1;
// input PIN for the rain sensor

void setup () {
Serial.begin (9600);
}
void loop () {
int soilValue = analogRead (sensorPinSoil);
int rainValue = analogRead (sensorPinRain);
// output to a readable format values
Serial.print ( "Current value rain sensor");
Serial.println (rainValue);
Serial.print ( "Current value of soil moisture sensor");
Serial.println (soilValue);
Serial.println ( "");
delay (200);
}

Done! Test! And do not forget to subscribe to my RSS feed.