This works perfectly well indoors with a 9-V wall wart supply to the buck-down converter. However, on a 6 D cell battery supply it triggers only a few power-ups and then stops. The battery supply voltage remains at about 8.8 V, plenty to power the buck-down converter. I do not understand the source of this intermittent operation of the TPL5110. Software problem? Hardware problem? Any ideas?
Here is the code:
Code: Select all
/*
Connections on Pro Mini:
"Done" to digital 5
"DRV" to VCC
See ads1115_test.
*/
#include <Wire.h>
#include <SD.h>
#include <SPI.h>
#include <RTClib.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads(0x48); // default address is 0x48
RTC_DS1307 rtc;
float V0,V1;
//float V2,V3;;
//float DtoA=0.015625/1000.;
float DtoA=0.007813/1000;
const int donePin=5,SDpin=10;
File logfile;
char filename[]="LOG00000.CSV";
void setup() {
//Serial.begin(9600);
// Power is applied...
pinMode(donePin,OUTPUT);
digitalWrite(donePin,LOW); // power on
//Serial.println("low power pin LOW");
//Serial.begin(9600);
Wire.begin(); rtc.begin();
if (!rtc.isrunning()) {
//Serial.println("RTC not running."); exit;
}
//rtc.adjust(DateTime(__DATE__, __TIME__));
//Serial.print("Initializing SD card...");
pinMode(10,OUTPUT);
if (!SD.begin(SDpin)) {
//Serial.println("Card failed.");
delay(50);exit(0);}
//Serial.println("card initialized.");
ads.begin();
//ads.setGain(GAIN_EIGHT); // full scale = 0.512 V
ads.setGain(GAIN_SIXTEEN);
int16_t adc0,adc1; // ADC reading produces 16-bit integers
//int16_t adc2,adc3;
adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
//adc2 = ads.readADC_SingleEnded(2);
//adc3 = ads.readADC_SingleEnded(3);
V0 = adc0 * DtoA;
V1 = adc1 * DtoA;
//V2 = adc2 * DtoA;
//V3 = adc3 * DtoA;
//Serial.print(adc0); Serial.print(" V0="); Serial.print(V0, 4); Serial.print(' ');
//Serial.print(adc1); Serial.print(" V1="); Serial.print(V1, 4); Serial.print(' ');
//Serial.print(adc2); Serial.print(" V2="); Serial.print(V2, 4); Serial.print(' ');
//Serial.print(adc3); Serial.print(" V3="); Serial.print(V3, 4); Serial.print(' ');
//Serial.println();
DateTime now=rtc.now();
logfile=SD.open(filename,FILE_WRITE);
logfile.print(now.year()); logfile.print(',');
logfile.print(now.month()); logfile.print(',');
logfile.print(now.day()); logfile.print(',');
logfile.print(now.hour()); logfile.print(',');
logfile.print(now.minute()); logfile.print(',');
logfile.print(now.second()); logfile.print(',');
logfile.print(V0,5); logfile.print(',');
logfile.print(V1,5); logfile.print(',');
//logfile.print(V2,5); logfile.print(',');
//logfile.print(V3,5);
logfile.println();
logfile.flush();
delay(250); logfile.close(); delay(250);
digitalWrite(donePin,HIGH); // power off
//Serial.println("low power pin HIGH");
}
void loop() {}