Make a simple Data-Logger with Arduino UNO for your solar power plant

Published by MKDas on

Data Logger is a device that records data periodically with time and date which can be used in analysis of the system. In this article, we’ll make a solar data-logger. We will use Arduino UNO for this project. Memory card, Real Time Clock (RTC) will be used too. Lets start.

Disclaimer: Electricity is always dangerous. Skill required to work with electricity. Do work with your own risk. Author will not be responsible for any misuse or harmful act. This website contents is also copyright protected. Anything copied and directly posted in your website and claiming it as yours is prohibited and nonsensical. Author published all the articles as opensource to help you making your project and learning purpose only. Learn and make one for yourself. If need any help feel free to ask the author. Author will be helpful to you. Thanks.

What is Data-Logger?

A data logger is an electronic device that records data over time or in relation to location either with a built in instrument or sensor or via external instruments and sensors. Increasingly, but not entirely, they are based on a digital processor.

A commercial data logger

Data-Logger can be different types based on data types. Different size, different operating system. But they all do the same thing in basic. They records data over time. Sometimes, data is stored in local storage and sometimes, data is stored online. Here is an example of IoT based Data-Logger which logs data at IoT server over internet.

IoT based Data-logger [Click to check the device on their website]

Data-Logger basic block diagram:

For a basic data-logger this block diagram is common:

Basic Block Diagram of a Data-Logger.

About block diagram:

Most of the data-logger have this block diagram in common. There will be some inputs to sense the data. The inputs can be any type of data depending on the data-logger use. These data are collected and processed in the system then stored in local storage and some data-logger sends or stores these data over cloud or dedicated server. These types of data-logger are called IoT based data-logger.

Here, in this project we are going to make a local storage data-logger.

Circuit Diagram:

Here is the circuit diagram of this project:

Here in the circuit diagram, we used ACS712-30A current sensor to sense the current and resistors as the voltage sensor. Arduino UNO is working as our central system controller, ADCs are used to read the values and process inside. Then values are printed on LCD display. With time reading from DS1307 RTC IC, data is being saved on MMC periodically. The total system runs on battery and LM7805 based linear voltage regulator is used to proved a regulated 5V DC to MCU and other circuits.

About ACS712-30A:

ACS712 is a hall sensor based current sensor. This sensor can be used in both AC and DC circuit to sense the current. The 1.2 mΩ internal conductor resistance makes it low loss current sensor which is ideal in most of the cases.

ACS712-30A current sensor

Coding:

#include <LiquidCrystal.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
#include <SD.h>
#include <SPI.h>
const int chipSelect = 4;
LiquidCrystal lcd(10, 9, 8, 7, 6, 5);
short display_mode = 0;
int i = 0;
double current = 0.0;
double voltage = 0.0;
double power = 0.0;
int minute1 = 0, minute2 = 0;
int second1 = 0, second2 = 0;
void setup()
{
  lcd.clear();
  RTC.begin();
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);//cr
  lcd.print(F("Solar Datalogger"));
  Serial.begin(9600);
  Serial.println(F("Solar Datalogger project"));
  //RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time, run this line only once.
  pinMode(chipSelect, OUTPUT);
  MMC_int(); // mark when simulating only
  Creat_file();// mark when simulating only; Unmark in real hardware
  delay(2000);
  lcd.clear();
  display_mode = 0;
}

void loop()
{

  current = 0;
  for (i = 0; i < 20; i++)
  {
    current += float((2490 - (analogRead(0) * 4.8828125)) / 66.00); //in mV range 
    delay(1);
  }
  current /= 20;
  current = abs(current);


  lcd.setCursor(0, 1);
  lcd.print("I:");
  lcd.print(current, 3);

  voltage = 0;
  for (i = 0; i < 20; i++)
  {
    voltage += float(analogRead(1) * 0.54555368); //in mV range
    delay(1);
  }
  voltage /= 20;
  voltage = abs(voltage);

  lcd.setCursor(0, 0);
  lcd.print("V:");
  lcd.print(voltage, 3);

  power = float(voltage * current);
  lcd.setCursor(8, 1);
  lcd.print("P:");
  lcd.print(power, 3);
  lcd.print("W");

  DateTime now = RTC.now();
  lcd.setCursor(11, 0);
  if (display_mode == 0)
  {
    lcd.print(now.hour(), DEC);
    lcd.print(":");
    lcd.print(now.minute(), DEC);
    //lcd.print(":");
    //lcd.print(now.second(), DEC);
  }
  else
  {
    lcd.print(now.day(), DEC);
    lcd.print("/");
    lcd.print(now.month(), DEC);
  }
  second1 = now.second();
  if(second1>=59)second2=0;
  if (second1 >= second2+2)
  {
    if (display_mode == 1)display_mode = 0;
    else if (display_mode == 0)display_mode = 1;
    second2 = second1;
    if(second1>=59)second2=0;
    lcd.clear();
    File dataFile = SD.open("datalog.txt", FILE_WRITE);
    if (dataFile)
    {
      Serial.println(F("Saving data on SD card"));
      DateTime now = RTC.now();
      dataFile.print(now.hour());
      dataFile.print(":");
      dataFile.print(now.minute());
      dataFile.print(":");
      dataFile.print(now.second());
      dataFile.print(",  ");

      dataFile.print(now.day());
      dataFile.print("/");
      dataFile.print(now.month());
      dataFile.print("/");
      dataFile.print(now.year());
      dataFile.print("     ");
      dataFile.print(voltage,3);
      dataFile.print("  ");
      dataFile.print(current,3);
      dataFile.print("  ");
      dataFile.print(power,3);
      dataFile.println("  ");      
      dataFile.close(); // close the file
      Serial.println(F("Done."));
      dataFile.close();
      lcd.clear();
    }
    lcd.clear();
  }


}//loop


void Creat_file()
{
  File dataFile = SD.open("datalog.txt", FILE_WRITE);
  if (dataFile)
  {
    dataFile.println(" Data Logger for Soler energy started_");
    dataFile.println("Time >> Date  >>  Voltage(volts)  >>  Current(ampere) >>  Power(watt)  ");
    dataFile.close();
    Serial.println("file found and ready to write");
  }
}



void MMC_int()
{
  Serial.print(F("Initializing SD card..."));
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect))
  {
    Serial.println(F("Card failed, or not present"));
    // don't do anything more:
    while (1);
  }
  Serial.println(F("card initialized."));
}

//

No special code is used in this project. All codes are very simple and arranged in the easiest way. When your PCB is ready to test, first of all you need to set your clock. For that, you need to unmask this line:

RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time

Once your time is set, then mask the line again. Everything will be fine.

PCB:

I made this project in real life and used as a product which is being used since 2017 locally. Here is the PCB file of this project.

After making the project in hardware:

Data-logger in real life.

Test result:

I used this project as a product in a solar test field. Where it used to log the voltage and current reading. But on that time, I did not kept any video of the project. But today, I can share the simulated result.

Protesus simulation result

Conclusion:

In the end, I can say that as I made this project in real so you can use it too in your project without any hesitation. It will work fine if you follow everything I said.

I hope this project was helpful to you. If you make one for yourself, it will be a great pleasure for me. Anywhere you need help, let me know. Please share this project and subscribe to my blog. Thank you.


MKDas

Mithun K. Das; B.Sc. in EEE from KUET. Blog: https://labprojectsbd.com

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *