As the subject declares I am trying to access the SD card of the ELEGOO 2.8 TFT shield installed as a shield on a Arduino Mega. I found very confusing information while searching around probably confusing because I am just a fledgling with Arduino and its jargon.
I have figured out that Mega uses pins 51 t o 53 for comunicating with the SD card while the shield is for ARDUINO UNO that uses 10 to 13# insteaad.
I downloaded SDfat library and MCCUFRIEND_kbv. TRied to follow the instructions I found around but when I try to run the sketch named "showBMP_not_UNO" it keeps getting me the following error message
'SdFatSoftSpi' does not name a type; did you mean 'SdFatConfig_h'?
Can anyone provide a step-by-step guidance for a workaround?
Did you install the SdFat.h library via the Library Manager ?
The instructions in the example were written a few years ago. If you have a problem, please quote the SdFat.h version number (from the Library Manager)
Thanks David
it is version 2.
In the readme file There is an explicit warning highlighting that it is version 2 while version 1 is available at a specific link
Thanks for the feedback. My instructions were correct for SdFat.h v1.x
SdFat.h v2.x works differently
Please edit your showBMP_not_Uno example
#include <SPI.h> // f.k. for Arduino-1.5.2
#define USE_SDFAT
#include <SdFat.h> // Use the SdFat library
////SdFat.h v1.x - edit SdFatConfg.h : #define ENABLE_SOFTWARE_SPI_CLASS 1
//SdFatSoftSpi<12, 11, 13> SD; //Bit-Bang on the Shield pins SDFat.h v1
//#define SD_CS 10
////SdFat.h v2.x - edit SdFatConfg.h : #define SPI_DRIVER_SELECT 2
SoftSpiDriver<12, 11, 13> softSpi; //Bit-Bang on the Shield pins SDFat.h v1
#define SD_CS SdSpiConfig(10, DEDICATED_SPI, SD_SCK_MHZ(0), &softSpi)
SdFat SD;
#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
//#define SD_CS 10 //remember to comment this original define
In other words. The v1.x sequence was two statements. i.e. constructor and SD_CS define
The v2.x sequence works differently and needs three statements. i.e. two different constructors + complex SD_CS define
Please report back. Only tested with 8GB SD.
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.13\hardware\arduino\avr\libraries\SPI
Using library SdFat at version 2.0.4 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\SdFat
Using library Adafruit_GFX_Library at version 1.10.4 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_GFX_Library
Using library Mcufriend_kbv at version 2.9.9-Release in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Mcufriend_kbv
Using library Adafruit_BusIO at version 1.6.0 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_BusIO
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.13\hardware\arduino\avr\libraries\Wire
"C:\\Users\\David Prentice\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_497204/showBMP_not_Uno.ino.elf"
Sketch uses 31366 bytes (12%) of program storage space. Maximum is 253952 bytes.
Global variables use 1152 bytes (14%) of dynamic memory, leaving 7040 bytes for local variables. Maximum is 8192 bytes.
I'll be damned! You nailed it! Works like a charm now and reads the SD card flawlwssly. Thank you.
In your opinion should I watch out for some specific issues when trying to write data on the SD card?
I think the SD card is 32Gb but I need to double check. Anyway I'll be glad to buy a card that just works eventually.
Let me make some changes in my original sketch. Basically it is a garden-variety of a barograph project using this Elegoo 2.6 tft display and a BME280 pressure/humidity/temperature sensor with a buzzer alarming for fast drop in pressure levels. Sketch is too large for a Arduino Uno so I am forced to use Mega2560/R3.
The sketch needs to write the pressure readings on the SD card.
I'll certainly report the outcomes of my trying
Hi David, ive been having the same problems as Scud63 above and ended up using your code and it worked perfectly
(thank you by the way). But ive now started tinkering with it and came across another problem i have copied the void loop contents into the void setup section at the end... my reasoning being i wanted the picture open only once, but its coming up with an error "showBMP was not declared in this scope" i was presuming one of the included .h files declares this specifically for the void loop but i cant find it anywhere.
Is there any other way to work out where the problem bit is or just looking through files and try to make them global variables?
you need showBMP(), read16() and read32() functions.
sorry again, this is probably a daft question but how do i do that? ive looked through the sketch and through as many of the .h and .cpp files as are attached to find a base function to declare these as but cant find anything.
ive done points 2. and 3.
Daryn