Hello and a very good day to all..
.
I'm a newbie in this area as i just learned about arduino and its capabilities when i started committing in my thesis.
Here i have an Arduino based temperature data logging assembly for my thesis. The assembly consists of:
SETUP:
1.Arduino UNO R3
2.Seeedstudio Solar Charger shield v2.0
3.TinyRTC i2c Module
4.SD-card breakout
5.19 pcs of DS18B20 waterproof thermal sensors[/li]
The sensors are connected in daisy-chain with cat5e cables spanding over 30m. The pullup resistor that i used were 1.3k. The solar charger shield was stacked on the UNO with RTC and sd-card breakout boards mounted on a breadboard and connected to UNO via jumper cables.
External power i used 6v rechargable battery and a 2w 80x180 solar panel.
PROBLEM:
The sketch that i wrote can be executed through the Serial Terminal with the USB connection. But cannot be executed when in standalone mode (external battery, USB unplug). The PWR LED is on. Been scratching my head for a couple of days now. How to get it running when the USB unplugged?
The code to my sketch:
//Project DataLogger Thesis
//
// 1)Library Used
//--------------------------------------
#include <DS1307RTC.h>
#include <Time.h>
#include <Wire.h>
#include <SD.h>
#include <OneWire.h>
#include <DallasTemperature.h>
//---------------------------------------
// 2)Variable Definitions
//---------------------------------------
#define ONE_WIRE_BUS 3 //one wire interface connection : digital pin 3
#define TEMP_PRE 12 //temperature precision , 9-12 bit
File File1;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Sensors Address Array
DeviceAddress s01 = { 0x28, 0x32, 0x57, 0xCD, 0x05, 0x00, 0x00, 0xC8 };
float tempC, tempF;
//SD Card Init...
void setup()
{
Serial.println("Initializing the SD Card...");
if(!SD.begin())
{
Serial.println("Initialization FAILED!");
return;
}
Serial.println("Initialization COMPLETE...");
Serial.begin(9600);
Serial.println("Type any character to start");
while (!Serial.available());
{
Serial.println();
sensors.begin();
Serial.println("Initialising Sensors...\n");
//set sensor resolutions
sensors.setResolution(s01, TEMP_PRE);
delay(100);
}
}
//Retrieving temperatures from sensors
void getTemperature(DeviceAddress deviceAddress)
{
sensors.requestTemperatures();
tempC = sensors.getTempC(deviceAddress);
tempF = DallasTemperature::toFahrenheit(tempC);
}
void loop()
{
tmElements_t tm;
File1 = SD.open("TEMPLOG.csv", FILE_WRITE);
Serial.println("File Opened.");
Serial.println();
if (File1)
{
if (RTC.read(tm))
{
File1.print(tm.Hour);
Serial.print(tm.Hour);
File1.write(':');
Serial.write(':');
File1.print(tm.Minute);
Serial.print(tm.Minute);
File1.write(':');
Serial.write(':');
File1.print(tm.Second);
Serial.print(tm.Second);
File1.print(",");
Serial.print(",");
File1.print(tm.Day);
Serial.print(tm.Day);
File1.write('/');
Serial.write('/');
File1.print(tm.Month);
Serial.print(tm.Month);
File1.write('/');
Serial.write('/');
File1.print(tmYearToCalendar(tm.Year));
Serial.print(tmYearToCalendar(tm.Year));
File1.print(",");
Serial.print(",");
}
else
{
if (RTC.chipPresent())
{
Serial.print(" DS1307 not working ");
}
else
{
Serial.print("DS1307 read error. check connection");
}
}
File1.print(" s01 : ");
File1.print(',');
Serial.print(" s01 : ");
getTemperature(s01);
File1.print(tempC);
Serial.print(tempC);
Serial.print(" C");
File1.write(',');
Serial.write(',');
Serial.println();
Serial.println("Data written");
}
File1.close();
Serial.println("File closed. \n");
Serial.println("Safe to disconnect card");
Serial.println();
delay(10000);
Serial.println();
Serial.println("Card in use, do not disconnect!!");
A COUPLE OF TWEAKS AND TRIALS:
- i've tried using different battery such as 3.7v 950mAH LiPo and also 9v LiOn, but both turn out to be the same. still no go on the sketch.
- i've commented out the while statement;
Serial.println("Type any character to start");
//while (!Serial.available());
Serial.println();
sensors.begin();
Serial.println("Initialising Sensors...\n");
..also find my self in dissapointment.
3. i've also tried resetting the UNO by pressing the reset button, but still..no initiation.
Hope to be saved from this mystery and get on with my thesis. Thank you all~ ![]()