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"...