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

Logging data onto the SD card


Now that data from the sensors is being displayed on the serial monitor, we will log the results on an SD card. You need the following code to make this work.

You will notice that the following code is similar to the previous code; only a few parts are added. This is the complete code for this recipe:

// Libraries
#include "DHT_Galileo.h"
#include <SD.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 SD card
Serial.print("Initializing SD card...");

if (!SD.begin()) {
Serial.println("Card failed, or not present");
return;
  }
Serial.println("card initialized.");
system("/sbin/fdisk -l > /dev/ttyGS0");  

  // Init DHT
dht.begin();

  // Set date and time (only run once!)
  //system("date 171110202014"); //sets the date & time to 10:00 1st Jan 2014
}
void...