Photon Weather Shield Hookup Guide

This Tutorial is Retired!

This tutorial covers concepts or technologies that are no longer current. It's still here for you to read and enjoy, but may not be as useful as our newest tutorials.

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

Pages
Contributors: Joel_E_B
Favorited Favorite 7

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.

Particle Dev

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.

select target

Note: You may be required to sign in to your Particle Cloud account (created for free at Particle.io), if you have not done so before. While this IDE is available offline, programming still happens over a WiFi connection. Thus, an Internet connection is still necessary to use Particle Dev.

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.

alt text

If everything compiles without error, click the lightning bolt symbol to upload you code.

alt text

Heads up! Particle Dev does not check to see if any changes were made before you upload. Thus, any changes made to a sketch must be saved manually before the will take affect and get uploaded. Changes made without saving will not be uploaded.

Particle Build

Create a new App by typing a name in the 'Current App' field and pressing 'Enter'.

alt text

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.

alt text

Select INCLUDE IN APP, and add it to your desired application.

alt text

Any sketch using the external libraries needs to have the library "included" first.

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.

basic serial print

Placing a finger over the sensors results in the temp and humidity rising.

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.