Hi everyone,
I am using a SD card reader with an arduino nano to log temperature data. The SD card works very well using the arduino examples.
I am new with SD card readers so my knowledge is quite limited about it, but I noticed a 3.7V voltage between 3.3V and GND even when the wires are unpluged . I found it weird so I tried to figure out where that power came from , and it turns out that when I unplug the SCK and MOSI pins (both or one of the two), the 3.5 voltage disapears between VCC and ground.
The SD card will not work if not plugged to Arduino's VCC and GND pins, even if there is a 3.5V voltage to its power pins.
I don't have enough knowledge to tell if it's normal or not, but I want to be able to power off the the SD card reader and the temperature sensor (with a transistor for instance) , but with this behavior I don't think it will be possible because there will always be a voltage (which will power the temperature sensor).
Can someone tell me why is it acting like that ? Is that normal ?
SD card board : MH-SD card module
Wiring :
GND to Arduino GND
3V3 to 3V3 arduino
CS to pin 10
MOSI to pin 11
MISO to pin 12
SCK to pin 13
After you disconnect those two lines from the SD module, what's the voltage on those two pins on the Nano? Are they at 5V?
Can you confirm that your SD module is for microSD, and has a xxx125A chip on it? Do you have a link or a picture?
I'm perplexed by your driving the card directly from the 3.3V output of the Nano. I don't think that output provides enough current to power an SD card.
But as LarryD says, it's probably because SCK and MOSI idle in the high state, and that voltage is flowing back through protection diodes to the 3.3V rail of the module. You may be able to change the Select mode of those pins back to GPIO (from SPI) on the Nano, and set them to INPUT mode before going to sleep. Then change them back to SPI mode when you need to communicate with the SD card.
For the 328P, the SPE bit (bit 6) of the SPCR register appears to enable the SPI function, including the functioning of the SPI pins. If SPE is set, SPI is enabled, and the SPI pins are controlled by the SPI peripheral. If it is cleared, SPI is disabled, and the SPI pins return to being normal GPIO pins, which you can then set low or floating before going to sleep. At least that's my theory.
Search for Back feeding thru the input protection diodes .
Ok thx I'll look into that
After you disconnect those two lines from the SD module, what's the voltage on those two pins on the Nano? Are they at 5V?
I am supplying it with 3.3V , and yes the nano does provide 3.3V
Can you confirm that your SD module is for microSD, and has a xxx125A chip on it? Do you have a link or a picture?
It's for SD and not mini SD, it does not precise the chip though.
I'm perplexed by your driving the card directly from the 3.3V output of the Nano. I don't think that output provides enough current to power an SD card.
It seems to work well, I can write data on it so I guess it's ok , at least for the time of debugging.
In the final wiring the sd card reader will be powered by a 3.3V voltage regulator supplied by the battery.
I'll try to put the SPI pins in normal GPIOs and I'll keep you in touch.
If it is cleared, SPI is disabled, and the SPI pins return to being normal GPIO pins, which you can then set low or floating before going to sleep. At least that's my theory.
It should. But when Googling, I found some people saying it didn't. But that could have been corrected in later versions of the IDE. It's certainly worth a try. And on wakeup you could just do an SPI.begin().
You may be supplying the module's 3.3V pin with 3.3V from the Nano, but if you are getting 3.7V on that pin when the power is removed, then SCK and/or MOSI must be supplying 5V. That's expected if the Nano itself is running on 5V.
This is further complicated by the fact that your standard size SD module does not provide any voltage translation to bring the SCK, MOSI and CS lines down from 5V to 3.3V, which is what your SD card will want. I believe that listing's statement that it is Arduino compatible is a false statement for any 5V Arduino. I'll show below what I believe is the schematic for your module, which also shows one way to modify it so it will not damage the SD card. To be clear, if you power the SD card at 3.3V, exposing its I/O pins to 5V will exceed the card's Absolute Maximum for the voltage you can apply to any pin. I know these modules are widely used, but the schematic doesn't lie. They are only suitable for Arduinos like the 3.3V Pro Mini unless you modify them.
By the way, The modifications should also solve the 3.7V problem.
That's expected if the Nano itself is running on 5V.
Yes my nano is 5V.
I put the diodes like you said , but the sd card is not recognized after that. So I came back to the previous wiring.
I succesfuly change my arduino nano to 3.3V by following this topic :
I was excepting this change to solve my issue , but I still have a voltage between 3.3V and GND (2.5V , it's better but still not acceptable). SCK , MOSI , MISO and CS are a 3.3V .
aren't the diode in the wrong way in your schematic ? I'm not sure to understand correctly what are their purposes...
Thank's for your patience !
Yes , I want to disconnect the ground from the sd card reader and the temperature sensor with a npn transistor . After read and wrote the data, the nano disconnect the ground from the GND bat by putting the pin connected to the base of transistor to LOW .
But because the SD card provides voltage from VCC and GND pins, the temperature sensor is powered too, so it doesn't work
Well if you've converted your Nano to 3.3V, then the diodes aren't needed. But for future reference, if you add the diodes and cut the traces on the bottom, then the three SPI output lines from the Nano can only pull the corresponding SD card pins low. When those lines go high to 5V, the diodes block that, and instead the existing pullup resistors (to 3.3V) on the SD module pull them high. That protects the SD card pins from exposure to 5V.
I did not understand that you were switching the ground off. I suspect 6V6gt is right about that being the problem. But even if you switch off the high side, you will still get backfeed from the SPI lines unless they are brought low.
But I'm not sure the 3.7V, now 2.5V, on the SD's Vcc matters if its ground is not connected. If you disconnect the ground of a module, the entire module will float toward the Vcc voltage (as measured with reference to the system ground). But that doesn't mean any current is flowing. Current will flow only if there is another path to ground that isn't disconnected. In your situation that path could be through the SPI lines or possibly the temperature sensor. I wish we had a drawing of your circuit.
Use a high side switch instead. Many voltage regulators have an enable input, for example.
But the idea is basically a bad one: you should never directly connect IO pins on powered devices with unpowered devices. Instead, use sleep modes to save energy.
Unfortunately, the Arduino Nano is a poor choice for that. See this excellent tutorial on low power operation: https://www.gammon.com.au/power
When it was just the SD module and the Nano, and you disconnected the module ground, then measured the module Vcc with your meter, what was your meter's negative lead touching? Which "ground"? And does the measurement change if you remove the SD card from its slot?
Anyway, no matter which side of the power supply you switch, you still have to consider the state of the I/O lines that connect back to the Nano. That would include the four SPI lines and the Data line of the sensor.