Shield shield with Arduino data logging shield

Hi,

has anyone tried using the Particle Shield Shield with the Arduino data logging shield?
I haven’t even looked at the RTC capabilities of the logging shield yet, I am struggling to get access to the SD card already.
Any help or pointer in the right direction would be greatly appreciated!

Cheers,
Joscha

No I’ve not got the data logging shield, but have you replaced Arduino pins numbers (10,11,12,13) with the corresponding Photon pin names (D5, D2, D4, D4)?
Also you need to make sure that the used library supports soft SPI.

What libraries are you using?

BTW: The Photon has an RTC too.

What capabilities of the Logger Shield would you actually need?

Also, if all you need is storage on a SD card, I’ve had success just using a microSD breakout board and the SDFat library right on the Photon. I use the breakout board from SparkFun (DEV-13743, US$4.95) but Adafruit also has one, and you can find them even cheaper on eBay.

The software side is the SDFat library which is in the community libraries on Particle Build and also here on Github.

1 Like

Hi @ScruffR,

I have tried https://github.com/jeshuamaxey/photon-sd-library/ - have you used that before?

I gave SdFat library (https://github.com/greiman/SdFat-Particle) a try and used the following config:

#define SPI_CONFIGURATION 3
SdFatSoftSpi<D3, D2, D4> sd;
const uint8_t chipSelect = D5;

(MOSI - D2, MISO - D3, SCK - D4, CS - D5)

according to the pin mapping here: https://docs.particle.io/datasheets/particle-shields/#shield-shield-pin-mapping I’d have expected this to work, do you have any hints what I might be doing wrong?

The Photon RTC is good, however I need it to work when it has been offline, there is no internet and/or the power was cut. Hence I am relying on a battery-backed DS1307 (which is part of the logger shield). I got it to work with this library here: https://github.com/joscha/particle-ds-1307/ and have some code that leverages the RTC-stored date if Particle.timeSync() fails and updates the RTC when it succeeds.

Thanks @rickkas7, unfortunately I don’t have a breakout. In retrospect I think it would have been better to get an SD breakout and an RTC breakout, but for now I guess I am stuck with the shield.

@joscha, you don’t need an RTC breakout with Particle devices. It is built in to device and with Cloud connectivity, it will sync to the latest time automatically upon connection. Using the Photon’s Vbat pin, you can also add a backup battery to maintain the RTC and a portion of RAM (retained RAM)! :smiley:

1 Like

@peekay123 I have two Spark Core’s - I thought the VBAT pin was only available on the Photon? The Core has a 3.3* pin where the Photon has its VBAT pin.

Oh! You are correct about Vbat on the Core. Maybe it’s time to upgrade to photons! :wink:

I can try to attach my SD breakout board to the respective pins on the Shield Shield and see if I can make it work

stay tuned …

O @ScruffR that would be so nice!! Thank you!

Bad news (from my side at least)

While the below code works fine when connecting my SD breakout directly to the Photon pins it stops working when connecting via jumper wires from the Shield Shield pins.
The interesting thing is, only MOSI and SCK (Photon -> SD high speed signals) seem to cause the trouble.
I can jumper SS and MISO from shield to breakout and it still works, but once I try MOSI or SCK off the shield the connection goes.
So I’d say it’s something similar as with RX/TX on the Shield Shield that the level shifters are somewhat prone to signal noise.
Maybe @BDub can chime in here (as he did with the RX/TX issue) and give some hints to work around it (if possible).

You could still try with the two shields, since jumper wires perform worse than a PCB anyway. Maybe there’s also a way to reduce SoftSPI speed which could help the signal quality.

Tested with this code

#include "SdFat/SdFat.h"

// Software SPI on Shield Shield (Arduino pin)
// MISO => D3 (12), MOSI => D2 (11), SCK => D4 (13), SS => D5 (10)
SdFatSoftSpi<D3, D2, D4> sd;
const uint8_t chipSelect = D5;

File myFile;

void setup() {
  Serial.begin(9600);
  // Wait for USB Serial 
  while (!Serial) {
    SysCall::yield();
  }
  
  Serial.println("Type any character to start");
  while (Serial.read() <= 0) {
    SysCall::yield();
  }

  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
    sd.initErrorHalt();
  }

  if (!myFile.open("test.txt", O_RDWR | O_CREAT | O_AT_END)) {
    sd.errorHalt("opening test.txt for write failed");
  }

  Serial.print("Writing to test.txt...");
  myFile.println("testing 1, 2, 3.");
  myFile.printf("fileSize: %d\n", myFile.fileSize());
  
  myFile.close();
  Serial.println("done.");

  if (!myFile.open("test.txt", O_READ)) {
    sd.errorHalt("opening test.txt for read failed");
  }
  Serial.println("test.txt content:");

  int data;
  while ((data = myFile.read()) >= 0) {
    Serial.write(data);
  }
  myFile.close();
}

void loop() { }
1 Like

Thanks for your efforts @ScruffR! I have tried continuously as well and can’t get it to work - the Shield Shield does not seem to be widely used unfortunately, so maybe there is an issue that hadn’t been identified, yet. Seems as if I set on the wrong horse and should just have gone with breakouts for everything…

Cheers,
Joscha

There might still be tweaks. Let’s see what Brett thinks.
Worst case either the SD pins on the Logger shield could be rerouted or the level shifter on the Shield Shield could be bypassed.
Cut-open solder jumpers on all pins of the Shield Shield would be a nice thing to see for such cases in a revision of the design.

1 Like

The only advice I can give is keep the wires short leaving the Shield shield, and try not to add any resistive or capacitive load to the pins. This is just an unfortunate aspect of the active bi-directional level shifters that must be dealt with.

1 Like

Thanks @BDub,

Unfortunately I think the wires are as short as they will get:

An extra problem here is that you have two level shifters in series Shield shield 3.3V -> 5V -> Logger shield 5V -> 3.3V -> SD card.

A rather crude workaround (at least to test) might be to bend the pins 10-14 of the Logger shield so that the don’t enter the headers on the Shield shield and see if you get it working, if you use jumper wires from the Photon to the Logger shield headers.
Before bending you could also jumper Vin and GND to the Logger shield with it completely off the Shield shield.