Hi!
I am a beginner, working on my first Arduino project! I want to measure the surface temperature of an alpine plant over the summer! I want it to log 3 times rapidly and then wait 15 minutes and log again.
I am using the Rocketscream Mini Ultra board (https://www.rocketscream.com/blog/product/mini-ultra/), the I2C sensor Melexis Contact-less Infrared Sensor - MLX90614 3V (Melexis Contact-less Infrared Sensor - MLX90614 3V [MLX90614ESF-BAA] : ID 1747 : $15.95 : Adafruit Industries, Unique & fun DIY electronics and kits), and the Adafruit Micro SD SPI or SDIO Card Breakout Board (Adafruit Micro SD SPI or SDIO Card Breakout Board - 3V ONLY! : ID 4682 : $3.50 : Adafruit Industries, Unique & fun DIY electronics and kits).
I am having some issues with power consumption, as it is using a lot of battery power in less than 3 days and stops logging. I have been working on trying to put it in sleep or standby mode to save power.
I am assuming I should connect the batteries to the BAT pin on the board, but I am seeing higher power consumption on this pin compared to VCC. I have added a paint drawing of how I have connected everything below.
Realistically, how low power can I get on "standby" with 2 x AA batteries? I am getting as low as 6 mA, but sometimes a lot higher power consumption. I was hoping to get as low as 1.2 mA, or under, so my batteries can last long enough. Is this possible?
As of now I have tried using the example from the LowPowerAVRZero library, found here:
RocketScream_LowPowerAVRZero/StandbyRTC.ino at master · rocketscream/RocketScream_LowPowerAVRZero · GitHub).
But when I put the code in the void toggle it would not read the temperature. It worked in void loop, but with high power consumption.
Here is the code that I could get to work, but this is without attachInterupt. Is this needed, and are there any other obvious issues in this code?
#include <RocketScream_LowPowerAVRZero.h>
#include <RocketScream_RTCAVRZero.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
const int chipSelect = 8;
const uint8_t unusedPins[] = {0, 1, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
uint8_t index;
for (index = 0; index < sizeof(unusedPins); index++) {
pinMode(unusedPins[index], INPUT_PULLUP);
LowPower.disablePinISC(unusedPins[index]);
}
RTCAVRZero.begin(false);
RTCAVRZero.enableAlarm(30, true);
if (!SD.begin(chipSelect)) {
while (1);
}
if (!mlx.begin()) {
while (1);
}
File dataFile = SD.open("datalog.csv", FILE_WRITE);
String header = "";
if (dataFile) {
header += String("Time");
header += ",";
header += String("Ambient 1");
header += ",";
header += String("Object 1");
header += ",";
header += String("Ambient 2");
header += ",";
header += String("Object 2");
header += ",";
header += String("Ambient 3");
header += ",";
header += String("Object 3");
header += ",";
dataFile.println(header);
dataFile.close();
}
}
void loop() {
String dataString = "";
dataString += String(millis());
dataString += ",";
dataString += String(mlx.readAmbientTempC());
dataString += ",";
dataString += String(mlx.readObjectTempC());
dataString += ",";
delay(1000);
dataString += String(mlx.readAmbientTempC());
dataString += ",";
dataString += String(mlx.readObjectTempC());
dataString += ",";
delay(1000);
dataString += String(mlx.readAmbientTempC());
dataString += ",";
dataString += String(mlx.readObjectTempC());
File dataFile = SD.open("datalog.csv", FILE_WRITE);
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
} else {
}
LowPower.standby();
}
Any tips or feedback would be highly appreciated!
Kind regards,
Sara