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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Setting Up the Galileo Board and the Development Environment
Index

Testing the sensors


After setting up the hardware, we can now test whether the sensors are working properly. To do so, we need to write a code to test both the digital temperature and humidity (DHT) sensor and the photocell.

Here is the complete code that I used in this project:

// Libraries
#include "DHT_Galileo.h"

// DHT sensor type
#define DHTTYPE DHT11 // DHT 11 

// DHT sensor pins
#define DHTIN 5
#define DHTOUT 6

// DHT instance
DHT_Galileodht(DHTIN,DHTOUT, DHTTYPE);

void setup()
{
  // Initialize the Serial port
Serial.begin(115200);

  // Init DHT
dht.begin();
}

void loop()
{
  // Measure from DHT
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();

  // Measure light level
floatsensor_reading = analogRead(A0);
float light = sensor_reading/1024*100;

  // Display temperature
Serial.print("Temperature: ");
Serial.print((int)temperature);
Serial.println(" C");
   // Display humidity
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println("%...