Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

SD Data Recording

Home Forums Data Loggers SD Data Recording

This topic contains 1 reply, has 2 voices, and was last updated by  Sara Damiano 3 days, 9 hours ago.

  • Author
    Posts
  • #13303

    Gera
    Participant

    Hi all,

    I am trying to log data from a conductivity sensor to the SD card, for some reason it is not working. here is my code (I try to use code snippet but I could not make it look like how it suppose to be, I will try again when I am not too busy):

    #include <Arduino.h>
    #include <math.h>
    #include <Wire.h>
    #include <SD.h>
    #include <SPI.h>

    //Digital pin 12 is the MicroSD slave select pin on the Mayfly
    #define SD_SS_PIN 12

    //The data log file
    #define FILE_NAME “Conductivity.txt”

    //Data header (these lines get written to the beginning of a file when it’s created)
    #define LOGGERNAME “Mayfly microSD Card Tester”
    #define DATA_HEADER “Conductivity.txt”

    int pin12 = 12;
    File Conductivity1;
    int volta;
    float Division;

    void setup()
    {
    Serial.begin(9600);
    pinMode(SD_SS_PIN,OUTPUT);
    pinMode(22,OUTPUT);
    digitalWrite(22,HIGH);
    Division = 0.0048875;
    if (SD.begin(SD_SS_PIN))
    {
    Serial.println(“SD card on”);
    }
    else
    {
    Serial.println(“SD card activation failed”);
    }
    }

    void loop()
    {

    volta = analogRead(A3);
    float voltage = (volta)*(Division);
    File Conductivity1 = SD.open(“Conductivity.txt”,FILE_WRITE);
    Serial.println(“Conductivity = “);
    Serial.println(voltage);
    Conductivity1.println(LOGGERNAME);
    Conductivity1.println(“Conductivity = “);
    Conductivity1.println(voltage);
    delay (1000);

    Please may everybody tell me what I am doing wrong, i would appreciate.

  • #13315

    Sara Damiano
    Moderator

    I think

    should be

    You also should have a

    before the last delay.

    Are you using a Mayfly? Are you using the built-in microSD card slot or the vertical adapter? What output do you get?

    Did you ever get your program in your earlier thread to write to the SD card?

You must be logged in to reply to this topic.