Hi
Be kind - this is my first post!
Background:
I've been working on a Temperature logger program for my greenhouse. Want to see how well the heated mats being used for early start of Chilli seeds is working. I've been doing this on a Uno and last year logged temperature from 5 sensors to SD card over a matter of weeks. Also have an RTC for time of measurement. This year I wanted to add a display but with that and the SD card I ran out of memory. So, I've just bought a Mega. I've learnt that it has different pins for things compared to Uno. Ihave RTC, Display and Temperature sensor all working. But surprise surprise I just cannot get the SD to work.
Problem:
I have an SD card module (cheap ebay one) works fine with a Uno. When I try and use it with the Mega I just cannot get the card to initialise. I am using the example files from SD library (1.2.4) as the programs. I have tried setting CS to 53 in code and i have tried movin CS wire to D10 on mega. I have it wired such:
- 50 MISO
- 52 SCK
- 51 MOSI
- 53 CS
I've read loads of posts but cannot get it to work.
I know it is a cheap SD module with no level shifter and have just tried the 3 diode fix, again works fine with Uno but not with Mega.
There seems to be a lot of people having issues with SD on Mega - more than on Uno
Question:
I've tried all that I know - can you suggest anything else? I've got a proper level shifting Micro SD on order but will be a few days yet.
Well my Micro SD module arrived in the post this morning. It has the level shifter i.c. on it! Tried it first with the Uno and a SanDIsk 32Gb uSD and it worked fine (CardInfo script). Ported module over to Mega and it worked first time
.
I had spent a little time looking at the wavefors of the signal on the Uno and then the Mega with th cheap SD module. They looked good on the Uno but quite different on the Mega. It seemed that there was an initial phase for CS that may have been 'missing' on the Mega. I'm wondering if the access speed is quicker on the Mega and the poor response time on the unbuffered SD module effectly filtered this initial pulse.
Any ideas on that? Is the Mega faster to SD or should it be exactly the same?
I'm not exactly clear on what your SD module is, but from the "three diode" comment, I assume it's the full-size SD module. If so, the problem with the three diode fix may be a question of speed. The diodes allow the Mega to (nearly) ground the three output lines, but the diodes block the 5V when they go back high, and the high at the SD card is just provided by a 10K pullup resistor. You can only go so fast doing it this way.
Here's a full size SD module which does have the level shifter:
But be aware that the above module, as well as most microSD modules from the Far East, do not properly release the MISO line when they are deselected, so they will not play well with others. If your sensors are also SPI, this could be a problem.