Skip to content
No description, website, or topics provided.
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
code
images
README.md
enviro-I3-publish.md
enviro-I3-subscribe.md
enviro-direct2Tangle.md

README.md

EnviroPhat

You can sense temperature, pressure, light, local color, accelerometer readings, and magnetometer data using EnviroPhat and Raspberry Pi Zero W. You can publish this sensor data to the Tangle or sell it on a data marketplace such as the I3 Data Marketplace. Here are step-by-step instructions.

Getting EnviroPhat

Getting 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

Solder a pin header to the EnviroPhat board and snap the board onto your Raspberry Pi. Then, install the EnviroPhat software.

sudo pip3 install envirophat

For other installation methods and details see these instructions

Verifying the version of Python

The Raspbian operating system comes with two versions of Python pre-installed. This tutorial uses Python 3. Verify that this version is installed:

python3 --version
$ Python 3.4.2
pip3 --version
$ pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)

Installing the Python IOTA Workshop scripts

This installs the Pyota client library so you can communicate with the Tangle. The 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 EnviroPhat.

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
pip3 install -r requirements.txt
python3 code/e01_hello_world.py

The Tangle will respond with the latest statistics:

{'appName': 'IRI Testnet',
 'appVersion': '1.8.0-RC1',
 'coordinatorAddress': 'EQQFCZBIHRHWPXKMTOLMYUYPCN9XLMJPYZVFJSAY9FQHCCLWTOLLUGKKMXYFDBOOYFBLBI9WUEILGECYM',
 'duration': 0,
 'features': ['dnsRefresher', 'testnet', 'zeroMessageQueue', 'RemotePOW'],
 'jreAvailableProcessors': 8,
 'jreFreeMemory': 11467464304,
 'jreMaxMemory': 22906667008,
 'jreTotalMemory': 16876830720,
 'jreVersion': '1.8.0_181',
 'lastSnapshottedMilestoneIndex': 434525,
 'latestMilestone': TransactionHash(b'9KVQUHSNWATBLGJJAUNNAFPCCOLDK9MPDMLOVLSMVFIYUPLPJLLUFQWPXNLGTCQKOYFBYBLFBCHNUC999'),
 'latestMilestoneIndex': 1313941,
 'latestSolidSubtangleMilestone': TransactionHash(b'9KVQUHSNWATBLGJJAUNNAFPCCOLDK9MPDMLOVLSMVFIYUPLPJLLUFQWPXNLGTCQKOYFBYBLFBCHNUC999'),
 'latestSolidSubtangleMilestoneIndex': 1313941,
 'milestoneStartIndex': 434527,
 'neighbors': 3,
 'packetsQueueSize': 0,
 'time': 1565658746766,
 'tips': 750,
 '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

Retrieving your data subscription

Investigating your data

Charting EnviroPhat data on ThingSpeak

Learning as we go

You can’t perform that action at this time.