0% found this document useful (0 votes)
123 views2 pages

Data Logger 4 Sensor

This Arduino code uses a DHT11 temperature and humidity sensor to log sensor readings to an SD card and serial monitor. It initializes the DHT11 sensor, DS3231 real-time clock (RTC), and SD card. In the setup, it prints header labels and clears any previous data. In the loop, it reads the temperature, prints the data to the serial monitor and logs it to the SD card along with the date and time from the RTC.

Uploaded by

JUGI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views2 pages

Data Logger 4 Sensor

This Arduino code uses a DHT11 temperature and humidity sensor to log sensor readings to an SD card and serial monitor. It initializes the DHT11 sensor, DS3231 real-time clock (RTC), and SD card. In the setup, it prints header labels and clears any previous data. In the loop, it reads the temperature, prints the data to the serial monitor and logs it to the SD card along with the date and time from the RTC.

Uploaded by

JUGI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include "SPI.

h"
#include "DHT.h"
#include "DS3231.h"
#include "SD.h"

// Arduino data logger with SD card and DHT11 humidity and temperature sensor

#define DHTPIN 7 // DHT11 data pin is connected to Arduino pin 4


#define DHTTYPE DHT11 // DHT11 sensor is used
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT library
DS3231 rtc(SDA, SCL);

void setup() {
File dataFile = [Link]("[Link]", FILE_WRITE);
if (dataFile) {
[Link]("Date,Time,Temperature,Humidity"); //Write the first row of
the excel file
[Link]();
}
[Link]();
[Link](FRIDAY); // Set Day-of-Week to SUNDAY
[Link](23, 31, 45); // Set the time to [Link] (24hr format)
[Link](8, 11, 2019); // Set the date to January 1st, 2014 //INITIALIZING
PLX DAQ
[Link]("CLEARDATA"); //clears up any data left from previous projects
[Link]("LABEL,Date,Time,Temperature"); //always write LABEL, to indicate
it as first line
}

void loop() {
delay(500);
float t = [Link]();

[Link]("DATA"); //always write "DATA" to Indicate the following as Data


[Link](","); //Move to next column using a ","

[Link]("DATE"); //Store date on Excel


[Link](","); //Move to next column using a ","

[Link]("TIME"); //Store date on Excel


[Link](","); //Move to next column using a ","

[Link](t); //Store date on Excel


[Link](","); //Move to next column using a ","
[Link](); //End of Row move to next row

File dataFile = [Link]("[Link]", FILE_WRITE);

// if the file opened okay, write to it:


if (dataFile) {
[Link]([Link]()); //Store date on SD card
[Link](","); //Move to next column using a ","

[Link]([Link]()); //Store date on SD card


[Link](","); //Move to next column using a ","

[Link](t); //Store date on SD card


[Link](","); //Move to next column using a ","
[Link](); //End of Row move to next row
[Link](); //Close the file
}
else{
[Link]("OOPS!! SD card writing failed");
}
}

You might also like