Couldn't connect to plotly's REST servers... trying again!

Hello,

I am working on a medical data logging project. I am using a Teensy 3.1 MCU and esp8266 module to connect to the internet.

The connection is successful but am not able to stream the data to the plotly site. Could anyone please help?

The following is my sample test code:

#include <WiFi.h>
//#include <avr/dtostrf.h>
#include “plotly_streaming_wifi.h”

#define nTraces 2
// 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] = {“us4dvqhhtw”, “ps2fdqzpcd”};

// arguments: username, api key, streaming token, filename
plotly graph = plotly(“krishnansrinidhi”, “LOBAJQPwUnXcGdNOcyjr”, tokens, “graph1”, nTraces);

#define ssid “teamASH” // change this to match your WiFi SSID
#define PASS “ash12345” // change this to match your WiFi password

#define BUFFER_SIZE 1024
char buffer[BUFFER_SIZE];

// By default we are looking for OK\r\n
char OKrn[] = “OK\r\n”;
byte wait_for_esp_response(int timeout, char* term=OKrn) {
unsigned long t=millis();
bool found=false;
int i=0;
int len=strlen(term);
// wait for at most timeout milliseconds
// or if OK\r\n is found
while(millis()<t+timeout) {
if(Serial1.available()) {
buffer[i++]=Serial1.read();
if(i>=len) {
if(strncmp(buffer+i-len, term, len)==0) {
found=true;
break;
}
}
}
}
buffer[i]=0;
Serial.print(buffer);
return found;
}

void setupWiFi() {
// turn on echo
Serial1.println(“ATE1”);
wait_for_esp_response(1000);

// try empty AT command
Serial1.println(“AT”);
wait_for_esp_response(1000);

// set mode 1 (client)
Serial1.println(“AT+CWMODE=3”);
wait_for_esp_response(1000);

// reset WiFi module
Serial1.print(“AT+RST\r\n”);
wait_for_esp_response(1500);

//join AP
Serial1.print(“AT+CWJAP=”");
Serial1.print(ssid);
Serial1.print("","");
Serial1.print(PASS);
Serial1.println(""");
wait_for_esp_response(5000);

Serial1.println(“AT+GMR”);
wait_for_esp_response(1000);

Serial1.println(“AT+CWJAP?”);
wait_for_esp_response(1000);

Serial1.println(“AT+CIPSTA?”);
wait_for_esp_response(1000);

Serial1.println(“AT+CWMODE?”);
wait_for_esp_response(1000);

Serial1.println(“AT+CIFSR”);
wait_for_esp_response(5000);

Serial.println("---------------##### READY TO SERVE #####---------------");
}

void setup() {
// assume esp8266 operates at 115200 baud rate
// change if necessary to match your modules’ baud rate
Serial1.begin(115200); // Teensy Hardware Serial port 1 (pins 0 and 1)
Serial.begin(9600); // Teensy USB Serial Port
delay(2000);
Serial.println(“begin.”);
setupWiFi();

graph.fileopt=“overwrite”;
bool success;
success = graph.init();
if(!success){while(true){}}
graph.openStream();
}

unsigned long x;
int y;

void loop() {
int randNumber1,randNumber2;
randNumber1 = random(10,20);
randNumber2 = random(30,50);
graph.plot(millis(),randNumber1, tokens[0]);
graph.plot(millis(),randNumber2, tokens[1]);

delay(200);
}