Things used in this project

Hardware components:
Photon new
Particle Photon
×1
SparkFun Photon Weather Shield
×1
Software apps and online services:
W9gt7hzo
Microsoft Azure

Schematics

Photon+WeatherShield Assembled
Photon%2bweathershield%20assembled

Code

ParticleWeatherShield codeC/C++
// This #include statement was automatically added by the Particle IDE.

#include "SparkFun_Photon_Weather_Shield_Library/SparkFun_Photon_Weather_Shield_Library.h"

char Org[] = "ORGANIZATION_NAME";
char Disp[] = "DISPLAY_NAME";
char Locn[] = "LOCATION";

//Create Instance of HTU21D or SI7021 temp and humidity sensor and MPL3115A2 barrometric sensor
Weather sensor;

void setup()

{

  Serial.begin(9600);

 //Initialize the I2C sensors and ping them
 sensor.begin();

 /*You can only receive acurate barrometric readings or acurate altitiude
 readings at a given time, not both at the same time. The following two lines
 tell the sensor what mode to use. You could easily write a function that
 takes a reading in one made and then switches to the other mode to grab that
 reading, resulting in data that contains both acurate altitude and barrometric
 readings. For this example, we will only be using the barometer mode. Be sure
 to only uncomment one line at a time. */

 sensor.setModeBarometer();//Set to Barometer Mode

 //baro.setModeAltimeter();//Set to altimeter Mode
 //These are additional MPL3115A2 functions the MUST be called for the sensor to work.
 sensor.setOversampleRate(7); // Set Oversample rate
 //Call with a rate from 0 to 7. See page 33 for table of ratios.
 //Sets the over sample rate. Datasheet calls for 128 but you can set it
 //from 1 to 128 samples. The higher the oversample rate the greater
 //the time between data samples.
	
  delay(10000);
}

void loop()

{
  
 delay(5000);
 
 // Measure Relative Humidity from the HTU21D or Si7021
 float h = sensor.getRH();

 // Measure Temperature from the HTU21D or Si7021
 float f = sensor.getTempF();
 // Temperature is measured every time RH is requested.
 // It is faster, therefore, to read it from previous RH
 // measurement with getTemp() instead with readTemp()

 char payload[255]; 

 snprintf(payload, sizeof(payload), "{ \"s\":\"wthr\", \"u\":\"F\",\"l\":\"%s\",\"m\":\"Temperature\",\"o\":\"%s\",\"v\": %f,\"d\":\"%s\" }", Locn, Org, f, Disp);
 Serial.println(payload);
 Spark.publish("ConnectTheDots", payload);

 delay(5000);

 snprintf(payload, sizeof(payload), "{ \"s\":\"wthr\", \"u\":\"%%\",\"l\":\"%s\",\"m\":\"Humidity\",\"o\":\"%s\",\"v\": %f,\"d\":\"%s\" }", Locn, Org, h, Disp);
 Serial.println(payload);
 Spark.publish("ConnectTheDots", payload);

}
webhook.jsonJSON
{ 
 "event": "ConnectTheDots", 
 "url": "https://connectthedotsex-ns.servicebus.windows.net/ehdevices/messages", 
 "requestType": "POST", 
 "json": { 
 "subject": "{{s}}", 
 "unitofmeasure": "{{u}}", 
 "measurename": "{{m}}", 
 "value": "{{v}}", 
 "organization": "{{o}}", 
 "displayname": "{{d}}", 
 "location": "{{l}}", 
 "timecreated": "{{SPARK_PUBLISHED_AT}}", 
 "guid": "{{SPARK_CORE_ID}}"

},

 "azure_sas_token": { 
 "key_name": "D1", 
 "key": "mBLQGWxSkRHg7f2eRCLonHUpNS+DY0iPHclxjf7Cmvk=" 
 }, 
 "mydevices": true 
}

Credits

Head
Paul DeCarlo

Technology Evangelist with an appetite for hardware hacking.

Replications

Did you replicate this project? Share it!

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

Give feedback

Comments

Similar projects you might like

Solar Smart Greenhouse Using Vertical Aquaponic Towers
Intermediate
  • 3,194
  • 44

Work in progress

Feed your family with 22 sqm greenhousing by combining permaculture, aquaponic vertical towers and IoT.

Drop of Life
Intermediate
  • 676
  • 17

Full instructions

A display to remind me when I can donate blood and save lives, powered by the Red Cross API and Particle.

Measure wind speed with Eltako windsensor and Win10 IoT Core
Intermediate
  • 624
  • 7

Full instructions

This Project will help you track wind Speeds using Windows 10 IoT Core and the Eltako Windsensor.

IoT Drone - Part 2 - Sensors
Intermediate
  • 761
  • 8

Work in progress

Part 2 incorperates a GPS receiver, 10 DOF IMU, and Ultrasonic distance sensor to be used for flight controls.

Vehicle Artificial Perception-Building Experimental Systems
Intermediate
  • 1,976
  • 17

Work in progress

Exploring Vehicle Artificial Perception in Self-driving technology with DragonBoard 410c and Raspberry Pi 3

How to run Particle on Raspberry Pi (Headless on Pi Zero W)
Intermediate
  • 1,747
  • 19

Protip

Use the most popular single-board computer with the most popular IoT tools.

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback