Contributors: “Nelson” Nelson, Gowri Ramachandran, Kurian Karyakulam

The first article in this series introduced IoT, I3 and IOTA. This article explains the details of buying and selling data on the I3 Marketplace. By design, the I3 Marketplace doesn’t keep data. You can store it in the Tangle. Then, you can use data science tools to investigate trends.

Sellers can use sensors to gather data. A CO2 detector monitors CO2 levels. An environment sensor monitors temperature, humidity, and other such data. You can sell all types of data. Sellers generally sell raw data. Raw data can be in text format, for example: 70 C meaning 70 degrees Celsius. Or it can be stored in a machine-readable language.

Data brokers may add value to their data stream by doing some pre-processing. For example, a data broker may capture video in front of a local shop then use artificial intelligence software to count the number of people walking by. The data broker sells the foot traffic, not the raw video.

Selling data

In order to sell data, a seller creates their product and publishes their topic. A buyer pays a fee to subscribe to it. To sell data, you need an IoT device capable of running MQTT. MQTT stands for Message Queuing Telemetry Transport. It is an ISO standard for a publish-subscribe or “pub-sub” messaging protocol.

MQTT libraries are available in multiple programming languages, including Python, Java, JavaScript, C, and others. These tutorials explain how to build IoT sensor devices. Their sample Python code imports the Eclipse Paho MQTT Python client library:

Setting up test accounts

Get started by going to http://3.17.183.219:8000 and creating two accounts: a seller account to publish your data and a different buyer account to subscribe to your data. Use your seller account to create and publish your product. Use your buyer account to purchase it. For step-by-step instructions, go to the menu at the top of the page and click Documentation.

Programming a publisher

There are many ways you can go about publishing data. Each tutorial has a sample script. In these tutorials, the publisher takes a sensor reading then publishes the date and time of the sensor reading along with the data. You can use a scheduler to run your publisher. For example, if you are using Linux, use cron to schedule the publisher to run every 30 minutes.

Setting up your subscription

Log on with your buyer account. Click the AstroPiOTA product. You will see the Product Details. Add this product to your cart then checkout. You will see a list of your transactions. You will also get a notification that you subscribed to the topic of “AstroPiOTA”.

Subscribing to your data

Suppose you want to keep track of trends in environmental data using your AstroPiOTA subscription. You can retrieve the data from I3 and store it in the Tangle. Here is a link to a step-by-step guide along with sample Python code: https://github.com/NelsonPython/AstroPiOTA/blob/master/I3-subscribe.md

To run this script, you will need your username, password, and API key. To get your API key, logon with your I3 buyer account and click Hello {your username} in the upper right corner. Then, click API. You will see your API key.

Viewing your data in the Tangle Explorer

AstroPiOTA environment data in json format

In this example, you can view your data in the IOTA testbed called, the Devnet Tangle Explorer. In production, you can use the MainNet Tangle Explorer.

It is important to understand what type of data you have purchased. In this example, you purchased environment data from AstroPiOTA in json format. The temperature is shown in Celsius.

Investigating data

You can use data science tools to investigate data. Kaggle is an online community of data scientists and machine learners where you can explore data. For example, data from the AstroPiOTA accelerometer and gyroscope tell us if AstroPiOTA is moving. This device is stationary. If these sensors indicate movement, they may be detecting an earthquake. You can correlate this data with a shakemap to find out. Check out this Kaggle notebook with step-by-step instructions: https://www.kaggle.com/nelsondata/astropiota-weather-los-angeles

Another example shows CO2 levels. In this Kaggle notebook, we compare CO2 levels indoors and outdoors beside my pick-up truck exhaust. Do not try this experiment in your garage. You can see the CO2 levels spike when placed beside the truck exhaust. The second spike occurred while I was taking readings while driving on the freeway. Stay tuned because we are conducting more experiments checking air quality on freeways. Here’s the link: https://www.kaggle.com/nelsondata/los-angeles-air-quality

Getting Involved

If you live near Los Angeles and wish to participate in hands-on learning, sign up for the Eventbrite Meetup Series: Intro to IoT, I3, and IOTA at https://www.eventbrite.com/e/intro-to-iot-i3-and-iota-tickets-71737176827

Here are step-by-step guides for building your own devices: https://github.com/iota-community/I3-IOTA

Here’s a recap of the blog posts in this series:

Blogpost 1 — Intro to IoT, I3, & IOTA

Blogpost 2 — Connecting an IoT Device to I3 and IOTA (this one)

Learning more

Learn more about IOTA https://www.iota.org/

Join our community on Discord https://discord.iota.org/

IOTA Technical documentation https://docs.iota.org/

Learn more about USC Marshall https://www.marshall.usc.edu/

Learn more about USC Viterbi https://viterbischool.usc.edu/

Learn more about the I3 Consortium https://i3.usc.edu/about/i3-consortium/

Biographies

S. D. Nelson (“Nelson”) works as a Technologist at the IOTA Foundation. He shares IOTA’s passion for zero-cost transactions for the Internet of Things so that society can benefit from these emerging technologies. He recently teamed up with Researchers at USC to participate in the I3 Intelligent-Integrated IoT Conference and Workshop. Previously, he tested the Curiosity Mars rover at NASA-JPL, taught in China, and worked in 27 countries validating robotic lab equipment. He recently moved to Los Angeles.

Special thanks to WenChen Mei for his advice regarding data visualization. He is a graduate student pursuing his Master of Science in Material Science at Auburn University.

Dr. Gowri Sankar Ramachandran is a postdoctoral researcher at Center for Cyber-Physical System and the Internet-of-Things (CCI), USC Viterbi School of Engineering, University of Southern California (USC). He has more than eight years of research experience in the area of Internet of Things including wireless testbeds and middleware technology as well as applications ranging from medicine delivery in Africa to improving fairness in Policing. Gowri is also involved in the development and management of USC’s Intelligent Internet-of-Things Integrator (I3), which is a data marketplace platform for smart cities.

Kurian Karyakulam Sajan is a technology enthusiast and a student pursuing a Master’s of Computer Science at the University of Southern California. Brings in 5 years of professional experience as a full-stack developer in Oracle, Creditvidya startup in the Financial Technology domain and research programmer at the University of Southern California. Presently, privileged to be working with a team of dedicated intellectuals on I3 data market under the guidance of Professor Bhaskar Krishnamachari. A revolutionary idea that is a conglomeration of IoT, Blockchain, Distributed Systems, Economies and Machine Learning which has the potential to dive deep into a plethora of research questions that were never investigated before. Also, passionate about adventurous sports and soccer.