By Tyler Pate, Jeremy Kun, and Balaji S. Srinivasan

In a previous post, we showed how to rent out your machine for bitcoin micropayments to facilitate distributed uptime monitoring. In this post we’ll demonstrate another fun kind of “grid computing” application: selling access to sensor data collected by a hardware device in return for bitcoin.

We should clarify that this demo is meant to illustrate the simplest possible example of a bitcoin-incentivized sensor network. A production example would likely monetize the built-in sensors in a network of phones or other IoT devices, with companies like Placemeter, Premise Data, Bloomberg, or Genscape as information buyers.

Before getting into that, though, let’s briefly discuss the difference between cloud computing and grid computing.

The Cloud and the Grid

Bitcoin micropayments are a powerful way for machines to pay other machines to perform useful tasks. But there are two very different paradigms for exactly how this process can work: cloud computing and grid computing.

In this context, the cloud refers to a set of homogeneous servers in a datacenter managed by a single economic entity like an Amazon or Google, while the grid refers to the set of heterogeneous machines in homes and offices around the world managed by different economic actors.

Of these two concepts, the cloud is by far the more familiar. It has been the dominant paradigm for outsourced computing since the launch of Amazon Web Services, and will continue to move from strength to strength for the foreseeable future.

By contrast, the grid is less well known. While the ideas have been around for decades, the technology is not yet widespread in practice. Probably the two best large-scale examples of grid computing are Folding@Home and SETI@Home: prestigious academic projects which essentially “pay” a distributed network of volunteer computers in status by showing a leaderboard of the top compute time contributors.

One hypothesis is that grid computing has been hobbled by the absence of a workable micropayments system. Small, fast, international, automated payments were hard to do before the advent of digital currency. However, if it were actually possible to use micropayments to rent out thin slices of any machine’s time (and not just the machines in an Amazon or Google datacenter), new applications now become possible.

Grid computing allows you to sense and act upon the real world

For computers on the grid to have something worth selling, they need to have a distinctive value proposition. Typically they will not have better price/performance ratios for compute, storage, or memory than their counterparts in the cloud. But grid computers do benefit from being in the real world, owned by real people, rather than being locked away in datacenters.

This means that if you had a working micropayments system, you could rent out grid computers to sense and act upon the real world. Here are four examples:

Software sensor. Rent out a distributed set of real IP addresses to monitor website uptime and latency. We previously published this example as ping21.

Hardware sensor. Rent out a geographically distributed set of measurement devices to record sensor data on the environment. An example is sensor21, which we cover below.

Software actuator. Rent a distributed set of real IP addresses to benchmark your website’s performance. You’d require email validation to confirm domain ownership to prevent DDOS.

Hardware actuator. Rent drones owned by different operators to mass in a specified location. This is a fun one for movie shoots, drone races, or simply cryptocurrency-powered supervillainry. You’d pay a ground station running something like dronekit-python.

To enable applications like this, we need a few things:

A digital currency capable of fine-grained micropayments (like this)

A discovery point or marketplace for computers on the grid to find, buy, and sell from each other (like this)

Client software on each grid node that allows them to buy and sell services for bitcoin (like this)

Fortunately, we’ve built all those things! Let’s go through the hardware sensor application to get a sense for how you might use bitcoin micropayments to rent out grid nodes that sell sensor data.

Earn bitcoin for collecting environmental data

Sensor21 is a simple hardware/software package that illustrates how to measure, store, and resell sensor data in return for bitcoin micropayments. You can buy sensor21 measurements with the free 21 software, and sell it if you have set up a hardware sensor.

Buying sensor21 data

If you’ve installed 21 and have a little bit of bitcoin, you can do this to buy distributed sensor measurements at the command line:

$ 21 buy sensor21 --data '{"n": 5, "sensor": "barometricpressure", "city": "San Francisco"}' {

"city": "San Francisco",

"sensor_type": "barometricpressure"

"readings": [

{

"reading": 101424.2,

"timestamp": "2016-05-25T23:15:45.845Z",

"sensor_id": "6297a731854a2ec0b1ee4e7057d97e75ba751031d952492e24616789"

},

# ... [four more readings]...

]

} You spent: 100 satoshis.

This example purchase pays 100 satoshis to buy five measurements of pressure data (in Pascals) from a small network of Bitcoin Computer-attached weather stations placed through the San Francisco area. You can see which cities have active sensors by running this command, which costs 0 satoshis:

$ 21 buy sensor21/info {

"info":[

{

"city":"Los Gatos",

"sensors":{

"BAROMETRICPRESSURE":{

"num_active_endpoints":1,

"price_to_buy_active_endpoints":20

},

"TEMPERATURE":{

"num_active_endpoints":1,

"price_to_buy_active_endpoints":20

}

}

},

{

"city":"San Francisco",

"sensors":{

"BAROMETRICPRESSURE":{

"num_active_endpoints":5,

"price_to_buy_active_endpoints":100

},

"TEMPERATURE":{

"num_active_endpoints":5,

"price_to_buy_active_endpoints":100

}

}

},

# [ ...more cities... ]

}

Selling sensor21 data

While buying sensor21 data requires only the 21 software and some bitcoin, selling sensor21 data is a little more involved as you actually need a physical sensor that is attached to a computer running 21. Full instructions for setting up a sensor on a Bitcoin Computer or DIY Bitcoin Computer are here.

Once you’ve assembled your hardware, run the following commands:



$ cd sensor21

$ source setup.sh

$ python3 sensor21-server.py -d $ git clone https://github.com/21dotco/sensor21.git $ cd sensor21$ source setup.sh$ python3 sensor21-server.py -d

With that, you will begin collecting sensor data and serving it up on a machine-payable endpoint. If you want to publish your endpoint to the 21 Marketplace, do this:

$ 21 publish submit manifest.yaml -p 'name="Joe Smith" email="joe@example.com" price="50" host="AUTO" port="5002"'

Anyone with the 21 software can now purchase your endpoint on the 21 Marketplace, and your measurements are aggregated with others so that a buyer need only hit one endpoint (namely mkt.21.co/sensor21).

So, just to summarize: with this short set of commands you were able to turn a small sensor into a passive income stream. The value from the sensor comes from the fact that it is not locked up in a datacenter like a cloud computer, but out in the real world and part of a compute grid. In this case, the specific location of the sensor is what adds value; put another way, the value is in the decentralization.

Next steps

The sensor21 example is an intentionally simple demonstration involving just longitudinal collection of temperature and pressure, but we can generalize it to less perceptible measurements like air quality, water quality, pollution, radiation, and the like. Perhaps more interestingly, we can also generalize it to buy and sell other kinds of sensor data automatically acquired by a large network of phones or other IoT devices. As a hardware sensor application of grid computing, it complements the software sensor we demonstrated in our earlier post on ping21.

If you’re interested in this kind of thing or the machine-payable web more generally, please come and discuss new IoT applications enabled by 21 in the #iot channel of our developer community at slack.21.co!