Weather Shield Hookup Guide

Pages
Contributors: Nate
Favorited Favorite 0

Example Firmware

To get started immediately here is a Codebender example that uses the MPL3115A2 and HTU21D libraries.

Hit connect once you’ve uploaded the example code to see the output from the Weather Shield

Arduino Files

If you are using the Arduino IDE 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.