Remote Data Logger Programming

I am trying to create a remote temperature Data logger using an Arduino Mega 2560, TMP36 probe, Sparkfun Openlog Data logger(SparkFun OpenLog - DEV-13712 - SparkFun Electronics) , and a phone battery plugged in through USB B.

My goal is to turn the device on and have it collect data for 2-3 hours while it is out in the field, I can't have a computer plugged into it so I am hoping to store the data on the SD card and power it through the phone bank.

The problem I am having right now is programming it, this is my first real project with Arduino and I am not sure how to have things saved on an SD card rather than printed to the Serial Monitor.

I set up my circuit the exact same as the image I attached, however I don't have a GPS Unit plugged in so that can be ignored, along with the 9V battery.

Here is what I am trying to use:

#include <Arduino.h>

int sensePin = A5;  //This is the Arduino Pin that will read the sensor output
int sensorInput;    //The variable we will use to store the sensor input
double temp;        //The variable we will use to store temperature in degrees. 
void setup() {
  // put your setup code here, to run once:
 Serial.begin(9600); //Start the Serial Port at 9600 baud (default)


 
}

void loop() {
  // put your main code here, to run repeatedly:
  sensorInput = analogRead(A5); //read the analog sensor and store it
  temp = (double)sensorInput / 1024;   //find percentage of input reading
  temp = temp * 5;                     //multiply by 5V to get voltage
  temp = temp - 0.5;                   //Subtract the offset 
  temp = temp * 100;                   //Convert to Degrees
  Serial.print("Current Temperature: ");
  Serial.println(temp);
}

If I am doing anything obviously wrong please let me know! I appreciate any advice/comments.

I am having trouble figuring out how to write data to the SD Card, I am attempting to use this site:
https://learn.sparkfun.com/tutorials/openlog-hookup-guide#command-set

I don't think you want that OpenData logger device. It is designed to capture serial data. You are reading data from an analog pin and you just want to write it to the SD card. Just look at the examples that come with the SD library. It will show you how to open a file and print() the data to the file.

blh64:
I don't think you want that OpenData logger device. It is designed to capture serial data. You are reading data from an analog pin and you just want to write it to the SD card. Just look at the examples that come with the SD library. It will show you how to open a file and print() the data to the file.

This is the only datalogger I have, is it impossible to get it working the way I want? I also have a MAX31820 Temperature probe MAX31820 Datasheet and Product Info | Analog Devices
Would that work?

Using a dtatlogger like you have is probably easier than figuring out anything else.

Just make your program Serial.print whatever data you want to keep.

You can verify correct behaviour using the IDE serial monitor.

In the field, just hook up the OpenData logger and it will record in a text file. At home, use a text editor to see you data. Process however.

HTH

a7