Reader small image

You're reading from  Intel Galileo Blueprints

Product typeBook
Published inJun 2015
Publisher
ISBN-139781785281426
Edition1st Edition
Tools
Concepts
Right arrow
Author (1)
Marco Schwartz
Marco Schwartz
author image
Marco Schwartz

Marco Schwartz is an electrical engineer, entrepreneur, and blogger. He has a master's degree in electrical engineering and computer science from Supélec, France, and a master's degree in micro engineering from the Ecole Polytechnique Fédérale de Lausanne (EPFL), Switzerland. He has more than five years' experience working in the domain of electrical engineering. Marco's interests center around electronics, home automation, the Arduino and Raspberry Pi platforms, open source hardware projects, and 3D printing. He has several websites about the Arduino, including the Open Home Automation website, which is dedicated to building home automation systems using open source hardware. Marco has written another book on home automation and the Arduino, called Home Automation With Arduino: Automate Your Home Using Open-source Hardware. He has also written a book on how to build Internet of Things projects with the Arduino, called Internet of Things with the Arduino Yun, by Packt Publishing.
Read more about Marco Schwartz

Right arrow

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("%...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Intel Galileo Blueprints
Published in: Jun 2015Publisher: ISBN-13: 9781785281426

Author (1)

author image
Marco Schwartz

Marco Schwartz is an electrical engineer, entrepreneur, and blogger. He has a master's degree in electrical engineering and computer science from Supélec, France, and a master's degree in micro engineering from the Ecole Polytechnique Fédérale de Lausanne (EPFL), Switzerland. He has more than five years' experience working in the domain of electrical engineering. Marco's interests center around electronics, home automation, the Arduino and Raspberry Pi platforms, open source hardware projects, and 3D printing. He has several websites about the Arduino, including the Open Home Automation website, which is dedicated to building home automation systems using open source hardware. Marco has written another book on home automation and the Arduino, called Home Automation With Arduino: Automate Your Home Using Open-source Hardware. He has also written a book on how to build Internet of Things projects with the Arduino, called Internet of Things with the Arduino Yun, by Packt Publishing.
Read more about Marco Schwartz