I am using micro SD card to log reading from four force sensors connected to the microcontroller (MSP430G2553). Controller logs reading to the SD card every 15 minutes and goes to sleep. I am using 1000 mAh battery, which is lasting over a week. Is it possible to reduce the power consumption as to make it last over a month.
(#) Even if the microcontroller is sleeping for 15 minute, SD card is continuously consuming power.
(#) It takes couple of mA to write.
Help with any suggestion to reduce to power consumption drastically.
Schematic is shown below, code is inserted after the schematic.
#include <pfatfs.h> #include <pffconf.h> /*----------------------------------------------------------------------- Copy the file LOG.txt from this file's location to the root of the SD-Card. */ #include "SPI.h" #include "pfatfs.h" #define cs_pin 8 // chip select pin #define read_buffer 128 // size (in bytes) of read buffer //#define LOG_DELAY 200 // 5000ms -> 5sec unsigned short int bw, br; char buffer[read_buffer]; int rc; DIR dir; /* Directory object */ FILINFO fno; /* File information object */ uint32_t sensor1; uint32_t sensor2; uint32_t sensor3; uint32_t sensor4; uint8_t StringLength = 0; char buf[50]; uint32_t counter = 0; uint32_t AccStringLength = 0; unsigned long time; int count=0; int d=0; int c=1; uint32_t t1 = 0; uint32_t t2 = 0; uint32_t t3 = 0; uint32_t t4 = 0; void setup() { analogReference(INTERNAL2V5); pinMode(9, OUTPUT); pinMode(10,OUTPUT); Serial.begin(9600); FatFs.begin(cs_pin); Serial.print(" \nSerial output \n\r"); } /* Stop with dying message */ void die ( int pff_err ) { Serial.println(); Serial.print("Failed with rc="); Serial.print(pff_err,DEC); for (;;) ; } void printDec(uint32_t ui) { Serial.print(ui/10, DEC); Serial.print("."); Serial.print(ui%10, DEC); } void loop() { if(c==1) { digitalWrite(10,HIGH); delay(300); digitalWrite(10,LOW); delay(300); c++; } sensor1 = analogRead(2); delay(5); t1 = sensor1; sensor2 = analogRead(3); delay(5); t2 = sensor2; sensor3 = analogRead(5); delay(5); t3 = sensor3; sensor4 = analogRead(6); delay(5); t4 = sensor4; if(d==5) {{ rc = FatFs.open("LOG.TXT"); if (rc) die(rc); delay(5); bw=0; sprintf(buf,"%lu Output is %lu,%lu,%lu,%lu\r\n",counter,t1,t2,t3,t4); counter++; StringLength = strlen(buf); Serial.println(buf); rc = FatFs.lseek( AccStringLength ); if (rc) die(rc); AccStringLength = AccStringLength + 1024; rc = FatFs.write(buf,StringLength,&bw); if (rc) die(rc); rc = FatFs.write(0,0,&bw); //Finalize write if (rc) die(rc); rc = FatFs.close(); //Close file if (rc) die(rc); d=0; }} { d=d+1; } digitalWrite(9,LOW); sleep(7500); digitalWrite(9,HIGH); }