Skip to content

Part 3. Putting it All Together

Elizabeth Adams edited this page Nov 26, 2018 · 13 revisions

Initial State Dashboard

Let's start by streaming the GrovePi Zero's temperature and humidity data to Initial State. We will use the script at https://github.com/initialstate/grovepi-zero/blob/master/grovepi-zero-dht22-initialstate.py. Before we run this script, we need to modify the user settings.

# --------- User Settings ---------
# The DHT_SENSOR_TYPE below may need to be changed depending on which DHT sensor you have:
#  0 - DHT11 - blue one - comes with the GrovePi+ Starter Kit
#  1 - DHT22 - white one, aka DHT Pro or AM2302
#  2 - DHT21 - black one, aka AM2301
DHT_SENSOR_TYPE = 1
# Connect the DHT sensor to one of the digital pins (i.e. 2, 3, 4, 7, or 8)
DHT_SENSOR_PIN = 4
# Initial State settings
BUCKET_NAME = ":partly_sunny: Indoor Environment"
BUCKET_KEY = "GPZa"
ACCESS_KEY = "PLACE YOUR INITIAL STATE ACCESS KEY HERE"
# Set the time between sensor reads
MINUTES_BETWEEN_READS = 1
METRIC_UNITS = False
# ---------------------------------

We need to place our Initial State ACCESS_KEY on the corresponding line in our script. Run the script:

$ cd ~/grovepi-zero
$ sudo python grovepi-zero-dht22-initialstate.py

Go to your Initial State account and look for a new bucket called Indoor Environment. Temperature and humidity data should be streaming in every minute (you can make it stream faster by changing MINUTES_BETWEEN_READS to .02 in the user settings section of the script ... just don't let it stream too long or you will send in way more data than you want).

Let's repeat this same process with the air quality sensor using this script (https://github.com/initialstate/grovepi-zero/blob/master/grovepi-zero-air-initialstate.py). Make sure you add your ACCESS_KEY to the user settings and run the script at the terminal. This script will append to the same data bucket as the temperature/humidity script.

If you want to run both the temperature/humidity and air sensors together, use the script at https://github.com/initialstate/grovepi-zero/blob/master/grovepi-zero-dht22-air-initialstate.py.

The final script for our project will combine our Wunderground data with our GrovePi Zero sensors. This script is located at https://github.com/initialstate/grovepi-zero/blob/master/grovepi-zero-wu.py. You will need to modify the user settings in this script:

# --------- User Settings ---------
# The DHT_SENSOR_TYPE below may need to be changed depending on which DHT sensor you have:
#  0 - DHT11 - blue one - comes with the GrovePi+ Starter Kit
#  1 - DHT22 - white one, aka DHT Pro or AM2302
#  2 - DHT21 - black one, aka AM2301
DHT_SENSOR_TYPE = 1
# Connect the DHT sensor to one of the digital pins (i.e. 2, 3, 4, 7, or 8)
DHT_SENSOR_PIN = 3
# Connect the Grove Air Quality Sensor to one of the analog pins (i.e. 0, 1, 2)
AIR_SENSOR_PIN = 0
STATE = "TN"
CITY = "Franklin"
SENSOR_LOCATION_NAME = "Office"
WUNDERGROUND_API_KEY = "PLACE YOUR WUNDERGROUND API KEY HERE"
BUCKET_NAME = ":partly_sunny: " + CITY + " Weather"
BUCKET_KEY = "gpzwu1016"
ACCESS_KEY = "PLACE YOUR INITIAL STATE ACCESS KEY HERE"
MINUTES_BETWEEN_READS = 15
METRIC_UNITS = False
# ---------------------------------

Make sure you add your Initial State ACCESS_KEY and your WUNDERGROUND_API_KEY and save. Run the script, and make sure a new data bucket gets created in your Initial State account (CITY Weather).

The first time you load your data in Tiles, you will see a bunch of data tiles on the screen. You can easily customize your dashboard to look like the image above. A great step-by-step example of customizing a dashboard can be found here. You can view my dashboard that I created here.

If you want to setup your Pi Zero to run this script uninterrupted in the background, you can use the nohup command:

$ nohup sudo python grovepi-zero-wu.py &

You can even setup your PiZero to run this script automatically using "sudo crontab -e" (more info).

That's it. We built a real project from beginning to end using the GrovePi Zero. Let's review the good and the bad.

<< Part 3: A Wunderground Dashboard - Part 4: Final Verdict >>