Thanks to Paul S and Cattledog i was able to get a jump on this, but im still fumbling on what i thought would be the easier step
Using an Arduino a Mega and CC3000, i am attempting to post multiple streams to m2X, which requires an ISO 8601 time stamp in an array.
I am thinking i should probably use a character array, but how do i have variables in a character array? When i read tutorials and other posts, people seem to shy from strings, but im not sure what else to do?
the m2x header is as follows per their example:
const char *streamNames[] = { "temperature", "humidity" };
int counts[] = { 2, 1 };
const char *ats[] = { "2013-09-09T19:15:00Z",
"2013-09-09T19:15:10Z",
"2013-09-09T19:15:20Z"};
double values[] = { 10.0, 20.0, 7.5 };
*not entirely sure what the double values are??
Anyway, using this section of code i should be able to construct whatever variable will sit inside of the brackets instead of those constants:
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(' ');
Serial.print(month());
Serial.print("/");
Serial.print(day());
Serial.print("/");
Serial.print(year());
Serial.println();
Serial.print("Unix Time ");
Serial.println(now());
Serial.println();
the whole m2x example follows:
#include <jsonlite.h>
#include <SPI.h>
#include <WiFi.h>
#include "M2XStreamClient.h"
char ssid[] = "<ssid>"; // your network SSID (name)
char pass[] = "<WPA password>"; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;
char feedId[] = "<feed id>"; // Feed you want to push to
char m2xKey[] = "<M2X access key>"; // Your M2X access key
const char *streamNames[] = { "temperature", "humidity" };
int counts[] = { 2, 1 };
const char *ats[] = { "2013-09-09T19:15:00Z",
"2013-09-09T19:15:10Z",
"2013-09-09T19:15:20Z"};
double values[] = { 10.0, 20.0, 7.5 };
WiFiClient client;
M2XStreamClient m2xClient(&client, m2xKey);
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
while(true);
}
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("Connected to wifi");
printWifiStatus();
}
void loop() {
int response = m2xClient.postMultiple(feedId, 2, streamNames,
counts, ats, values);
Serial.print("M2x client response code: ");
Serial.println(response);
if (response == -1) while(1) ;
delay(5000);
}
the "ats" is used in one of the last lines
(note, about 10lines of wifi related code deleted from end)
thanks so much for the help i've recieved thus far from here. It has been immensely helpful for me to get started and gain an understanding.