Photon Weather Shield Hookup Guide
This Tutorial is Retired!
Note: V11 of the Photon Weather Shield utilizes the Si7021 for humidity and temperature sensing as opposed to the HTU21D.
View the updated tutorial: Photon Weather Shield Hookup Guide V11
Example 1: Getting Started & Reading the On-Board Sensors
For this first example, we're going to keep it simple. This code will get data from the two on-board sensors and print that information to the Serial port. Your Photon will need to be plugged into a USB port on your computer in order to read the input in a Serial Terminal. You'll need a Micro USB cable, which you should have if you bought a Photon kit.
This first example will detail how to use each version of the Particle IDE. Each example after this will assume you know how to navigate each.
Open Particle Dev. Click File -> Add Project Folder. Navigate to where you downloaded the SparkFun Photon Weather Shield repo, and select the 'SparkFun_Photon_Weather_Basic' folder. Click open, and the folder will be added to the left hand sidebar. You can also drag and drop folders into the IDE. The .ino file along with the library files will be available here. Double-click the SparkFun_Photon_Weather_Basic.ino file to see the sketch.
Explore the sketch. Read the comments. Make any changes you want. Once you're ready to upload, you'll need to first select your target device. Click the crosshair looking symbol on the left hand menu to select your device.
You'll be presented with a list of all your Particle devices. Select the correct target. Click the circle with a check mark to compile your code and check for any errors.
If everything compiles without error, click the lightning bolt symbol to upload you code.
Create a new App by typing a name in the 'Current App' field and pressing 'Enter'.
When using Particle Build, you'll need to add each library individually. Search for 'weather' in the "Libraries" tab to find the SparkFun Photon Weather Shield Library. Once found, click on the library.
Select INCLUDE IN APP, and add it to your desired application.
What You Should See
Once everything has uploaded correctly, open your favorite Serial Terminal program at 9600-8-N-1-NONE. Select the serial port your Photon has showed up as, and click connect. You should see something like the following print out in the window.
As mentioned in the comments of this example sketch, you must choose whether you want the MPL3115A2 sensor to be in Barometric mode or in Altimeter mode. It cannot be in both modes at the same time.
Also worth noting is the output of the MPL3115A2 sensor. The pressure from this sensor is outputted in Pascals. However, many weather station report local pressure using hectopascals (hPa) or millibars (mb). Thus, to have the Photon Weather shield give you a reading that more closely resembles what you would see from an online weather report, we take the reading in Pascals and divide by 100 to get a reading in hPa or mb. For more information on pressure sensor data, visit this section of the MPL3115A2 tutorial.