I want to send a txt file over my two xbees. I have the xbees set up the same PAN. I am writing a txt file that logs data from a COZIR sensor. I am sure it is a relatively simple command I am just having trouble.
I am using 2 arduino unos, 2 xbees series 2 (one as a AT ROUTER and the other as AT CONTROLLER) and 2 SD cards
The txt file that I want sent over is a log of my data. I would like to be able to access it from a single SD card so I do not have to individually load them to my computer.
Here is my code:
#include <SoftwareSerial.h>
#include "cozir.h"
#include <SD.h>
//Follow the following connection
//pin #1 -ground
//pin #3 -3.3V
//pin #5 -Digital 2
//pin #7 -Digital 3
SoftwareSerial nss(3,2);
COZIR czr(nss);
const int chipSelect = 4;
void setup()
{
Serial.begin(9600);
delay(3000);
//czr.SetOperatingMode(CZR_POLLING);
//czr.SetOperatingMode(CZR_STREAMING);
while (!Serial) {
}
Serial.print("Initializing SD card...");
pinMode(10, OUTPUT);
// see if the card is working
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
}
Serial.println("card initialized");
}
void loop()
{
float t = czr.Celsius();
float f = czr.Fahrenheit();
float h = czr.Humidity();
int c = czr.CO2();
int digi = czr.GetDigiFilter();
/* String dataString = "";
for (int analogPin = 2 ; int analogPin < 4; analogPin++ ) {
int cozir = analogRead (analogPin);
dataString += String (cozir) ;
if (analogPin < 3) {
dataString += "," ;
} */
Serial.print("Celcius : ");Serial.println(t);
Serial.print("Fahrenheit : ");Serial.println(f);
Serial.print("Humidity : ");Serial.println(h);
Serial.print("CO2 : ");Serial.println(c);
Serial.print("Digital Filter : ");Serial.println(digi);
File dataFile = SD.open("testrun3.txt", FILE_WRITE);
if (dataFile) {
dataFile.print(t);
dataFile.print(" , ");
dataFile.print(f);
dataFile.print(" , ");
dataFile.print(h);
dataFile.print(" , ");
dataFile.print(c);
dataFile.print(" , ");
dataFile.print(digi);
dataFile.println(" ");
dataFile.close();
delay(20000);
// print to the serial port too:
Serial.println(t);
}
Serial.print(dataFile);
}