// This #include statement was automatically added by the Spark IDE.
#include "Adafruit_DHT/Adafruit_DHT.h"

#define DHTPIN 6 //Temperature and humidity sensor will connect to digital pin 6
#define DHTTYPE DHT22   // DHT 22  (AM2302)

DHT dht(DHTPIN, DHTTYPE); //Create a DHT 22 object on digital pin 6

int lightPin = A6; //Light sensor will connect on analog pin 6
int uvPin = A7; //UV sensor will connect on analog pin 7

int lightVal = 0; //Variable to store light sensor data
int uvVal = 0; //Variable to store UV sensor data

char resultstr[64]; //String to store the sensor data

void setup() {

pinMode(lightPin, INPUT); //Specify pin 6 as an input
pinMode(uvPin, INPUT); //Specify pin 7 as an input
dht.begin(); //Fire up the DHT 22

Spark.variable("result", &resultstr, STRING);  //Spark variable "result" to store sensor data string

}

void loop() {
lightVal = analogRead(lightPin); //Read the voltage on the light sensor signal pin
uvVal = analogRead(uvPin); //Read the voltage on the UV sensor signal pin

float h = dht.getHumidity(); //Get humidity from the DHT 22
float t = dht.getTempCelcius(); //Get temperature from the DHT 22.  This can be switched to report in degrees F.

sprintf(resultstr, "{\"lightVal\":%d,\"uvVal\":%d,\"t\":%f,\"h\":%f}", lightVal, uvVal, t, h); //Write sensor data to string

delay(2000); //Wait a couple of seconds
}