2018
April Sunday 22

Bookmark and Share

Related Articles...

MILWAUKEE WI Arduino Meet Up Make Space

WANTED: CORE TEAM MEMBER TO HELP START NON-PROFIT GROUP.

WANTED: Angle Investor Start-Up Funding

Large Industrial Zoned Arduino Make Space Acquired!

Email :

COASMailBox @ gmail.com

World Class Tier 1 Embedded Computing Services

CGI Computer Wares

CONTACT:

COASMailBox @ gmail.com

Data Collectors, Loggers, IoT, Data Distribution Systems - Custom Builder Programmer With Continued Management & Support Subscriptions

38+ Years Independent Computer Science and Technology Research And Development Work.

Melbourne Australia Tier 1 Computer IT Management Business Support Subscription Service Laboratory Opportunity - Capital Investor & Core Team Members

Business Outsourced Tier 1 Computer Laboratoy - Managing All Electronics, And Computer Systems - Hardware, Formware and Software Application Deployments.

Tier 1 Computer Scientist and Engineer Founder Offering Investor And Core Team Member Opportunity

Contact:

COASMailBox @ gmail.com


2017 REVIEW

Arduino Writing DATA To CSV Files On SD Card

Data Logging

2017 NOVEMBER | by Gene Casanova

Senior Systems Engineer


Data Logging

The task of 'data logging', is to record (log) data values in real time to memory.

Record data values by separating each data value by a comma.  This format is referred to as "comma separated values" (CSV).  A CSV file enables logging values efficiently.


CSV - Comma Separated Data

Comma separated data, is simply, comma separated data.

CSV is a standard format for storing data.  Data is stored in a plain-text computer file.  Each line of text in the file, holds one record.  Each record can hold an unlimited amount of data fields.  Each data field, is delimited by a comma.

Example Data Logging CSV


12,c,15,c,20,c
13,c,14,c,21,c
14,c,13,c,22,c
13,c,14,c,23,c

Example 2 removes the known constants:


12,15,20
13,14,21
14,13,22
13,14,23

Real time measurement data, is collected efficiently; saving limited static memory space and time.  In the application, the values represent known constants.


CSV Data Recording

The task is to write a new line (row) of data to a storage file on an attached microSD memory card.

The following Arduino sketch, is experimental, intended as an example for learning the process and writing an effective Arduino sketch (source code):

/*
 * Writing Sensor Data to an attached microSD memory card.
 * EXPERIMENTAL
 * 2017
 * This example demonstrates how to write data
 * to a mciroSD flash memory card,
 * using the Arduino "SD" library.
 * 
 * Circuit:
 * microSD Card Reader/Writer Device,
 * attached to SPI bus on an Arduino:
 * SD Device ---> Arduino
* MOSI ---> pin 11
* MISO ---> pin 12 * CLK ---> pin 13 * CS ---> pin 10 Arduino UNO (pin 53 on Arduino MEGA)
*/
#include "SD.h"
#include"SPI.h" /*
* Hardware CS pin (select) on Arduino UNO is pin 10; * pin 53 on Arduino Mega; * Must be set to OUTPUT mode - required by the SD library: */
const int CSpin = 10; String dataString =""; // Variable to hold data to be written to microSD card. float sensorReading1 = 0.00; // value read from first sensor
float sensorReading2 = 0.00; // value read from second sensor
float sensorReading3 = 0.00; // value read from third sensor
File sensorData;

void setup()
{
// Open Serial Communication Port:
Serial.begin(9600);
Serial.print("Initialized SD Card.");
pinMode(CSpin, OUTPUT);

if (!SD.begin(CSpin)) { // If card present and initialized, then proceed: Serial.println("Card failed, or not present"); return; // stop process. } Serial.println("Card Initialized.");
}
void loop() { // Form data string dataString = String(sensorReading1) + "," + String(sensorReading2) + "," + String(sensorReading3); // convert to CS saveData(); // Write to SD card. delay(60000); // delay before next write to SD Card, adjust as required
}

void saveData(){
if(SD.exists("data.csv")){ // Check if file available.
// Append new data file
sensorData = SD.open("data.csv", FILE_WRITE);
if (sensorData){
sensorData.println(dataString);
sensorData.close(); // close the file } }else { Serial.println("Error writing to file !"); } }

Use The Technology Wisely & Keep It Simple

- Cheers!

Gene Casanova


Need More?   Need Help? ........Software, Network, System & Data Center Builder & Developer | Development Services Available - Freelance Small Jobs; To Outsourced Long Term Service Provider Contract Labor Available.

CGI Computer Wares | EST 1979

Send E-MailCONTACT: [click]@CGIComputerWares.com