MisterBotBreak
Published

How to Use a Datalogger

This project will show you how to use a datalogger and how to registered analog values on a SD card.

BeginnerProtip12 minutes2,084
How to Use a Datalogger

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Datalogger shield
×1
Photo resistor
Photo resistor
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Datalogger code

Arduino
This code will registered analog values read by the arduino on an SD card and create an excel file when this SD card is open on a computer.
#include <SPI.h> 
#include <SD.h>  

const char* filename = "Light.csv";

File file;

void setup() {
  Serial.begin(9600);
 
  pinMode(10, OUTPUT); 
  
  if (!SD.begin(10)) {
    Serial.println("Error : Push the reset button");
    for (;;); 
  }
  
  file = SD.open(filename, FILE_WRITE);
 
  if (file.size() == 0) {
    file.println("Brightness value per seconds");
    file.flush();
  }
}

void loop() { 
    measure();
    delay(1000);
}

void measure() {
  int lightvalue = analogRead(A0); 
  Serial.println(lightvalue);
  file.println(lightvalue);
  file.flush();
}

Credits

MisterBotBreak

MisterBotBreak

37 projects • 66 followers
I love electronic and I make explanatory project on how to control sensors.

Comments