Book Image

Intel Galileo Blueprints

By : Marco Schwartz
Book Image

Intel Galileo Blueprints

By: Marco Schwartz

Overview of this book

Table of Contents (19 chapters)
Intel Galileo Blueprints
About the Author
About the Reviewers
Free Chapter
Setting Up the Galileo Board and the Development Environment

Automating your garden

After we have programmed the sensor controls, we will proceed to configure our water pump. In this next section, we will add the pump in the loop to automate gardening. Here is the complete code for this part:

// Libraries
#include <Sensirion.h>

// Pins
int temperature_pin = A1;
int light_pin = A0;

int dataPin = 6;
int clockPin = 7;

int relay_pin = 8;

// Soil sensor instance
Sensirion soil_sensor = Sensirion(dataPin, clockPin);

// Humidity thresholds
float low_threshold = 40;
float high_threshold = 60;

void setup() {

  // Serial
  // Pin mode
  pinMode(relay_pin, 8);

// the loop routine runs over and over again forever:
void loop() {
  // Measure & print data
  float light_reading = analogRead(light_pin);
  float light_level = light_reading/1024*100;
  Serial.print("Light level: ");
  float temperature_reading = analogRead(temperature_pin);
  float temperature = (temperature_reading...