I am getting the following error when compiling a sketch.
Arduino: 1.5.7 (Mac OS X), Board: "Arduino Yún"
Build options changed, rebuilding all
Temboo_Email_Test.ino: In function 'void loop()':
Temboo_Email_Test.ino:71:13: error: too few arguments to function 'void logData(String)'
Temboo_Email_Test.ino:15:6: note: declared here
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
What is strange is that the function and the call to the function work just fine in another sketch.
This is the code I am using:
/* Yun specific */
#include <Bridge.h>
#include <Process.h>
/* Temboo Specifc */
#include <Temboo.h>
#include "TembooAccount.h" // Contains Temboo account information
int maxCalls = 10;
int calls = 0;
const short broadcastInterval = 10; // Interval between broadcasts in seconds
/* SD Card on Yun */
#include <FileIO.h>
/* Hall Effect Sensor */
const int hall_output = 12; // output of the hall effect sensor
int peaks = 0; // peaks since last transmission
/* Time Stamp */
unsigned long epoch; // UNIX timestamp when Arduino starts
unsigned long millisAtEpoch; // millis at the time of timestamp
unsigned long lastBroadcast; // timestamp at last broadcast
unsigned long currentBroadcast; // timestamp at current broadcast
/* Misc Items */
const int led = 13; // on-board led of Arduino Yun
int duration = 0; // duration to record for
/////////////////////////////////////////////////////////////////////
void setup() {
// Initialize Bridge
Bridge.begin();
// Initialize serial communications:
Serial.begin(9600);
// Initialize SD File System
FileSystem.begin();
// Initialize the on-board led as output and the pin connected
// to the hall effect sensor as input:
pinMode(led, OUTPUT);
pinMode(hall_output, INPUT);
// Wait for serial to be connected, remove this in the future
while(!Serial);
// Wait until connected to the Internet
//while(!isConnectedToInternet());
// Sync clock with NTP
setClock();
// Get time from Linino in Unix timestamp format
epoch = timeInEpoch();
lastBroadcast = epoch;
Serial.println("Ready for broadcasting...");
}
void loop() {
String dataString;
dataString += "Date-Time, Pulse Count/";
dataString += duration;
dataString += " millsec";
waitForPeak();
if((calcCurrentTimestamp() - lastBroadcast) > broadcastInterval) {
logData();
sendAlert();
}
}
/////////////////////////////////////////////////////////////////////
// Synchronize clock using NTP
void setClock() {
Process p;
Serial.println("Setting clock.");
// Sync clock with NTP
p.runShellCommand("ntpd -nqp 0.openwrt.pool.ntp.org");
// Block until clock sync is completed
while(p.running());
}
/////////////////////////////////////////////////////////////////////
// Return timestamp of Linino
unsigned long timeInEpoch() {
Process time; // process to run on Linuino
char epochCharArray[12] = ""; // char array to be used for atol
// Get UNIX timestamp
time.begin("date");
time.addParameter("+%s");
time.run();
// When execution is completed, store in charArray
while (time.available() > 0) {
millisAtEpoch = millis();
time.readString().toCharArray(epochCharArray, 12);
}
// Return long with timestamp
return atol(epochCharArray);
}
/////////////////////////////////////////////////////////////////////
// Return current timestamp, calculated by initial Linino's epoch + seconds past since then
unsigned long calcCurrentTimestamp() {
return epoch + ((millis() - millisAtEpoch) / 1000);
}
/////////////////////////////////////////////////////////////////////
// Wait for a peak. Turn the led on while hall effect output is 0V.
// Then turn led off and increase the number of peaks.
void waitForPeak() {
while(digitalRead(hall_output) == HIGH);
digitalWrite(led, HIGH);
delay(10); // small delay because a pass of the magnet might be counted as multiple peaks
while(digitalRead(hall_output) == LOW);
digitalWrite(led, LOW);
peaks++;
}
/////////////////////////////////////////////////////////////////////
void logData (String dataString){
// open the file. Note that only one file can be open at a time,
// so you have to close this one before opening another.
// The FileSystem card is mounted at the following "/mnt/FileSystema1"
File dataFile = FileSystem.open("/mnt/sd/WaterMon.csv", FILE_APPEND);
// if the file is available, write to it:
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
// print to the serial port too:
Serial.println(dataString);
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening WaterMon.csv");
}
}
/////////////////////////////////////////////////////////////////////
// This function return a string with the time stamp
String getTimeStamp() {
String result;
Process time;
// date is a command line utility to get the date and the time
// in different formats depending on the additional parameter
time.begin("date");
time.addParameter("+%D-%T"); // parameters: D for the complete date mm/dd/yy
// T for the time hh:mm:ss
time.run(); // run the command
// read the output of the command
while (time.available() > 0) {
char c = time.read();
if (c != '\n')
result += c;
}
return result;
}
/////////////////////////////////////////////////////////////////////
void sendAlert (){
}