Hardware Reference
In-Depth Information
// Get IP
uint32_t ip = 0 ;
Serial.print(F( "www.dweet.io -> " ));
while (ip == 0 ) {
if ( ! cc3000.getHostByName( "www.dweet.io" , & ip)) {
Serial.println(F( "Couldn't resolve!" ));
}
delay( 500 );
}
cc3000.printIPdotsRev(ip);
Serial.println(F( "" ));
// Reset watchdog
wdt_reset();
// Measure from DHT sensor
float t = dht.readTemperature();
float h = dht.readHumidity();
temperature = ( int )t;
humidity = ( int )h;
// Measure light level
float sensor_reading = analogRead(A0);
light = ( int )(sensor_reading /1024*100 );
Serial.println(F( "Measurements done" ));
// Reset watchdog
wdt_reset();
// Send request to Dweet.io
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." ));
Search WWH ::




Custom Search