SD logging and Arduino TFT LCD screen


How to write data on SD card of the Arduino TFT LCD screen with Official Arduino Robot?

By default, on the Official Arduino Robot, µSD card reader located under the Arduino TFT screen is dedicated to read sound or bitmap. header file "ArduinoRobot.h" define it like that.

For our robot we want to save all our data into the µSD in the way to upload them later to a database using wireless connection.



Using the Robot::beginSD() is not interesting for us as it will initialize the Melody class to play music.

void RobotControl::beginSD(){
card.init();
file.init(&card);
melody.init(&card);
}
view raw RobotSdCard.cpp hosted with ❤ by GitHub
We prefer use directly SD method to manage SD directly.
'card' and 'file' are already defined into the main class of robot control 'Arduino.robot.h'.
SD card module is plugged into pin CARD_CS of the Arduino Robot control board. The management of this pin (due to SPI usage) is managed automatically by the LCD library part.

void setup() {
Robot.begin();
// SD reader init on pin CARD_CS (D8) of the 32u4
card.init(0,CARD_CS);
file.init(&card);
}
void loop() {
//...
// Save the data into µSD
if (file.open("AWBBlog.txt", O_RDWR | O_CREAT | O_APPEND)) {
// Write a line
//"YYYY-MM-DDTHH:MM:SS.mmm;FIX;SAT;LAT;LONG;ALT;LIGHT;TEMP;HYGRO;CO2;MICRO;NOTE"
file.print(F("20"));
file.print(gpsInfo.year);
//...
file.close();
//...
}
}

Related link:

1 comment:

  1. monitores touch screen our robot we want to save all our data into the µSD in the way to upload them later to a database using wireless connection.

    ReplyDelete