Is it possible that's what's causing these new errors as I'm adding more functionality to the program?
Code: Select all
#include <SD.h>
#include <Wire.h>
#include <BMP085.h>
#include <RTClib.h>
#define sensorAddr 40
#define logInterval 2000 //Set the logging time in millis between logs
#define tempPin 3 //The input pin that the thermistor will read on
#define redLEDpin 11
#define greenLEDpin 12
#define sccAddress 40
BMP085 bmp;
RTC_DS1307 RTC;
File logfile;
const int chipSelect = 10;
int bmpTemp, bmpPress, tTemp, lPress, tCounter, pCounter, logTimer = 0;
float pressure = 0;
int tempArray[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int pressArray[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
volatile int bmpEOC = LOW; //Set up state for BMP085 EOC bit
volatile int startBit = LOW; //Set up state for 'start' button, set high here for no button start
void error (char *str){
digitalWrite(redLEDpin, HIGH);
while(1);
}
void setup() {
attachInterrupt(0, getI2C, RISING); //Interrupt to read EOC bit
attachInterrupt(1, start, RISING); //Interrupt to read 'start' button press
bmp.begin(); //Begin I2C communication as master
pinMode(10, OUTPUT);
if (!SD.begin(chipSelect)) {
return;
}
char filename[] = "LOGGER00.CSV"; //Create a file everytime startup occurs
for (uint8_t i = 0; i < 100; i++) { //...with a filename between LOGGER00 and LOGGER99
filename[6] = i/10 + '0';
filename[7] = i%10 + '0';
if (!SD.exists(filename)) { //Don't create the file until a name
logfile = SD.open(filename, FILE_WRITE); //...is found that doesn't exist
break;
}
}
if (! logfile) { //Give an error if the logfile could not
error("couldn't create file"); //be created.
digitalWrite(redLEDpin, HIGH);
}
Wire.begin();
if (!RTC.begin()) { //If the RTC could not be communicated with
logfile.println("RTC failed"); //...log the failure
digitalWrite (redLEDpin, HIGH); //...and light the error LED
}
logfile.println("Millis,Time,AmbPress,AmbTemp,LPress,LTemp"); //Attempt to write a header to the file
if (logfile.writeError || !logfile.sync()) { //If the header file could not be written
error("write header failure"); //...set an error code
digitalWrite (redLEDpin, HIGH); //...and light the error LED
}
pinMode(redLEDpin, OUTPUT);
pinMode(greenLEDpin, OUTPUT);
logTimer = millis();
}
void loop() {
if (bmpEOC == HIGH){
get_bmpTemp_Press(); //If conversion is done, get temp and pressure
}
tempArray[tCounter] = analogRead(tempPin) - 238; //Get the thermistor temperature and add to array
tCounter++; //Array count increased for thermistor averaging
if (tCounter == 10){
tTemp = average_array(tempArray); //Average every 10 samples
tCounter = 0; //...and reset the averageing counter
}
if (millis()-logTimer == logInterval) {
write_to_log(bmpPress, bmpTemp, lPress, tTemp);
}
}
void getI2C() {
bmpEOC = HIGH; //Conversion is done, set bit high
}
void start() {
startBit = HIGH; //'Start' button has been pressed
}
void get_bmpTemp_Press() {
bmpTemp = bmp.readTemperature(); //Get temperature
bmpPress = bmp.readPressure(); //Get pressure
bmpEOC = LOW; //Reset conversion bit after reading I2C
}
int average_array (int array[10]){
int i, tempHolder = 0;
for (i = 0; i < 11; i + 1){
tempHolder += array[i]; //Add all of the saved values in the array
}
return tempHolder/10; //...and divide by ten, returning a 10 sample running-average
}
void get_SCC_data (byte *a, byte *b){
Wire.requestFrom(sccAddress, 2);
*a = Wire.recieve();
*b = Wire.recieve();
}
int acquire_SCC_data (){
byte aa, bb;
boolean checkOk;
int counts = 0;
get_SCC_data(&aa, &bb);
for (int i = 1; i < 3; i++){
if(bitRead(aa, i) == 0){
checkOk = true;
}
}
if (checkOk == true){
counts = aa + bb;
}
else {
return 0;
}
pressure = (counts - 1638)/13107;
return pressure;
}
void write_to_log (int aPress, int aTemp, int lPress, int lTemp) {
DateTime now;
digitalWrite(greenLEDpin, HIGH); //Turn the green LED on
uint32_t m = millis(); //Log millis since power-up
logfile.print(m);
logfile.print(", ");
now = RTC.now();
logfile.print(now.get()); //Log date and time in YY/MM/DD HH:MM:SS format
logfile.print(", ");
logfile.print(now.year(), DEC);
logfile.print("/");
logfile.print(now.month(), DEC);
logfile.print("/");
logfile.print(now.day(), DEC);
logfile.print(" ");
logfile.print(now.hour(), DEC);
logfile.print(":");
logfile.print(now.minute(), DEC);
logfile.print(":");
logfile.print(now.second(), DEC);
logfile.print(", ");
logfile.print(aPress); //Log the Ambient Pressure
logfile.print(",");
logfile.print(aTemp); //Log the Ambient Temperature
logfile.print(",");
logfile.print(lPress); //Log the Line Pressure
logfile.print(",");
logfile.println(aTemp); //Log the Line Temperature
logTimer = millis(); //Reset the log timer
digitalWrite(greenLEDpin, LOW); //...and turn the green LED on
}
And the list of errors I get now;
line_audit_case.cpp: In function 'void setup()':
line_audit_case:55: error: 'class File' has no member named 'writeError'
line_audit_case:55: error: 'class File' has no member named 'sync'
line_audit_case.cpp: In function 'void get_SCC_data(byte*, byte*)':
line_audit_case:106: error: 'class TwoWire' has no member named 'recieve'
line_audit_case:107: error: 'class TwoWire' has no member named 'recieve'
line_audit_case.cpp: In function 'void write_to_log(int, int, int, int)':
line_audit_case:137: error: 'class DateTime' has no member named 'get'
Thanks for any help,
-Ian