Hardware Reference
In-Depth Information
Serial.println(F( " \n Initializing..." ));
if ( ! cc3000.begin())
{
Serial.println(F( "Couldn't begin()! Check your wiring?" ));
while ( 1 );
}
In the loop() function, we first connect the CC3000 chip to your local WiFi network:
cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
We also need to start the watchdog. The watchdog is basically a circuit inside the Arduino
microcontroller, independent from the code itself. It will reset the Arduino sketch auto-
matically after a given time, unless we send it a reset signal. This will ensure that even if
our Arduino sketch hangs for some reasons (for example, it cannot connect to the Dweet.io
servers), the Arduino sketch will just reset itself and the project will continue to work. We
first need to enable the watchdog with the maximal delay of 8 seconds:
wdt_enable(WDTO_8S);
When we are connected, we perform the temperature, humidity and light level measure-
ments:
float t = dht.readTemperature();
float h = dht.readHumidity();
temperature = ( int )t;
humidity = ( int )h;
float sensor_reading = analogRead(A0);
light = ( int )(sensor_reading /1024*100 );
Serial.println(F( "Measurements done" ));
Once we got the measurements, we can upload them on the dweet.io service. To do so,
we need to connect to their servers, and then send the data inside a standard HTTP GET
request. This is done by the following piece of code:
Search WWH ::




Custom Search