Hello everyone. I am new in the Arduino's world. I love it so far.
I have:
Arduino UNO
IR temperature sensor (measures ambient and object temp)
Data logger shield (https://www.tindie.com/products/Dead_Bug_Prototypes/extreme-low-power-data-logging-shield-for-arduino/)
I bought this shield because it can go to sleep using a "coin type" baterry. Also, has a slot for microSD.
I believe the WAKING UP stuff is with something called DS1337 ?? I found that in a sketch in the web site of the shield.
I want to make measures every 15 minutes, write it on the SD card, and put it to sleep 15 minutes. And so on,
I was able to make it do everything, but I CANT MAKE IT GO TO SLEEP AND COME BACK. Anyone knows about this??
This is my sketch, without any line for waking up (after this I put the sketch the developer sent me to try, but it's not working):
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_MLX90614.h>
const int chipSelect = 8;
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
RTC_DS1307 RTC;
File myFile;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
Wire.begin(); //IR Sensor
RTC.begin(); //IR Sensor
mlx.begin(); //IR Sensor
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(10, OUTPUT);
if (!SD.begin(8)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
DateTime now = RTC.now(); //IR SENSOR
myFile.print(now.day(), DEC);
myFile.print('.');
myFile.print(now.month(), DEC);
myFile.print('.');
myFile.print(now.year(), DEC);
myFile.print("\t");
myFile.print(now.hour(), DEC);
myFile.print(':');
myFile.print(now.minute(), DEC);
myFile.print(':');
myFile.print(now.second(), DEC);
myFile.print("\t");
myFile.print("SensorTemp=");
myFile.print("\t") ;
myFile.print(mlx.readAmbientTempC());
myFile.print("\t*C\tCorn=\t");
myFile.print(mlx.readObjectTempC());
myFile.println("\t*C");
myFile.println();
// close the file:
myFile.close();
Serial.println("done.");
}
else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
}
else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop()
{
// nothing happens after setup
}
This is the sketch the developer sent me, but is not working for me:
To have the logger wake up every 30 minutes you need to add the following function to your sketch.
void SetAlarmMin(uint8_t AntallMin)
{
Wire.begin(DS1337_ADDRESS);
Wire.beginTransmission(DS1337_ADDRESS);
Wire.write((byte) 0);
Wire.endTransmission();
Wire.requestFrom(DS1337_ADDRESS, 2);
Wire.read(); // hopper over sekunder
uint8_t mm = bcd2bin(Wire.read());
mm = mm + AntallMin;
if (mm 59) mm = mm - 60;
Wire.beginTransmission(DS1337_ADDRESS);
Wire.write((byte) 7);
Wire.write(0b00000000); // Alarm 1 sekunder
Wire.write(bin2bcd(mm)); // Alarm 1 minutter
Wire.write(0b10000000); // Alarm 1 timer (flagg satt)
Wire.write(0b10000000); // Alarm 1 dato (flagg satt)
Wire.write(0b00000000); // Alarm 2 minutter
Wire.write(0b00000000); // Alarm 2 timer (flagg satt)
Wire.write(0b00000000); // Alarm 2 dato (flagg satt)
Wire.write(0b00011101); // skru av ocillator og enable alarm 1
Wire.write((byte) 0); // Nullstill alt
Wire.endTransmission();
}
//This will take an integer and set the alarm accordingly with this function call in you main loop (that puts your logger to sleep)
SetAlarmMin(10); // Sets the alarm 10 minutes for now
THANKS!