Creating a soil moisture sensors using nails and Intel Galileo

Believe or not, I worked in a project with hardware and software created in 8 weeks only. I am talking about Intel Galileo ! The first intel board compatible with Arduino API plus some new and cool features.


Before to talk about how to create a very affordable moisture sensor system, let me explain what is Intel Galileo.

About the Intel Galileo Board – Hardware

Intel Galileo is a board with new processor called Quark SoC X1000, x86 based, 32 bits, single-core/single thread processor full compliance with ACPI and support RTC. Do you remember pentium ? Yes, chipset instruction compatible but smaller, affordable, ACPI enabled and very simple to use.

The board contains also contains:

  • ethernet connector
  • pci-e bus (mini PCI)
  • sdcard slot up to 32Gb
  • the regular arduino Uno pins for digital and analog IO’s and an IO expander able to generate 8 PWN channels
  • 1 USB port as host (2.0) and accepts up to 128 devices
  • 1 USB port for programming (2.0)
  • contains 512Mb flash and 216Mb RAM
  • reset button for the processor, reset button for the sketches
  • 10 pin jtag-connector
  • The board can operated in 5V or 3.5V (jumper configurable)
  • 11kb EEPROM available (yeah.. we have a API for this.. click here)

The schematics are available.

About the Intel Galileo Board – Software

Intel Galileo uses Linux as OS and you can boot from flash SD card.  The cool thing on this board you have the Arduino APIs available that means you have the IDE for Linux, Windows and Macs in 32 and 64 bits.

Only Arduino API experience ? NO!!!! We expanded the experience.. you have new components in the board so new APIs were created like RTC, EEPROM, Web client, etc. Another details is, the servo API is a new methods added that can allow your servos working with 188Hz (for more precision) or 50Hz.

Considering we are running linux, when you install the IDE all the crosscompilers are installed also (toolchain). It means you can develop using native C/C++ ANSI and using the linux libraries. Arduino IDE on this case will be optional to you because you can develop your code natively and transfer using ftp for instance.

When Intel Galileo will be releases and how much will cost ? And does it worth ?

The official date is Nov, 29/2013. The cost will be around US$ 50 to US$60 bucks! I do not have the details yet..

Intel Galileo has an ethernet connector and a pci-e bus. If you are developing anything with Arduino and requires internet connection you will be forced to buy an expensive wifi/ethernet shield that costs US$ 65 bucks! If you are using Galileo you can use the embedded ethernet connector or you can buy a simple Wifi and Bluetooth module pci-e compatible in amazon for only US$ 8.00.

The same if you need a video card!

Another plus is the RTC.. You do not need another shield with RTC.. The same with SD card, you do not need another shield for data logging because you can use the APIs and store your data up to 32Gb sd card using the slot already present.

These will save a lot of money and you give you a powerful board for your project.

How do I start ?

If you are Arduino developer you will realize the IDE is mostly the same excepted by the new APIS added and the option to update the board firmware.

You can take a look in the “Getting Start Guide” and download the IDE and you can choose Windows, Linux or Mac for IDE.

This IDE a feature very special that allow us to update the Linux OS in your board (flash or SD card). Take a look in the Start Guide for more information.

The Soil Moisture System using Nails

Now you already have an introduction about what is Intel Galileo Board. Let’s talk about this very simple project.

First of all, I created this project in 2 hours and I used this project as a demo in Maker Fair in Rome/Italy.


People, did not understand (at glance) what two coups with soil and wires were doing over the table in an electronic fair but when they realized they loved (including the intel CEO Brian Krzanich).


The system is based in two sensors. Each sensor is built using galvanized nails connected to an analog port and making a resistor division with another resistor. The sensors also keeps the nail separated in a distance equivalent of 1.5 inches using pieces of foam that I found in the trash. Yes! the system is simple, cheap and you can monitor your soil only using nails. I choose galvanized for obvious reasons.. I do not want to see the nails rusted in a short period of time.



This is more than enough to check if soil has water in good amount to the plants or not. Considering was a fair, I build a LED matrix in order to show a happy or sad face. This face has a push button as well.

If “one eye” is on, means sensor number ONE. Two “eyes” means sensor number TWO. The sensor selection was done using the push button. On this way, you could see “one” or “two” eyes being switched by the users. In the fair, I had two coups each of them with soil but one of them with a little bit of water and each coup connected to a sensor.



Then, each sensor is connected to a respective analog port (A0 – sensor 1 and A1 – sensor 2) and periodically the sensor select by the push button and represented by the “eyes” were measured. If is lower then certain amount (see the code) the soil was dry and the plants need water and consequently you could see a “sad” face in the LED matrix. Otherwise, the soil was good and a happy face could see in the LED’s matrix.

Take a look in the pictures below. The first picture is sensor number 2 (two eyes) and the plant is happy, it means, has water enough in the first coup with soil. The second pictures (one eye) means sensor number 1 and the flower is sad, it means, the plant needs water.



Then the sad face, could tweet you asking for water! Of course it was a fair and I did not connect any eletric water valve because would be a mess and I would need to change the soil all the time. Another point is, if you want to create this system in your house, you do not need the LED matrix to draw the flower sad or happy face, you only need the nails connected to your analog ports and let your software make the decision, for example, turn on your sprinklers.

The code:

On this post I am adding the code to how the sensors are read and how the LED matrix is changed after reading the push button state. I will add a different post how to tweet using our ethernet connector or wifi pci-e module.

// Author: Manoel Carlos Ramon

#define DEBUG 0

/* Pins that define if system is ON */
#define PIN_LEFT_EYE 10
#define PIN_RIGHT_EYE 11

/* Sensor switch button */
int sensor_value = 0;

/* Moisture sensor - Analog Input */

/* The analog reading boundary when soil is good */
#define SOIL_IS_GOOD 350

/* some prototypes*/
void clear();
int current_system = 0;
int button_state = 0;
int last_button_state = 0;

int array_happy_face[2][4] = {{1, 0, 0, 1}, /* line 1 */
 {0, 1, 1, 0}}; /* line 0 */

int array_sad_face[2][4] = {{0, 1, 1, 0}, /* line 1 */
 {1, 0, 0, 1}}; /* line 0 */

 _____________ led 0 - pin 6
 | __________ led 1 = pin 7
 | | _______ led 2 = pin 8
 | | | ______ led 3 = pin 9
 | | | |

int array_serious_face[2][4] = {{1, 1, 1, 1}, /* line 1 */
 {1, 1, 1, 1}}; /* line 0 */

 ^ ^ ^ ^
 | | | |__ led 3 = pin 5
 | | |______ led 2 = pin 4
 | |________ led 1 = pin 3
 |____________ led 0 = pin 2

/* LED MAD */
 How the pins will work
pin 0 - Selects the common anode line 0
pin 1 - Selects the common anode line 1
int lastButtonState = LOW; // the previous reading from the input pin
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers

void setup() {

 if (DEBUG) Serial.begin(9600);
 // put your setup code here, to run once:
 int pin = 0;
 for (pin = 0; pin < 12; pin++)
 pinMode(pin, OUTPUT);

 // switch button

// clear();


void clear()
 int pin = 0;
 for (pin = 0; pin < 12; pin++)
 digitalWrite(pin, LOW);

void drawMatrix(int array[2][4])
 int line = 0;
 int pin = 2;
 int c = 0;
 int level = LOW;

 while (line < 2)
 digitalWrite(line, LOW);

 while (c <= 3)

 level = array[line];
 if (DEBUG)

 digitalWrite(pin, level);
 /* if (DEBUG)

 digitalWrite(PIN_LEFT_EYE, HIGH);

 if (current_system != 0) digitalWrite(PIN_RIGHT_EYE, HIGH);


int checkButtonState()

 // read the state of the switch into a local variable:
 int reading = digitalRead(PIN_SWITCH_SYSTEM);

// check to see if you just pressed the button
 // (i.e. the input went from LOW to HIGH), and you've waited
 // long enough since the last press to ignore any noise:

// If the switch changed, due to noise or pressing:
 if (reading != lastButtonState) {
 // reset the debouncing timer
 lastDebounceTime = millis();

 if ((millis() - lastDebounceTime) > debounceDelay) {
 // whatever the reading is at, it's been there for longer
 // than the debounce delay, so take it as the actual current state:

// if the button state has changed:
 if (reading != button_state) {
 button_state = reading;


return button_state;
void loop() {

digitalWrite(0, LOW);

digitalWrite(1, LOW);
 // reading the sensor
 switch (current_system)
 case 0:
 sensor_value = analogRead(ANALOG_MOISTURE_SENSOR_1);

 case 1:
 sensor_value = analogRead(ANALOG_MOISTURE_SENSOR_2);

 if (DEBUG)

 Serial.print(" sensor_value:");

 if (sensor_value >= SOIL_IS_GOOD)

 // reading the button state
 button_state = digitalRead(PIN_SWITCH_SYSTEM);

 if( button_state == HIGH)
 // button pressed
 if (current_system > 1) current_system = 0;

 if (current_system == 0)
 digitalWrite(PIN_RIGHT_EYE, LOW);




The format is not so good but I am letting the code available to download here as well.

Next part I will post how to make the plants tweet you when they need water allowing them to communicate with you.

About Rome-Italy

One of most beautiful places I have been.. loved the place, the people and the food!!

36 thoughts on “Creating a soil moisture sensors using nails and Intel Galileo

  1. Pingback: nba 2k

  2. Pingback: slot games

  3. Pingback: nike sunray adjustable kids aluminum volt uk trainers

  4. Pingback: 褉芯蟹芯胁褘泄 泻芯褉懈褔薪械胁褘泄 nike kobe icon

  5. Pingback: vans abstract classic slip on womens uk trainers

  6. Pingback: jaune marron blanc superstar metal

  7. Pingback: adidas eqt support 93 17 grey by9511 uk trainers

  8. Pingback: bl氓 lilla nike air foamposite

  9. Pingback: nike roshe run 2014 nike roshe run mens

  10. Pingback: khaki volt dame nike air max 2017

  11. Pingback: caqui voltio adidas messi 16.1 fg

  12. Pingback: nike free 50 womens nike free 50 ext

  13. Pingback: uk trainers nike lunar elite sky hi city yellowish pink

  14. Pingback: nike air vapormax flyknit 2 racer bluetotal crimson 942842 400

  15. Pingback: hot sale acronym x nike air vapormax moc 2 black volt black aq0996 007 mens running shoes

  16. Pingback: urban adidas eqt running 93 primeknit

  17. Pingback: adidas zx flux limited edition adidas zx flux womens limited edition

  18. Pingback: concave aura+ fg black red soccer footwear

  19. Pingback: puma pwrwarm x packlite down jacket mens sport box

  20. Pingback: uk trainers adidas flip flops yellowish pink

  21. Pingback: jz80 supra mark 4 body new type lfa

  22. Pingback: 2017 5 colors newborn baby infant toddler girls boy children first walkers booties 0

  23. Pingback: nike free tr fit womens cool grey chlorine blue varsity maize 429785 101

  24. Pingback: nike lebron 15 wine burgundy navy blue

  25. Pingback: kids pro line jermon bushrod 74 new orleans saints jersey

  26. Pingback: blue beanie day adrian roselli

  27. Pingback: 2016airjordanshoes

  28. Pingback: all comes once a blue moon junior prom graduation plus dresses share light pink semi

  29. Pingback: under armour spotlight fg

  30. Pingback: chaussures ecco chaussures derby femme beige2018 nouvelle de derbies et richelieus

  31. Pingback: long sleeve and long dress

  32. Pingback: yuribobrikhin

  33. Pingback: puma avanti

  34. Pingback: philipp plein couture casual trouser black women trousers philipp plein t shirt new york

  35. Pingback: ac milan 1988 89 away retro jersey

  36. Pingback: is new red black puma evopower 3d vigor 2017 football boot

Leave a Reply