Mass storage for the Photon

Has anyone integrated mass storage with their Photon so that one may log a lot of data offline where access to a WiFi network is not possible? The data might be dumped when WiFi connectivity is established or if this is an SD card, the card itself could be transferred for offline analysis.

there is an SD card library already.
Have a search on the forum :sunglasses:

@ScruffR I use that library for my Core project and it works very well. However when I try to compile for the Photon I get the following error.

sd-card-library/sd2-card.cpp: In member function 'uint8_t Sd2Card::sparkSPISend(uint8_t)':
This looks like an error in sd-card-library library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
sd-card-library/sd2-card.cpp:764:40: error: 'struct GPIO_TypeDef' has no member named 'BSRR'
 PIN_MAP[mosiPin_].gpio_peripheral->BSRR = PIN_MAP[mosiPin_].gpio_pin; // Data High
                                    ^

This looks like an error in sd-card-library library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
sd-card-library/sd2-card.cpp:766:40: error: 'struct GPIO_TypeDef' has no member named 'BRR'
 PIN_MAP[mosiPin_].gpio_peripheral->BRR = PIN_MAP[mosiPin_].gpio_pin; // Data Low
                                    ^

This looks like an error in sd-card-library library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
sd-card-library/sd2-card.cpp:768:40: error: 'struct GPIO_TypeDef' has no member named 'BSRR'
PIN_MAP[clockPin_].gpio_peripheral->BSRR = PIN_MAP[clockPin_].gpio_pin; // Clock High
                                    ^

This looks like an error in sd-card-library library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
sd-card-library/sd2-card.cpp:774:40: error: 'struct GPIO_TypeDef' has no member named 'BRR'
PIN_MAP[clockPin_].gpio_peripheral->BRR = PIN_MAP[clockPin_].gpio_pin; // Clock Low
                                    ^

My understanding was that this was on a list to get fixed so the library works for the Photon. Is that correct or am I doing something else wrong. Sorry these messages are over my head. I am using the WebIDE

Those messages are happening because the library is using low-level digital I/O specifically for the Core. We have recently made functions for this, so that library writers can easily target all our platforms with the same code. The original library authors just need to use these functions to provide cross-platform compatibility.

There seems to be a Photon compatible port of that library already online in Particle Build (Web IDE).
It’s called sd-card-library-photon-compat

I’ve not tested it, but the example spark-datalogger.ino builds without error once you change the following lines of the sample

// *** change this include                      ***
//#include "sd-card-library/sd-card-library-photon-compat.h"
// to
#include "sd-card-library-photon-compat/sd-card-library-photon-compat.h"

// *** and                                      ***
// *** comment this redeclaration of chipSelect ***
// change this to match your SD shield or module;
//const int chipSelect = A2;

The copy i use is here: https://github.com/kennethlimcp/particle-examples/tree/master/sd-library

@ScruffR thank you very much. That library wasn’t showing in my list until I refreshed the libraries. Changed the include line in my program, ran verify and to my surprise, I got the coveted “Code Verified, Great Work” :sunglasses:

Now I have my work cut out for me this weekend exchanging the core for the photon and tweaking any electrical issues that may crop up with the A/D section.

Thanks again.

1 Like