You are on page 1of 10

INSTRUMENTATION

AND CONTROL
Experiment No. 4: Data Logger using Arduino

Name: SALVADOR, MIKEE ANGELA B. Date of Submission: ________________


Course/Year/Section: BSEE 4-A

Instructor: Engr. Darrel D. Pasalo


Experiment No. 4: Data Logger Voltage using Arduino EE 147: Instrumentation
and Control

OBJECTIVES

1. Design a Data Logger using Arduino.


2. Write a program that will gather the data using Arduino.
3. Store a data using Arduino.

COMPONENTS/EQUIPMENT
 Computer/Laptop (with Arduino IDE)
 RTC DS3231
 SD Card Module
 Breadboard
 Male to Female DuPont Wire
 Male to Male DuPont Wire

INTRODUCTION/DISCUSSION

Real Time Clock or RTC is a timekeeping device in the form of an Integrated


Circuit or IC. RTC is an integral component of many time critical applications and
devices like Servers, GPS, Data Loggers. The DS3231 is an RTC IC developed by Maxim
Integrated. It is a low cost, extremely accurate RTC IC with communication over I2C
Interface. An interesting feature of DS3231 RTC IC is that it has integrated crystal
oscillator and temperature sensor.

The DS3231 can keep track of seconds, minutes, hours, days, dates, months, and
years. For months with fewer than 31 days, it automatically adjusts the date at the end
of the month, including leap year corrections (valid up to 2100). It can work in either a
12-hour or 24-hour format and has an AM/PM indicator. It also has two time-of-day
alarms that can be programmed.

1 Electrical Engineering Department COE MMSU


Experiment No. 4: Data Logger Voltage using Arduino EE 147: Instrumentation
and Control
Storing data is one of the most important parts of every project. There are
several ways to store data according to the data type and size. SD and micro SD
cards are one of the most practical ones among the storage devices, which are
used in devices such as mobile phones, minicomputers and etc. SD cards or Micro

SD cards are widely used in various applications, such as data logging, data visualization,
and many more. Micro SD Card Adapter modules make it easier for us to access these
SD cards with ease. The Micro SD Card Adapter module is an easy-to-use module with
an SPI interface and an on-board 3.3V voltage regulator to provide proper supply to the
SD card.

PROCEDURES

CODE:

#include <EduIntro.h>

#include <Wire.h>

#include <ds3231.h>

#include <SPI.h>

#include <SD.h>

DHT11 dht11(D7); // creating the object sensor on pin 'D7'

struct ts t;

int C; // temperature C readings are integers

float F; // temperature F readings are returned in float format

int H; // humidity readings are integers

2 Electrical Engineering Department COE MMSU


Experiment No. 4: Data Logger Voltage using Arduino EE 147: Instrumentation
and Control

void setup()

// initialize serial communications at 9600 bps

Serial.begin(9600);

Wire.begin();

DS3231_init(DS3231_CONTROL_ADDR);

t.hour = 11;

t.min = 05;

t.sec = 0;

t.mday = 23;

t.mon=12;

t.year=2022;

DS3231_set(t);

while (!Serial){

Serial.print("Initializing SD card ...");

if (!SD.begin(10)){

Serial.println("Card failed, or not present");

while(1);

3 Electrical Engineering Department COE MMSU


Experiment No. 4: Data Logger Voltage using Arduino EE 147: Instrumentation
and Control
}

Serial.print("Card initialized data");

void loop(){

dht11.update();

C = dht11.readCelsius(); // Reading the temperature in Celsius degrees and store in


the C variable

F = dht11.readFahrenheit(); // Reading the temperature in Fahrenheit degrees and


store in the F variable

H = dht11.readHumidity(); // Reading the humidity index

DS3231_get(&t);

File dataFile = SD.open("data.txt",FILE_WRITE);

if (dataFile){

dataFile.print("Date : ");

dataFile.print(t.mday);

dataFile.print("/");

dataFile.print(t.mon);

dataFile.print("/");

dataFile.print(t.year);

dataFile.print("\t Time : ");

dataFile.print(t.hour);

4 Electrical Engineering Department COE MMSU


Experiment No. 4: Data Logger Voltage using Arduino EE 147: Instrumentation
and Control
dataFile.print(":");

dataFile.print(t.min);

dataFile.print(".");

dataFile.print(t.sec);

dataFile.print(" : ");

dataFile.print("H: ");

dataFile.print(H);

dataFile.print("\tC: ");

dataFile.println(C);

dataFile.close();

// Print the collected data in a row on the Serial Monitor

Serial.print("Date : ");

Serial.print(t.mday);

Serial.print("/");

Serial.print(t.mon);

Serial.print("/");

Serial.print(t.year);

Serial.print("\t Time : ");

Serial.print(t.hour);

Serial.print(":");

Serial.print(t.min);

Serial.print(".");

Serial.print(t.sec);

5 Electrical Engineering Department COE MMSU


Experiment No. 4: Data Logger Voltage using Arduino EE 147: Instrumentation
and Control
Serial.print(" : ");

Serial.print("H: ");

Serial.print(H);

Serial.print("\tC: ");

Serial.println(C);

delay(1000); // Wait one second before get another temperature reading

else{

Serial.println("Error opening data.txt");

Diagrams and figures

RTC DS3231

6 Electrical Engineering Department COE MMSU


Experiment No. 4: Data Logger Voltage using Arduino EE 147: Instrumentation
and Control

Pin Number Pin Name Description

1 32KHz 32KHz output

2 VCC DC Power Pin

3 INT/SQW Active LOW Interrupt or


Square wave output

4 RST Active LOW Reset

5-12 NC No Connection

13 GND Ground

14 VBAT Back-up Power Supply


Input from Battery

15 SDA Serial Data I/O

16 SCL Serial Clock Input

SD CARD MODULE

7 Electrical Engineering Department COE MMSU


Experiment No. 4: Data Logger Voltage using Arduino EE 147: Instrumentation
and Control

Pin Type Pin Description

GND Ground

VCC Voltage Input

MISO Master In Slave Out (SPI)

MOSI Master Out Slave In (SPI)

SCK Serial Clock SPI

CS Chip Select SPI

CONCLUSION

At the end of this experiment we were able to design a data logger a device
that save data from time to time. We use RTC (Real Time Clock). Details like the second,
minute, hour, day of the week, day of the month, month, and year—including the leap
year clarification provided by the module. Another intriguing feature is that it may run in
either a 12 or 24-hour mode. Data logging, data visualization, and many more
applications utilize SD cards or Micro SD cards often. We can access these SD cards
where we can store our data with simplicity thanks to Micro SD Card Adapter modules.
The Micro SD Card Adapter module is a user-friendly device with an SPI interface and
an internal 3.3V voltage regulator to supply the SD card with the appropriate power.

Data logging can be accomplished in many ways. This project demonstrates an


application and the capabilities of a data logger utilized to monitor sensor variables,
and the project highlights the data logger’s ability to aid in research. The date and time
of each case were documented by the data logger and saved on to a file on the SD

8 Electrical Engineering Department COE MMSU


Experiment No. 4: Data Logger Voltage using Arduino EE 147: Instrumentation
and Control
card. The file can be opened, and the information can be read in Excel where further
analysis can be completed.

Data logger technology is evolving more quickly than ever. A device that
captures data but also has access to wireless communications for event warning,
automatic data reporting, and remote control is replacing the classic model of a stand-
alone data logger. Data loggers are starting to offer web sites for real-time readings,
email alarms, and FTP daily findings directly to users or into databases. There has been a
recent movement toward switching from proprietary items with commercial software to
hardware and software that are open source.

9 Electrical Engineering Department COE MMSU

You might also like