Browse over 10,000 Electronics Projects using the Page Numbering provided at the bottom of each Page.

Intel Galileo Board for Measuring Rain and Moist

Intel Galileo Board for Measuring Rain and Moist

In this Intel Galileo board sensors tutorial you’ll learn how to use analog sensors. I’ll show you how to use a simple rain sensor and a soil moisture sensor.

This project could be used on a farm: To make better decision about when to water the crops, it’s very helpful to have information about how much it has rained, and the moisture level in the soil.

Even though I used an Intel Galileo here, you could just as well use the same code and connections with an Arduino.

The components I used:


How does a soil moisture sensor work?

The soil moisture sensor is very simple.

It measures the resistance in the soil and converts this into a voltage between 0 and 5V. You can read this value with the analog pins of the Intel Galileo board.

This will give you an integer value between 0 and 1024 in your code.

From the info page of the soil moisture sensor you can find that the sensor will give you the following output for dry soil, humid soil and water:

Sensor in dry soil: 0 ~ 300
Sensor in humid soil: 300 ~ 700
Sensor in water: 700 ~ 950

Different plants need water at different moisture levels. So you need figure the exact values for your plant by doing a manual check and comparing it to the sensor reading.

How does a rain sensor work?

The raindrop sensor measures the amount of rain it detects.

It is a cheap sensor, and not very accurate. But it is good for getting started with Intel Galileo board sensors.

This output is also a simple voltage value between 0V and 5V. And you can this read with one of the analog inputs of your Intel Galileo board.

The sensors also has a digital output. This will go high when the moisture level is above a certain threshold. You can control the threshold using the on-board potentiometer.

But since this can easily be done in code, you can skip this output and use only the analog output.

Here’s a good resource to learn more about this sensor:

Step 1: Connect the hardware

Connect jumper wires from 5V and GND on the Galileo, to two empty rows on the breadboard.

Use jumper wires to connect VCC and GND from the soil moisture sensor to 5V and GND on the breadboard.

And connect a jumper wire from the SIG pin of the soil sensor to A0 on the Intel Galileo board.


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

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


intel galileo board sensors

Plug in the power of the Intel Galileo board, and when the USB light turns on, plug the USB cable from the Galileo to your computer.

Now you are ready to program the Galileo.

Step 2: Upload code to read soil sensor

Test the soil sensor to work by uploading the following code:

int sensorPin = A0; // select the input pin for the sensor
void setup() {
  //Initialize serial communication
void loop() {
  // read the value from the sensor:
  int sensorValue = analogRead(sensorPin);
  // print the value out on the serial port
  //Wait for 200 ms (to make the serial output more readable in realtime)

Then, touch the two pins with your fingers to check that it responds. If you see a change in value when touching the two pins, it’s working.

Step 3: Test the rain sensor

Now, change the code to test the rain sensor.

Use the same code as above, but change the sensorPin variable to A1 instead. You can test the rain sensor by using a wet sponge on the sensing area.

Step 4: Combine code for the Intel Galileo board sensors

At last, combine both sensor readings in one program and make the serial output a bit nicer:

int sensorPinSoil = A0; // select the input pin for the soil sensor
int sensorPinRain = A1; // select the input pin for the rain sensor
void setup() {
  //Initialize serial communication
void loop() {
  // read the value from the sensors:
  int soilValue = analogRead(sensorPinSoil);
  int rainValue = analogRead(sensorPinRain);
  // print the value in a nice format on the serial port
  Serial.print("Current rain value: ");
  Serial.print("Current soil value: ");
  //Wait for 200 ms (to make the serial output more readable in realtime)