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.
