Skip to content
No description, website, or topics provided.
Python
Branch: master
Clone or download
Latest commit 29134b2 Oct 24, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
code Add files via upload Aug 14, 2019
images Add files via upload Aug 14, 2019
README.md Update README.md Oct 23, 2019
co2-direct2Tangle.md

README.md

CO2-TVOC

You can monitor CO2 and TVOC using a Raspberry Pi and an Adafruit CCS811 gas sensor. TVOC stands for Total Volatile Organic Compounds. This sensor measures CO2 in PPM (parts per million) and TVOCs in PPB (parts per billion).

CO2-TVOC Sensor

Raspberry Pi Zero W


The Raspberry Pi Mega Kit includes a Raspberry Pi Zero W
with GPIO header attached plus a 16GB MicroSD memory card with the Raspbian operating system installed. You can use your own memory card and download and install Raspbian

Interacting with Raspberry Pi Zero W

To connect directly to your Raspberry Pi Zero W, you will need a miniHDMI-to-HDMI adaptor and a microUSB-to-USB adaptor. Power Raspberry Pi with a wall plug or a USB battery capable of powering mobile phones.

You can connect remotely using Secure Shell (SSH). First, you must enable SSH. Click the raspberry icon on the menu. Select Preferences, then select Raspberry Pi Configuration. Click the Interfaces tab and enable SSH.

Window for enabling SSH as described in text

Building your device

Use this tutorial to build your device

Verifying the version of Python

The Raspbian operating system comes with two versions of Python pre-installed. This tutorial uses Python 2 and Python 3. Verify that these versions are installed:

python --version
$ Python 2.7.16

Verify that Python3 has been pre-installed:

python3 --version
$ Python 3.7.3
pip3 --version
$  pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)

Installing the Python IOTA Workshop scripts

This will install the Pyota client library so you can communicate with the Tangle. This workshop includes a step-by-step tutorial teaching the details of sending and receiving transactions to the Tangle. They provide the foundation for the code used to store sensor data from CO2-TVOC.

Clone the github repository, install the workshop code, and run the "hello world" example.

git clone https://github.com/iota-community/python-iota-workshop.git

cd python-iota-workshop
pip install -r requirements.txt
python code/e01_hello_world.py

The Tangle will respond with the latest statistics:


{u'appName': u'IRI Testnet',
 u'appVersion': u'1.8.0-RC1',
 u'coordinatorAddress': u'EQQFCZBIHRHWPXKMTOLMYUYPCN9XLMJPYZVFJSAY9FQHCCLWTOLLUGKKMXYFDBOOYFBLBI9WUEILGECYM',
 u'duration': 0,
 u'features': [u'dnsRefresher', u'testnet', u'zeroMessageQueue', u'RemotePOW'],
 u'jreAvailableProcessors': 8,
 u'jreFreeMemory': 12670851880L,
 u'jreMaxMemory': 22906667008L,
 u'jreTotalMemory': 16866344960L,
 u'jreVersion': u'1.8.0_181',
 u'lastSnapshottedMilestoneIndex': 1313805,
 u'latestMilestone': TransactionHash('SJWXOHIUGFMOKSSKKFEQJDZDCVOSFSXPAVWDUIUPKUDAJRLVBTPKSHYBAHAFVQAVIHOLKYVSCPCPFE999'),
 u'latestMilestoneIndex': 1313911,
 u'latestSolidSubtangleMilestone': TransactionHash('SJWXOHIUGFMOKSSKKFEQJDZDCVOSFSXPAVWDUIUPKUDAJRLVBTPKSHYBAHAFVQAVIHOLKYVSCPCPFE999'),
 u'latestSolidSubtangleMilestoneIndex': 1313911,
 u'milestoneStartIndex': 434527,
 u'neighbors': 3,
 u'packetsQueueSize': 0,
 u'time': 1565655959126L,
 u'tips': 748,
 u'transactionsToRequest': 0}

Using your data

You can store sensor directly to the Tangle and view it using the Tangle Explorer. You can use custom scripts or the ZMQ listener to retrieve it.

Storing sensor data on the Tangle

Viewing data using the Devnet Tangle Explorer

Retrieving data using ZMQ

Selling your data

You sell data by publishing it on the I3 Marketplace where subscribers can buy it:

Publishing data to the I3 Data Marketplace - coming soon

Retrieving your data subscription - coming soon

Investigating patterns in your data

Plotting CO2 and TVOC data over time shows how air quality may change. Use this data science notebook to get started investigating patterns in CO2-TVOC data

Charting CO2 data on ThingSpeak

Learning as we go

  • Seeds are only needed for sending value transactions

  • Raspberry Pi Buster operating system appears to have a WiFi Bug. You may want to use Stretch until a solution is found. Learn more: https://www.raspberrypi.org/forums/viewtopic.php?t=252984

  • Testing is underway using the new version of Pyota that supports Python 3.7.3. Expect updates to this tutorial

You can’t perform that action at this time.