Cold Chain Monitoring With Streamr, Ruuvi, And Ethereum

In November, we had the pleasure to demo at Slush, Europe’s biggest startup event. We had a very productive time there, with one of the highlights being our meeting with the brilliant guys from Ruuvi. This Finnish company has developed very impressive Bluetooth sensors called RuuviTags. They measure temperature, air pressure, acceleration and humidity, run on a single battery for 3 years, and three devices cost just €69. What’s even more awesome is that both the software and the hardware are open source – a perfect match for the decentralised trustless technology we’re busy building at Streamr.

Once we got back from Slush, we immediately installed a few RuuviTags for demo purposes around our Zug office. The data is freely available on Streamr for prototyping IoT stuff. Search for these stream names in the Editor to add them to your canvas:

    • RuuviDemo Zug Fridge
    • RuuviDemo Zug Freezer
    • RuuviDemo Zug Room 331
    • RuuviDemo Zug Meeting Room

Using the historical run mode in our Editor, it’s easy to inspect what a few days of data (in this case fridge temperature) looks like:

The Streamr Engine makes it easy to refine the data and connect results to Ethereum smart contracts in real-time. To illustrate this, we implemented a little cold chain insurance example.

Millions of tons of frozen foods are transported around the world everyday. So ensuring that foods remain frozen whilst in transit is really important for the end consumer. No one wants to buy defrosted then refrozen ice cream and restaurants don’t want to be cooking meat infested with bacteria. So in our scenario, a “courier” places a stake in ETH into a smart contract. If the measured temperature exceeds an agreed threshold (in the demo, 10°C), a penalty is subtracted from the stake and sent to the “beneficiary”.

In this simple demo, the Streamr Engine calculates a one-hour rolling average temperature and reports it (once every hour) to the smart contract. This demonstrates how the Streamr Engine can be used to easily build data processing oracles, reporting the calculation results to smart contracts.

We believe this is a really great (though small scale) example of machine-to-machine verification and payment.

Below you can see the live canvas, embedded onto this blog. You can also open it in the Editor.

Of course we didn’t stop there. We figured if we were going so crazy about RuuviTags, then other people must be too. So now, to make it really easy to connect data from the sensors to Streamr, we’ve created a little library called ruuvi-streamr for node.js. It acts as the glue between the Bluetooth tags and Streamr, allowing you to connect the data. All you need to do is give names to your tags. The library will take care of the rest, including creating the streams and producing data to them. This snippet powers the above demo streams using the library:

// Require the library
const RuuviStreamr = require('ruuvi-streamr')

// Insert your Streamr api key here. You can create one in Settings -> Profile
const apiKey = 'MY-API-KEY'

// Define your tags here. A stream with the tag name will be created, if it does not exist.
// Data from each tag will be produced to its respective stream.
const tags = {
	'4457e1eccefc425fa577669c62cbb733': {
		name: 'RuuviDemo Zug Fridge',
		description: 'Streamr office fridge in Zug'
	},
	'8955c5f3cd3046e29c3cd2293f1dcbbe': {
		name: 'RuuviDemo Zug Freezer',
		description: 'Streamr office freezer in Zug'
	},
	'6d2b59ffdcc84a759319de9cc3f4086a': {
		name: 'RuuviDemo Zug Meeting Room',
		description: 'Streamr office meeting room in Zug'
	},
	'6ef4bc7d2253474bb19d05769cb7ea76': {
		name: 'RuuviDemo Zug Office',
		description: 'Streamr office in Zug'
	}
}

// Start!
let rs = new RuuviStreamr(apiKey, tags)

 
Tech warning: nerdy stuff ahead

We used a Raspberry Pi 3 Model B to act as a gateway between the RuuviTags and Streamr. This computer approximately the size of a credit card features built-in Bluetooth Low Energy (BLE) and Wi-Fi, which makes it easy to connect to the sensors as well as to the internet. In the ruuvi-streamr README you will find tips on how to set up the RasPi3.

Notice that the smart contract has also been deployed from the Editor using SolidityModule. You can find the smart contract source code by clicking the “Edit Code” button on the module.

To create a Streamr API key and to configure Ethereum accounts to be used by the Streamr Engine, visit your user settings.

If you have any questions about how to make the most of Ruuvi and Streamr, drop them in the comments below, or post them in our Reddit FAQ, and we’ll try to answer them as soon as possible. We look forward to hearing from you.

Video from the Aragon/Streamr Helsinki meetup is here – and we’re hiring

It’s always great to hook up with other developers and Ethereum enthusiasts, especially in your home country. What’s more, we’re now doing even more to make ourselves available to the community. So, I was very happy to showcase Streamr at a meetup in downtown Helsinki last week.

Making the most of meetups

Arranged by the Aragon guys in the Microsoft Flux space, in coordination with the Helsinki Ethereum meetup, this was a great chance to meet very engaged participants in the local community and share ideas over pizza and beer. Good connections were made between both developers and crypto enthusiasts and investors alike. Happily, I also had the opportunity to run a presentation, the video of which you can see below.  Similarly to my talk at Devcon3, there’s a live demo showing off Streamr’s real time capabilities.

Why we should all want a decentralized world

After my demo, we had the opportunity to watch an incredibly passionate presentation by Aragon’s Luis Cuende. Luis’s fascinating philosophical talk showed why he’s been listed in the Forbes 30 under 30 and why he’s been such an inspiration to many. He really nailed the worrying technological trends that present some of the best arguments for decentralized technology right now and highlighted other key reasons why we’re so driven to succeed. Besides our own dream of tokenizing real time data, it’s this vision of a fairer future that really motivates us. To see for yourself, check his talk below.

Want to join us on our journey?

If this inspired you as much as it did us, you might be someone we’re looking for. To help bring Streamr even closer to reality, we’re currently looking for developers who share our vision of a decentralised computing world. We have open positions in both Zug, Switzerland and Helsinki, Finland. If you’re up for the challenge, If you’re up for the challenge, please drop us a line.

We look forward to hearing from you. You can get in touch with us on Rocket.Chat or official subreddit. Please follow us on Twitter and Youtube to stay on top of new updates.