Weather Shield Hookup Guide

Pages

Contributors: Nate

Example Firmware

The Weather Shield example relies on the HTU21D and MPL3115A2 libraries. Download the libraries here then install them into your Documents/Arduino folder.

Grab the example sketch, and load it onto your Arduino. Open the serial monitor at 9600bps. You should see an output string every second containing the current weather information:

$,winddir=0,windspeedmph=0,windspdmph_avg2m=0.0,winddir_avg2m=0,windgustmph_10m=0.0,windgustdir_10m=0,humidity=31.7,tempf=76.3,rainin=0.00,dailyrainin=0.00,pressure=81525.25,batt_lvl=4.32,light_lvl=2.03,#

$,winddir=0,windspeedmph=0,windspdmph_avg2m=0.0,winddir_avg2m=0,windgustmph_10m=0.0,windgustdir_10m=0,humidity=31.7,tempf=76.3,rainin=0.00,dailyrainin=0.00,pressure=81520.75,batt_lvl=4.32,light_lvl=2.02,#

$,winddir=0,windspeedmph=0,windspdmph_avg2m=0.0,winddir_avg2m=0,windgustmph_10m=0.0,windgustdir_10m=0,humidity=31.7,tempf=76.3,rainin=0.00,dailyrainin=0.00,pressure=81517.50,batt_lvl=4.34,light_lvl=2.11,#

$,winddir=0,windspeedmph=0,windspdmph_avg2m=0.0,winddir_avg2m=0,windgustmph_10m=0.0,windgustdir_10m=0,humidity=31.7,tempf=76.3,rainin=0.00,dailyrainin=0.00,pressure=81509.25,batt_lvl=4.31,light_lvl=2.11,#

The $ and # are start and stop characters. These types of bytes are used to make it easy to parse out the data. For example, you could have an Electric Imp listen for a $ and record the data until you see a #. Once you have the string then split on the commas (also known as comma delimited), and start recording the next string.


Want more information about SparkFun's classes? Interested in getting involved with teaching electronics? Just want to talk? Sign up for our newsletter, or contact our education department.

SparkFun is a company built around one core idea – sharing ingenuity. We think everyone should have the hardware and resources to learn and play with cool electronic gadgetry.

Share, give, learn, SparkFun.

Do you regularly instruct classes and workshops in a formal or informal learning environment? SparkFun offers Educator Discounts to people teaching and sharing electronics.

Find out more.