So here's my problem, I've built a karting lap timer that uses an IR beam to trigger the lap time each time the kart passes the pits. I have a Micro SD card which I'm writing the lap times to - this works very well however the SD card is pulling around 12mA even after writing the times and after I've closed the file - myFile.close(); I need to get the timer to run for at least 24 hours including running a screen so mA's are crucial. Without the SD card attached the device only uses about 13mA, with it attached its running at 17mA and when begun - sd.begin() - it jumps to 25mA. This is too much for the batteries (4 x AAA, can't use AA's as the space isn't enough). Different cards behave differently as one of my cards jumps to over 40mA when SD.begin()
Also if I remove the card it jumps back to 13mA but on re inserting the card the whole system restarts, not sure why?
Is there a way to switch off the SD card when not required etc either with software (preferred) or with a hardware method? I've seen that turning off the SCK pin can put SD cards to sleep, is there any way to do this? I've also seen an N-MOSFET being used on the gnd line to swith the SD card off, anyone got any experience of this?
Or is my code wrong? here's a sample
myfile = SD.open("times.csv", FILE_WRITE);// Open SD Card File if (myfile) {// if the file opens ok myfile.print("Lap,");//Start line with Lap myfile.print(lapcount);//add the lap count to the file myfile.print(",");//add a comma for use in excel later myfile.println(laptime);//save laptime and start new line myfile.close();// close and save the file }
Thanks