Arduino project

Raspberry project

Post Page Advertisement [Top]


This tutorial shows how to make data logger by Arduino & SD card module
It will read data from real time module DS3231 (real time, temperature), then save data into text file which is latter imported into Excel file
Important thing of data logger is to know real time of recorded data, so real time DS3231 is used to read real time (link here to know how to use DS3231)
In this example, Arduino will read temperature (also from DS3231) and record in text file. Microsoft Excel will help us to import data from text file, from here we can draw a graph.

Hardware need to purchase
1. Arduino Pro Mini
2. Real time moduel DS3231
3. SD card module SPI
4. Micro SD card 8GB (with adapter)
1. Arduino Pro Mini
2. Real time module DS3231
3. SD card module SPI
4. Micro SD card 8GB




Step 1. Arduino SD card schematic




Step 2. Arduino SD card data logger code
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include "DS3231.h"

RTClib RTC;
DS3231 Clock;

int Year;
int Month;
int Date;
int Hour;
int Minute;
int Second;
int tempC;
int interval;
int Minute_last;

File myFile;

void setup() {
  Serial.begin(9600);
  Wire.begin(); //for DS3231
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  delay(2000);  //afer reset Arduino, 2s to take out SD

  Serial.print("Initializing SD card...");
  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
  }
  else
  {
    Serial.println("initialization done.");
  }
}

void loop() {
  interval = 1; //interval to write data
  DateTime now = RTC.now();
  Year = now.year();
  Month = now.month();
  Date = now.day();
  Hour = now.hour();
  Minute = now.minute();
  Second = now.second();
  tempC = Clock.getTemperature();
  
  if ((Minute % interval == 0)&(Minute_last!=Minute))
  {
    write_data(tempC);  //write data
    Minute_last = Minute;
  }
}

void write_data(int temperature_input)
{
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    myFile.print(Year);
    myFile.print("/");
    myFile.print(Month);
    myFile.print("/");
    myFile.print(Date);
    myFile.print(" ");
    myFile.print(Hour);
    myFile.print(":");
    myFile.print(Minute);
    myFile.print("_temperature_");
    myFile.println(temperature_input);
    myFile.close();
    Serial.println("Write file successful!"); //print out COM Port
  } else {
    Serial.println("error opening test.txt");
  }
}
What the code do is: Initialize the card, if any failure from here, it will show "initialization failed!". I got experience with it when the card 16GB can't be recognized by Arduino, but it works when replace new card 8GB.

Then the code read temperature from DS3231 and write data to file test.txt. It will inform out to COM screen the result of data writing activity.
In this code, Arduino will write data every 1 minutes (it is controlled by variable "interval", if change it into 5, then it will record data every 5 minutes)

The text file test.txt then will import to Excel by import data function

29 comments:

  1. At that point we embed a last circle completing a similar assignment toward the end. This circle is there just to watch that all rooms are truly associated.ExcelR Data Science Courses

    ReplyDelete
  2. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.

    digital marketing course

    ReplyDelete
  3. This Was An Amazing ! I Haven't Seen This Type of Blog Ever ! Thankyou For Sharing, data science courses

    ReplyDelete
  4. wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries.
    Data science Interview Questions
    Data Science Course

    ReplyDelete
  5. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.

    data science course

    ReplyDelete
  6. The camera memory card is where you store the images (and videos) until you can transfer them to your computer. There are different types of digital camera memory cards such as the CompactFlash (CF), Memory Stick (MS), MultiMediaCard (MMC), Secure Digital (SD), SmartMedia (SM) and xD-Picture Card (xD). The newest type of card is the Secure Digital High Capacity (SDHC) card. https://www.hugdiy.com/

    ReplyDelete
  7. The camera memory card is where you store the images (and videos) until you can transfer them to your computer. There are different types of digital camera memory cards such as the CompactFlash (CF), Memory Stick (MS), MultiMediaCard (MMC), Secure Digital (SD), SmartMedia (SM) and xD-Picture Card (xD). The newest type of card is the Secure Digital High Capacity (SDHC) card. bulk SD cards

    ReplyDelete
  8. Great blog. it was so Nice to read and useful to improve my knowledge as updated one,
    Machine Learning Training in Hyderabad

    ReplyDelete
  9. Cool stuff you have and you keep overhaul every one of us

    Correlation vs Covariance

    ReplyDelete
  10. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple linear regression

    ReplyDelete
  11. Great! Information you have been shared, it’s really very impressive and easy to understand please share more useful information like this. Thank you
    Data Science Training in Hyderabad
    Data Science Course in Hyderabad

    ReplyDelete
  12. Nice knowledge gaining article. This post is really the best on this valuable topic. instagram liker and followers app

    ReplyDelete
  13. Very interesting blog. Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome.You can also check my articles as well.

    Data Science In Banglore With Placements
    Data Science Course In Bangalore
    Data Science Training In Bangalore
    Best Data Science Courses In Bangalore
    Data Science Institute In Bangalore

    Thank you..

    ReplyDelete
  14. This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.

    Simple Linear Regression

    Correlation vs Covariance

    ReplyDelete
  15. You must have a lot of pride in writing quality content. I'm impressed with the amount of solid information you have written in your article. I hope to read more.
    SAP training in Mumbai
    Data Science training in Mumbai
    Best data science training in Mumbai
    SAP training in Mumbai

    ReplyDelete
  16. This Was An Amazing ! I Haven't Seen This Type of Blog Ever ! Thankyou For Sharing, data science training in Hyderabad

    ReplyDelete
  17. This post is great. I reallly admire your post. Your post was awesome.
    data science course in Hyderabad

    ReplyDelete
  18. Very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing, data science course in hyderabad with placements

    ReplyDelete
  19. I am looking for and I love to post a comment that "The content of your post is awesome" Great work!

    data science interview questions

    ReplyDelete
  20. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.

    Simple Linear Regression

    Correlation vs covariance

    KNN Algorithm

    Logistic Regression explained

    ReplyDelete
  21. Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple Linear Regression
    data science interview questions
    KNN Algorithm
    Logistic Regression explained

    ReplyDelete
  22. Excellent post. I learned a lot from this blog and I suggest my friends to visit your blog to learn new concept about technology.Best data science courses in hyerabad

    ReplyDelete
  23. Nice information thanks for sharing it’s very useful. This article gives me so much information.
    AWS Training in Hyderabad
    AWS Course in Hyderabad

    ReplyDelete
  24. I am looking for and I love to post a comment that "The content of your post is awesome" Great work!

    Simple Linear Regression

    Correlation vs Covariance

    ReplyDelete

Bottom Ad [Post Page]