Reading data from an SD card and displaying it on 16x2 LCD

I am fairly new to programming arduino.

I am datalogging the maximum and minimum voltage measured on A0 to a file created on an SD card.

I have managed to get the data stored onto the SD card as i had hoped but my ultimate goal is that when the arduino starts running the sketch, it opens the data file on the SD card, takes the last bits of data and then displays that data on the LCD before it moves to the main loop to look for new values.

My question is that if I am storing floats onto the SD card in a .txt file, when I read the data on the card back, what format is it in ? float,string,char?

This is my code so far, any suggestions?

/*
 This example shows how to read and write data to and from an SD card file  
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4
     
 */
 
#include <SD.h>
#include <SPI.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>  
#include <Statistic.h>

Sd2Card card;
SdVolume volume;
SdFile root;

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

const int inputPin = 7; //input pin for switch
const int ledPin = 8; //LED connected to pin 8 to show new maximum value
const int chipSelect = 4;

Statistic myStats;



//**************************************************************************************************************

void setup()
{
  Serial.begin(9600);
  
  myStats.clear(); //explicitly start clean

  lcd.begin(16,2); 
  lcd.backlight();
  lcd.clear();
  
  pinMode(ledPin, OUTPUT);
  pinMode(inputPin, INPUT);
  digitalWrite(inputPin,HIGH);
  
//-------------------------------- INITIALIZE SD CARD ---------------------------------------------------------
 
  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);
  
   if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present."); 
  }  
  
  if(!SD.begin(4)){
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  
  
 File myFile = SD.open("Max.txt", FILE_WRITE);// re-open the file for reading:
  
   
  if (myFile) 
    {
        String header = ("Max Data , Min Data");
        myFile.println(header);
        myFile.close();// close the file
        Serial.println(header); 
   } 
   
  else
  {
        Serial.println("error opening max.txt");// if the file didn't open, print an error:
  }
  
}
  
//-------------------------------------------------------------------------------------------------------------
   
   
//**************************************************************************************************************

void loop()
{
int sensorValue = analogRead(A0);   //read the A1 pin value (ADC Value)
  //Serial.print(sensorValue);
  float voltage= (sensorValue * 0.01992);   //convert the value to a true voltage.
  lcd.setCursor(0,0);      //set the cursor to the end of line 2
  lcd.print(voltage);         //print the voltage
  lcd.setCursor(0,1);     //set the cursor to the end of line 1
  lcd.print("VDC");        //print a label for the voltage
  delay(100);                 //this delay makes the display readout more stable and not flash
  
  myStats.add(voltage);
  
  float value1 = myStats.maximum();
  float value2 = myStats.minimum();

String dataString = String(value1) + "     ,  " + String(value2);

File myFile = SD.open("Max.txt", FILE_WRITE);
if (myFile)
{
myFile.println(dataString);
myFile.close();
Serial.println (dataString);
}
else 
{
Serial.println("Couldnt open File");
}

delay(2000);


if (myFile)
{
  while(myFile.available())
  {
    int output = (myFile.read());
  }
  

myFile.close();
Serial.println (output);
}
else 
{
Serial.println("Couldnt read File");
}




}

 

 //-------------------------------- MAXIMUM VALUE -----------------------------------------------------------------------------
 

 
  

 //-------------------------------- MINIMUM VALUE -----------------------------------------------------------------------------
    

//-------------------------------------------------------------------------------------------------------------

My question is that if I am storing floats onto the SD card in a .txt file, when I read the data on the card back, what format is it in ? float,string,char?

You are uselessly pissing away resources using the String class, so you are writing text to the file. You need to read the text, and parse and convert it, if you need floats.

But, since the LCD can't display a float, the conversions seems unnecessary.

Thanks for the advice.

I could do away with the String dataString and just write my floats (max and min) to the SD card. I have done this previousely.

I am interested in how I display data stored on the SD card back onto the LCD.

I think the LCD can display floats. I say this because it is doing it.