Hardware Reference
In-Depth Information
1.4
Uploading Data to the Cloud
We are now going to do the most important part of this chapter: upload data to the cloud via
WiFi. To do so, we will use a service called dweet.io, which is a service that proposes to
store your data online via a very simple API. You can check out their page at:
https://dweet.io/
The nice thing with dweet.io is that it doesn't require any account creation or configuration:
you can upload data immediately. It is based on the principle of having objects called
“things”, to which you will upload new data via HTTP requests. And if you upload data to
a new thing that doesn't exist yet, it will be created automatically.
Let's now build the sketch that we will use to automatically make measurements, connect to
the dweet.io server, and upload the data there. This is the complete code for this section:
// Libraries
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include "DHT.h"
#include <avr/wdt.h>
// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10
// DHT sensor
#define DHTPIN 7
#define DHTTYPE DHT11
// Create CC3000 instances
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,
ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);
// DHT instance
DHT dht (DHTPIN, DHTTYPE);
 
Search WWH ::




Custom Search