Hardware Reference
In-Depth Information
#define WEBSITE "api.xively.com"
#define API_key
"GFSM8c7f83E0MMta3FkGAwzVktkzXNN6kXhoRBV8QN1WmkiZ"
#define feedID "1628598268"
Once this is done, we can move to the setup() function of the sketch. We start by ini-
tializing the CC3000 chip:
Serial.println(F("\nInitializing..."));
if (!cc3000.begin())
{
Serial.println(F("Couldn't begin()! Check your wiring?"));
while(1);
}
Then, in the loop() function of the sketch, we start by connecting to your local Wi-Fi
network:
cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
We also define the IP address of the Xively website, so that the CC3000 chip knows
where it has to connect:
uint32_t ip = cc3000.IP2U32(216,52,233,120);
It's now time to do the measurements. This is similar to what we saw in the first sketch
where we tested the different sensors:
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
int lightLevel = analogRead(A0);
Now comes the most complicated part, so bear with me. In order to upload data to Xively,
we need to follow a given format so that Xively servers understand what we want to send.
This is all defined in the Xively API's documentation, which you can find on the follow-
ing Xively website:
https://xively.com/dev/docs/api/
Search WWH ::




Custom Search