Ingo Lohs
Published © GPL3+

MyWeatherstation For Indoor & Outdoor Use

Check the current conditions: light, temperature, humidity on your smartphone.

BeginnerShowcase (no instructions)2 hours1,864
MyWeatherstation For Indoor & Outdoor Use

Things used in this project

Hardware components

Photon
Particle Photon
for outdoor use over WIFI
×1
Breadboard (generic)
Breadboard (generic)
half+
×1
Male/Male Jumper Wires
×1
Photo resistor
Photo resistor
it´s on option
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 4.75k ohm
Resistor 4.75k ohm
×1

Software apps and online services

Blynk
Blynk
Option1: it´s an comfortable option to check the conditions over your smartphone
ThingSpeak API
ThingSpeak API
Option2: www.thingspeak.com to save and report historical data
Maker service
IFTTT Maker service
Option3: round about the project - is Particle Photon device up and running?

Story

Read more

Schematics

mywetterstation_sketch_steckplatine_fmLdAoXOzy.jpg

Code

MyWeatherstation

C/C++
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_DHT/Adafruit_DHT.h"

// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"

#define BLYNK_DEBUG       // Uncomment this to see debug prints
#define BLYNK_PRINT Serial

//Put your blynk token here
//DANGER - DO NOT SHARE!!!!
char auth[] = "Put your blynk token here"; // photon1
//char auth[] = "Put your blynk token here"; // photon3 
//DANGER - DO NOT SHARE!!!!

int led = D7;  // The on-board LED

// DHT parameters
    #define DHTPIN 5 // what pin we´re connected to
    #define DHTTYPE DHT22 // DHT 22 (AM2302)
    // Variables
    float temperature;
    int humidity;
    int light;
    // Pins
    int light_sensor_pin = A0;
    // DHT sensor
    DHT dht(DHTPIN, DHTTYPE);
    unsigned long lastmillis = 0;
    
    void setup() {
        Serial.begin(115200);
        delay(5000); // Allow board to settle
        // Start Blynk
        Blynk.begin(auth);
        // Start DHT sensor
        dht.begin();
        // Start LED
        pinMode(led, OUTPUT);
        // Start Webhooks
        Particle.subscribe("hook-response/temp", myHandler, MY_DEVICES);
        Particle.subscribe("hook-response/humidity", myHandler, MY_DEVICES);
        Particle.subscribe("hook-response/light", myHandler, MY_DEVICES);
    }
    
    void myHandler(const char *event, const char *data) {
      // Handle the integration response
    }
    
    void readData()
        {
        // Turn ON the LED
        digitalWrite(led, HIGH);   
        // Temp measurement
        temperature = dht.getTempCelcius();
        // Humidity measurement
        humidity = dht.getHumidity();
        // Light level measurement
        float light_measurement = analogRead(light_sensor_pin);
        light = (int)(light_measurement/4096*100);
        
        // Publish data to Webhook -> thingspeak.com
        Particle.publish("temp", String(temperature), PRIVATE);
        Particle.publish("humidity", String(humidity), PRIVATE);
        Particle.publish("light", String(light), PRIVATE);
        
        // Publish data to Blynk
        // virtual pin 1 will be the temperature
        Blynk.virtualWrite(V1, String(temperature)); // photon1 gauge
        
        // virtual pin 2 will be the temperature
//        Blynk.virtualWrite(V2, String(temperature)); // photon3 gauge
        
        // virtual pin 3 will be the humidity
        Blynk.virtualWrite(V3, String(humidity)); // photon1 gauge
        
        // virtual pin 4 will be the humidity
//        Blynk.virtualWrite(V4, String(humidity)); // photon3 gauge
        
        // virtual pin 5 will be the humidity
        Blynk.virtualWrite(V5, String(humidity)); // photon1 history graph
        
        // virtual pin 6 will be the light
        Blynk.virtualWrite(V6, String(light)); // photon1 history graph
        
        // virtual pin 7 will be the light
        Blynk.virtualWrite(V7, String(temperature)); // photon1 history graph
        
        // virtual pin 8 will be the humidity
//        Blynk.virtualWrite(V8, String(humidity)); // photon3 history graph
        
        // virtual pin 9 will be the light
//        Blynk.virtualWrite(V9, String(light)); // photon3 history graph
        
        // virtual pin 10 will be the light
//        Blynk.virtualWrite(V10, String(temperature)); // photon3 history graph
        
        // Turn OFF the LED
        digitalWrite(led, LOW);    
        //delay(15000);  // Wait at least for 15 seconds - thingspeak.com refresh time
        }
    
    void loop() {
        
        Blynk.run(); // all the Blynk magic happens here
        
            if ((millis() - lastmillis) > 20000) {
                lastmillis = millis();
                readData();
            }
    }

Credits

Ingo Lohs

Ingo Lohs

182 projects • 194 followers
I am well over 50 years and come from the middle of Germany.

Comments