I'm using a Micro-SD-Storage-Board-SD-TF-Card-Memory-Shield-Module-SPI-For-Arduino-N30 (pic attached)
#include <dht.h>
dht DHT;
#define DHT11_PIN 7
#include <SD.h> //The libraries we need
#include <SPI.h>
#include <Wire.h>
const int chipSelect = 8; //Maybe not yours!!.You have to put your cs pin here
File Datos;
void setup()
{
Serial.begin(9600);
SD.begin(chipSelect);
Datos = SD.open("Datos.csv", FILE_WRITE); //Will open and write once just for headers
Datos.println("Tempeture, Humidity, Dewpoint"); //Print headers (not saved yet)
Datos.close(); //Print saved
}
void loop()
{
int chk = DHT.read11(DHT11_PIN);
Serial.print("Temperature = ");
Serial.print(DHT.temperature);
Serial.print("*C");
Serial.println();
Serial.print("Humidity = ");
Serial.print(DHT.humidity);
Serial.print("%");
Serial.println();
double gamma = log(DHT.humidity / 100) + ((17.62 * DHT.temperature) / (243.5 + DHT.temperature));
double dp = 243.5 * gamma / (17.62 - gamma);
Serial.print("Dew point = ");
Serial.print(dp);
Serial.print(" *Celcius ");
Serial.println();
Datos = SD.open("Datos.csv", FILE_WRITE); //Will open and write according to delay
Datos.print(DHT.temperature); //Print mesage(not saved yet)
Datos.print(DHT.humidity); //Print mesage(not saved yet)
Datos.print(dp); //Print mesage(not saved yet)
Datos.println("");
Datos.close();
delay(1000);
}
