SD card consuming power, even without 5V and groud connected

Hi all,

I am constructing temperature logger with use of Arduino pro mini, DS18B20 temperature sensor, DS3231 RTC clock and microSD card module. I have separate power line switched by transistor, where DS18B20, RTC and microSD module are connected. So i can turn this line on and off by digital pin.

Its all OK, but even if the separate power line is switched off, arduino is drawing about 1mA in sleep. Arduino alone consumes about 0,1mA. I figured out, that 0,9mA is used by SCK pin on microSD card module (pin 13 on arduino). How can i reduce current on that pin to zero? My project gonna be powered with AA cells, so power consumption is crucial.

Thanks for you suggestions!

Code:

// SD card attached to SPI bus as follows:
// ** MOSI - pin 11
// ** MISO - pin 12
// ** CLK - pin 13
// ** CS - pin 4
//RTC Clock
// SDA -Pin A4
// SCL -Pin A5

#include <SPI.h>
#include "LowPower.h"
#include <Wire.h>
#include <RTClib.h>
#include <DS3231.h>
#include <SdFat.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 3
int pinPowerSwitch = 5;

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);
// Init a Time-data structure
Time  t;

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Replace SS with the chip slect pin for your SD.
const int chipSelect = 4;

// SD file system.
SdFat sd;

// Log file.
SdFile dataFile;

float Temp = 0;   // temprature

void setup()   {
digitalWrite(pinPowerSwitch,HIGH);
delay(500);
  Serial.begin(9600);
  
  
 pinMode(10, OUTPUT); // required for SD lib
 pinMode(pinPowerSwitch, OUTPUT);
 
 digitalWrite(pinPowerSwitch,HIGH);
 digitalWrite(10,HIGH);

 
    

Serial.println("card initialized.");
 
  sensors.begin();
  rtc.begin();
  
  
}

void LogToSD(){
  digitalWrite(pinPowerSwitch, HIGH);
  
  delay(400);



// Get data from the DS3231
t = rtc.getTime();

sensors.requestTemperatures(); // Send the command to get temperatures
  
  Temp = sensors.getTempCByIndex(0);

// Initialize SdFat or print a detailed error message and halt
  // Use half speed like the native library.
  // change to SPI_FULL_SPEED for more performance.
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
    sd.initErrorHalt();
  }

  // open the file for write at end like the Native SD library
  if (!dataFile.open("test.csv", O_RDWR | O_CREAT | O_AT_END)) {
    sd.errorHalt("opening test.txt for write failed");
  }
  
Serial.println("SD file open ok");


    dataFile.print(t.date, DEC);
    dataFile.print('.');
    dataFile.print(t.mon, DEC);
    dataFile.print('.');
    dataFile.print(t.year, DEC);
    dataFile.print(';');
    dataFile.print(t.hour, DEC);
    dataFile.print(':');
    dataFile.print(t.min, DEC);
    dataFile.print(':');
    dataFile.print(t.sec, DEC);
    dataFile.print(';');
    dataFile.print(Temp);
    dataFile.println();    
    dataFile.close();  

      //Serial.println("end of write");
         
  // if the file isn't open, pop up an error:
  

      delay(300);
      digitalWrite(pinPowerSwitch, LOW);
      
 }
 
void loop() {

    digitalWrite(pinPowerSwitch, LOW);
    
    // Enter power down state for 8 s with ADC and BOD module disabled
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
    LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF); 
    
    
    // Do something here
    // Example: Read sensor, data logging, data transmission.
    
    LogToSD();  //Log to SD using commands under void LogToSD()       
    
  
}

Schematic?

Just a guess, but maybe one or more of the lines are active and parasitically powering the card. If that's the case you would want to drive them low before going to sleep.

Here is the schematics.

I tryed to set pin 13 to low every time i turn off the separate line, but without effect, but on pin 13, there is no current now. Propably current find another route to flow.

I believe the SD card uses SPI mode 0 which means that the clock is low when idle. But MOSI might be high. Have you checked it?

You can't change the value of pin 13 while SPI is enabled since the SPI logic overrides the normal port function. The same is true with MOSI. In order to change either of those you would have to first disable SPI.

Your schematic shows an Uno -- you're using a 3.3V pro mini, right?

I am using 5V Pro mini.

Your schematic shows an Uno (5V) connected directly to the SD card interface signals (max 3.6V). So either your circuit is flawed or your schematic is inaccurate. Or both. I can't tell.

On MOSI is 5V and zero current. The current in sleep is flowing through pin13/sck - 0,9mA. On sd card module board is 3,3V to 5V logic level converter SN74LVC125A and 5V to 3,3V stabilizator. (its not on the schematic, because i cant find this part in fritzing.

x-fox:
On MOSI is 5V and zero current. The current in sleep is flowing through pin13/sck - 0,9mA.

Are you saying SCK is 5V when the processor is asleep?

I suggest you read about the Cave Logger.

The final version will log data for many months with three AA batteries.

Most microSD cards will sleep at 100 μA or less. You don’t need to reinitialize the card if you keep it powered.

The final version of the logger sleeps at about 0.25 ma so 2000 mah AA batteries will power it for a long time.

Read Part 4 for more detail.