My Serial return looks good:
... Initializing...
... Connected!
... Request DHCP
... Attempting to connect to plotly's REST servers
... Connected to plotly's REST servers
... Sending HTTP Post to plotly
... A-ok from plotly, All Streams Go!
... View your streaming plot here: https://plot.ly/~mjwilsun/4
... Connecting to plotly's streaming servers...
... Connected to plotly's streaming servers
... Initializing stream
... Done initializing, ready to stream!
And here is the code I'm working with:
Code: Select all
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <plotly_streaming_cc3000.h>
#define photoresistor_pin 0 //analog pin 0
#define WLAN_SSID "Wifi Name"
#define WLAN_PASS "Wifi PW"
#define WLAN_SECURITY WLAN_SEC_WPA2
// Sign up to plotly here: https://plot.ly
// View your API key and streamtokens here: https://plot.ly/settings
#define nTraces 1
// View your tokens here: https://plot.ly/settings
// Supply as many tokens as data traces
// e.g. if you want to ploty A0 and A1 vs time, supply two tokens
char *tokens[nTraces] = {"Plot.ly Token"};
// arguments: username, api key, streaming token, filename
plotly graph("Plot.ly Name", "Plot.ly Key", tokens, "filename", nTraces);
void wifi_connect(){
/* Initialise the module */
Serial.println(F("\n... Initializing..."));
if (!graph.cc3000.begin())
{
Serial.println(F("... Couldn't begin()! Check your wiring?"));
while(1);
}
// Optional SSID scan
// listSSIDResults();
if (!graph.cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
Serial.println(F("Failed!"));
while(1);
}
Serial.println(F("... Connected!"));
/* Wait for DHCP to complete */
Serial.println(F("... Request DHCP"));
while (!graph.cc3000.checkDHCP())
{
delay(100); // ToDo: Insert a DHCP timeout!
}
}
void setup() {
graph.timezone = "America/Los_Angeles",
graph.maxpoints = 1000;
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
wifi_connect();
bool success;
success = graph.init();
if(!success){while(true){}}
graph.openStream();
}
void loop() {
int sensor_reading = analogRead(photoresistor_pin);
graph.plot(millis(), sensor_reading, tokens[0]);
delay(5000);
}