The program works just fine when I've got the shield nested on top of the Mega. I'm able to data log and update my HMI even send control commands via the web interface to start/stop the process.
The problem comes when I attach them to the DIN Rail mounts for mounting inside the Panel enclosure of the environment. My SPI or something seems to not work and so the SD card isn't initializing and I can't log or send my webpage over the ethernet.
I am using https://www.adafruit.com/product/4555 for the Mega and https://www.adafruit.com/product/4556 for the shield, as shown here: https://photos.app.goo.gl/zVRqjRfzkd7zS97i6
After this set up didn't work, I have run wire from every single pin on each DIN mount and still the SD card is not accessible.
As you can see every single pin is connect on the Shield. The output of my program is:
For reference my SD initialization code is this:09:55:27.035 -> Initializing SD card...
09:55:29.707 -> ERROR - SD card initialization failed!
09:55:30.694 -> ERROR - Can't write to log.csv
09:55:30.726 -> ERROR - Can't write to log.csv
Code: Select all
void init_fs(void)
{
// initialize SD card
Serial.println("Initializing SD card...");
if (!SD.begin(4))
{
Serial.println("ERROR - SD card initialization failed!");
//TODO: Print Error message in HTML...Error LEDs/Codes -- blink Built-in
return; // init failed
}
Serial.println("SD card initialized.");
// check for index.htm file
if (!SD.exists(MAIN_FILE))
{
Serial.print("ERROR - Can't find ");
Serial.println(MAIN_FILE);
//TODO: Print Error message in HTML...Error LEDs/Codes -- blink Built-in
return; // can't find index file
}
Serial.println("index file present");
}
I'm not sure what else to try because I have a pin for pin connection on both of them. This somehow leads me to think its an ICSP problem but I've traced that out too.10:04:12.331 -> Initializing SD card...
10:04:12.363 -> SD card initialized.
10:04:12.407 -> index file present