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

Testing all the sensors

At this point, we are ready to test things. We will start with all the sensors.

Again, we will use the Arduino IDE. Note that we will use the Sensirion library, which is required here to use the soil temperature and humidity sensor. 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;

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

void setup() {

  // Serial

// the loop routine runs over and over again forever:
void loop() {
  // Test photocell
  float light_reading = analogRead(light_pin);
  float light_level = light_reading/1024*100;
  Serial.print("Light level: ");
  // Test temperature sensor
  float temperature_reading = analogRead(temperature_pin);
  float temperature = (temperature_reading/1024*5000 - 500)/10; 
  Serial.print("Temperature: "...