Things used in this project

Hardware components:
Photon new
Particle Photon
×1
386 00
DHT11 Temperature & Humidity Sensor
×1
Adafruit industries ada161 image 75px
Photo resistor
×1
Mfr 25frf52 10k sml
Resistor 10k ohm
×1
08377 02 l
Resistor 330 ohm
Or 220 ohm. I think this is a pull-down resistor, isn't it?
×1
12002 04
Breadboard (generic)
×1
Software apps and online services:
particle.io Build online IDE
If you don't have an account already, sign up. It's Free!
ThingSpeak Open Data Platform
If you don't have an account already, sign up. It's Free!

Schematics

Circuit
Here's the whole circuit -
Solar1

Code

Particle.io WebhookJSON
This is the code that resides at particle.io. No changes are required.
{
    "event": "thingSpeakWrite_",
    "url": "https://api.thingspeak.com/update",
    "requestType": "POST",
    "form": {
        "api_key": "{{k}}",
        "field1": "{{1}}",
        "field2": "{{2}}",
        "field3": "{{3}}",
        "field4": "{{4}}",
        "field5": "{{5}}",
        "field6": "{{6}}",
        "field7": "{{7}}",
        "field8": "{{8}}",
        "lat": "{{a}}",
        "long": "{{o}}",
        "elevation": "{{e}}",
        "status": "{{s}}"
    },
    "mydevices": true,
    "noDefaults": true
}
solarmonitor.inoC#
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_DHT/Adafruit_DHT.h"

// -----------------------------------------
// solarmonitor
// Monitor light, temperature and Humidy at solar panel
// Particle Photon + Particle.io Webhook + ThingSpeak Integration
// April, 2016 - Pete Hoffswell - pete@hoffswell.com
// -----------------------------------------

#define DHTPIN 2
#define DHTTYPE DHT11 // DHT11 Module

#define publish_cycle 60000 // Only publish every 60 seconds
const String key = "8OAB88505K78478J"; // Change this to your Thingspeak api write key

int led = D7; // Sensor Read Light
int photoCell = A0;
int power = A5; // Photocell power.  An analog pin to gives a more steady voltage.

int light; // Light
double tempF; // Temperature F
double tempC; // Temperature C
double humidity; // Humidity
unsigned int lastPublish = 0;

DHT dht(DHTPIN, DHTTYPE);

void setup() {
    // Set Pin Modes
    pinMode(led,OUTPUT);
    pinMode(photoCell,INPUT);
    pinMode(power,OUTPUT);

    digitalWrite(power,HIGH); // Turn on power source for photoCell
    digitalWrite(led,LOW); 

    // Connect variables to particle cloud
    // This allows you to save data to particle.io, and run commands against it such as "particle variable Photon get light"
    Particle.variable("light", &light, INT);
    Particle.variable("tempF", &tempF, DOUBLE);
    Particle.variable("tempC", &tempC, DOUBLE);
    Particle.variable("humidity", &humidity, DOUBLE);

    dht.begin();
    Serial.begin(9600);
    delay(10000);

} //setup


void loop() {
  unsigned long now = millis();
  digitalWrite(led,HIGH); // Signal read sequence led

  // read sensors
  light = analogRead(photoCell);
  delay(100);  // is this needed?
  humidity = dht.getHumidity();
  tempC = dht.getTempCelcius();
  tempF = dht.getTempFarenheit();

  // DHT Read ok?
  if (isnan(humidity) || isnan(tempF) || isnan(tempC)) {
    Serial.println("");
    Serial.println("Failed to read from DHT sensor!");
    Serial.println("humidity=" + String(humidity) + " tempF=" + String(tempF) + " tempC=" + String(tempC));
    Serial.println("");
    return; // exit loop and try again
  }

  // Display to serial
  Serial.println();
  Serial.print("humidity=" + String(humidity) + " tempF=" + String(tempF) + " tempC=" + String(tempC) + " light=" + String(light));
  delay(200);

  // Publish to thinkspeak
  if ((now - lastPublish) > publish_cycle) {
    Particle.publish("thingSpeakWrite_All", "{ \"1\": \"" + String(humidity) + "\"," +
       "\"2\": \"" + String(tempC) + "\"," +
       "\"3\": \"" + String(tempF) + "\"," +
       "\"4\": \"" + String(light) + "\"," +
       "\"k\": \"" + key + "\" }", 60, PRIVATE);
    lastPublish = now;
    Serial.println(" - Published!");
  } else {
      Serial.println();
  }

  digitalWrite(led,LOW);
  delay(2000); // Wait 2 seconds before next loop
  
} // loop

Credits

Pete2014
Pete Hoffswell
10 projects • 50 followers
Network Engineer for All the People. Internet advocate. Microcontroller Fan. Maker.
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog