Skip to content

Python Script

Elizabeth Adams edited this page Sep 5, 2019 · 4 revisions

With our o/s installed along with our two Python modules for reading sensor data and sending data to our Initial State account, we are ready to write our Python script. The following script will create/append to an Initial State data bucket (a collection of data streams grouped together so you can view them in a dashboard), read DHT22 sensor data, and send that data to your real-time dashboard. All you need to do is modify lines 6–11.

The value on line 6 should be unique for each node. This could be your sensor node’s room name, physical location, unique identifier, or whatever. Just make sure it is unique for each node to ensure that the data from this node goes to its own data stream in your dashboard. The name of the data bucket is specified on line 7. This can be changed at any time in the Initial State UI (more info).

The bucket key on line 8 needs to be the same bucket key for every node you want displayed in the same dashboard (more info).

Your Initial State account access key has to be specified on line 9. Copy+paste this key from your Initial State account (more info).

The time between sensor reads is specified on line 10. Change accordingly. You can specify metric or imperial units on line 11. After you have set lines 6–11 in your Python script on your Pi Zero WH, kick off the script:

$ python tempsensor.py

Repeat these steps for each sensor node. As long as each node is sending data to Initial State using the same access key and bucket key, all data will go into the same data bucket and show up on the same dashboard (more info).

<< Software Setup - Dashboard >>

Clone this wiki locally