Hardware Reference
In-Depth Information
Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80 );
if (client.connected()) {
Serial.print(F( "Sending request... " ));
client.fastrprint(F( "GET /dweet/for/" ));
client.print(thing_name);
client.fastrprint(F( "?temperature=" ));
client.print(temperature);
client.fastrprint(F( "&humidity=" ));
client.print(humidity);
client.fastrprint(F( "&light=" ));
client.print(light);
client.fastrprintln(F( " HTTP/1.1" ));
client.fastrprintln(F( "Host: dweet.io" ));
client.fastrprintln(F( "Connection: close" ));
client.fastrprintln(F( "" ));
Serial.println(F( "done." ));
} else {
Serial.println(F( "Connection failed" ));
return ;
}
We should also not forget to reset the watchdog after this long request:
wdt_reset();
After the data is sent, we read back the answer from the dweet.io server, to be sure that the
data was correctly received on the other end. We also close the connection and disconnect
the CC3000 chip from your WiFi network, in order to save energy:
Serial.println(F( "Reading answer..." ));
while (client.connected()) {
while (client.available()) {
char c = client.read();
Serial.print(c);
}
}
Serial.println(F( "" ));
// Reset watchdog
wdt_reset();
Search WWH ::




Custom Search