Brian Krohn
Published

Climate Dashboard

Create dashboard to monitor conditions using Structure and Particle Photon.

IntermediateFull instructions provided2 hours5,605
Climate Dashboard

Things used in this project

Story

Read more

Code

climate-monitor.ino

Arduino
This code can be pasted into the Particle Build code editor.
The "SparkFun_Photon_Weather_Shield_Library" should be included via Particle Build's Library tab.
// This #include statement was automatically added by the Particle IDE.
#include "SparkFun_Photon_Weather_Shield_Library/SparkFun_Photon_Weather_Shield_Library.h"

Weather sensor;

float t = 0;    //actual temperature
float h = 0;    //humidity

void setup() {
    sensor.begin();
    sensor.setOversampleRate(7);
    sensor.setModeBarometer();
    delay(1000);
}

void loop() {
    getClimateData();
    publishData();
    delay(15000);
}

void getClimateData() {
    t = sensor.getTempF();
    h = sensor.getRH();
}

void publishData() {
    char payload[255]; 

    //  {
    //      "t": ##.#
    //      "h": ##.#
    //  }
    snprintf(payload, sizeof(payload), "{ \"t\": %.1f, \"h\": %.1f }", t, h);
    Particle.publish("climate", payload, 60);
}

structure-webhook.json

JSON
Webhook for Particle Cloud to Structure.
To create, run the following from the command line:
particle webhook create structure-webhook.json
{
    "event": "climate",
    "url": "https://triggers.getstructure.io/webhooks/replacethiskeywithyours",
    "requestType": "POST",
    "json": {
        "value1": "{{t}}",
        "value2": "{{h}}"
    },

    "mydevices": true
}

Credits

Brian Krohn

Brian Krohn

1 project • 12 followers
Maker, Tinkerer, Reverse Engineer, Quantum Mechanic, Binary Load Lifter

Comments