There is a thread from 24 August - Photon and SD-Card library error - just wondering exactly how to fix the SD library file (SD2-CARD.cpp). I understand what the solution is in using pinSetFast() and pinResetFast(). I have included this library from the Web IDE and can see but not alter the file? I am in need of a quick fix as I need to demo a solution tomorrow. Thanks
Since editing is indeed not (yet) possible, you could copy&spastic the relevant files. Click the + icon in the top right corner to create new .h and .cpp files. Those are fully editable.
Alternatively, you could use Particle Dev, the ‘offline’ IDE.
You could also fork the library from GitHub, apply your changes there and import/contribute the library as private (only visible for you).
This might be the quicker way due to the amount of seperate files in the SD library.
Make sure to push the version number up in the spark.json
file.
Edit: @armor, have you not seen this library on Web IDE "SD-Card-Library-Photon-Compat"
I hadn’t - the original thread wasn’t updated as Solved. Good spot.
When you enter a part of the lib name (e.g. SD) in the search field of Web IDE lib drawer you get all libraries containing that part.
It’s a bit slow updating but quite helpful.
Have you managed to get this photon SD library to work? I have been having other issues and now I have got back to the SD card library with photon it doesn’t work. All seems OK with the build and flash and when run nothing happens - I am wondering whether some other change is required rather than just changing the library? I am setting the clock speed as HALF should this be left as FULL speed with the photon?
Thanks in advance for any advice.
I guess I have not got the same SD-Card shield as you, but mine (on-board with Adafruit HX8357 TFT display) works.
If it doesn’t work with HALF speed it’s even less likely to work FULL speed.
@armor, I’ve now dug up another SD shield (IoT Research POD µSD) and had some issues with this one, but not because of the library, but while my other one was powered via its mother TFT board I powered this one (out of convenience) from an GPIO pin, which caused some reading inconsistencies.
But once powered via 3V3 and GND it worked just fine.
I have gone back to an SD card reader board and that works fine with hardware SPI at any speed.
I then tried reading the SD card on the back of the TFT ST7735 board and that works fine with hardware SPI.
So it is not the library.
The problems start when I test the TFT adafruit_ST7735 library with it. There is something the photon does not like - it goes through a whole range of flashing red, green, cyan. I need to get down and be methodical to work out what’s causing this. I also really need to understand with the cheap ST7735 displays why I cannot get them to work as others appear to have done.
Update - I figured out the issue with the TFT display and have posted a solution for others if using the same type of board. Going back to my original build (porting a solution from Core to Photon) I am now unable to compile due to the following declare errors. I am rather struggling to understand why I am now getting these when this program compiled before I swapped in the photon compatible SD library. Anyone have any insights as to the cause.
The compile errors are:
powerhub1.cpp:67:17: error: 'File' was not declared in this scope
uint16_t read16(File &fi);
^
powerhub1.cpp:67:23: error: 'fi' was not declared in this scope
uint16_t read16(File &fi);
^
powerhub1.cpp:68:17: error: 'File' was not declared in this scope
uint32_t read32(File &fi);
^
powerhub1.cpp:68:23: error: 'fi' was not declared in this scope
uint32_t read32(File &fi);
^
There are then subsequent errors for any use of read32 and read16.