How you can setup a basic IoT tracking solution for a local meat farm using Arduino and NEM - IoT + blockchain


Credit to nem.io/catapult

Hello all, Bader here (ツ)


There are a lot of blockchain and IoT companies out there. Most of them I have seen are ICOs in the funding stage.

I want to see some actual tech!

Today, I want to show you how local farms can use an IoT system in their business using the NEM blockchain and Arduino.

I have already done a variation of a blockchain tracking device like this using Arduino and Tendermint, but my next installment will use NEM and a SparkFun ESP8266 board. This guide will feature my project-to-be’s components.

This is in theory right now. I have not tested these components or written any code yet. This is not a step-by-step guide, but a scenario

Main materials needed:


  • 1x SparkFun ESP8266 Thing (any Arduino Wifi board will work)

  • 1x DHT11 temperature & humidity sensor

  • 1x Lithium Ion battery

  • 1x RTC Module (for keeping time)

What are we accomplishing?


In this example, I just want to track the temperature of a shipment of beef from when it leaves the farm until it reaches my local supermarket. Data such as which animal it was from, the farm, the farmer, and more can also be logged.

For this example, I want to make sure my meat has been at a consistent and safe temperature throughout shipment. This way, I can avoid consuming anything that may harm me before I even buy the item.

Bacteria can start growing on meat once it reaches higher temperatures, which can generate toxic proteins.

Not something I want to put in my body.

This also allows farms and supermarkets to isolate incidents of food poisoning, as they can track the shipment to a certain animal or plot of land.

Recently in the US, there was an E. Coli outbreak from romaine lettuce . Farms recalled all the lettuce, as they didn’t quite know the source of the outbreak. With a method such as this, they could’ve tracked down a bad batch down to the plot of land, thus isolating the incident (and not taking my lettuce).

What will the Arduino do?


The Arduino will log the temperature of a serialized crate of beef from the farm at various intervals. For this scenario, let's say the delivery truck has internet connectivity that the SparkFun Thing is using.

The Journey


And the journey begins! The shipment of beef from bull #149 is loaded on the truck for transportation.

Now get ready for some numbers:

Let’s say the trip from the farm to the supermarket is 45 minutes.

The SparkFun Thing logs the temperature every two seconds and averages the temperature every 10 minutes and sends a transaction to the NEM blockchain.

In NEM, a transaction can contain a 1024 character message. This transaction that we send contains a message, which would look something like this:

beef-crate#149&temperature@40F&time@12:49:34PM

This message means the crate of beef with ID 149 (same as the bull the meat was from) has an average temperature reading of 40 degrees Fahrenheit at 12:49 PM.

(I see @deleted_user_1 asset library being a great way to also do this)

This process happens every 10 minutes and is sent to the farm’s beef NEM address.

There could be an address representing shipments for lamb, duck, or fish. Each address corresponds to a type of meat.

Finally, when the crate reaches the supermarket, our device is returned back to the farm and the meat is stocked.

When a customer walks in, they can view the journey of the shipment along with which animal the meat is from.

The customer app indexes the beef shipment from the company’s NEM account and displays if the temperature threshold has been crossed (if the meat is safe for consumption). In other words, it either gives a SAFE or NOT SAFE reading for that specific package of meat.

The customer can also choose to look further at all the readings submitted by our SparkFun Thing.

Conclusion


As you can see, blockchain is a great use case for this type of application. It provides transparency and trust, and in this case, assurance for the customer. It also allows farms and corporations to isolate incidents. If you like this type of article, be sure to follow me as I will work on more topics related to this.

If you would like to chat more about blockchain and IoT, you can find me on any of the NEM channels on Telegram @crackingcode.

And if there are any other IoT + blockchain projects that are showing off some tech, please share them!

Thank you for reading!

6 Likes

Maybe you can check-in with the ethyl folks ? Looks like there could be some overlap since they are also working on an IoT platform on nem. Or at least they were, haven’t heard anything in a while.

1 Like

This is interesting, although from what I can gather refrigerated transport technology is pretty on the ball these days.
Yet the aspect of quality control is good and your idea goes beyond fridge meat transport.

The Biotech industry for example use many Bio products and Bio companies are audited regularly so buyers know that a certain standard has been reached (ISO standard for example), yes and this is big bucks for the company.

And yes even in Biotech the products often come from raw materials such as meat or organs
that come from processing points in a very raw form and end up being used in ISO labs.

Nice topic

BTW The Arduino would have to be very sturdy and resistant to temp/shock/dust and moisture.
Any regular transport gets punished over time.

1 Like

Last I heard they had some trouble with ‘beta logistics’, so not too sure on the state of the project. I would love they they would put out some more info regarding their solution.

I’m glad you liked it! Yes, this does go beyond meat for sure.

And as far as refrigerated transport, something like this will make sure it does in fact use a refrigerated truck. There are a great deal of probiotic health supplements that cost a pretty penny but lose their effect because of the conditions they are transported/stored in.

Hi Bader…
The complicated part here is the communication with a blockchain node to submit the data in regular intervals, isn’t it?
Collecting data and saving it by messaging to a blockchain account is no magic - getting the data transferred in real-life environments often happens to be complicated.
Which then touches points like

  • connectivity
  • battery life
  • logistics of the sensors (mount, dismount)
  • human-error avoidance (attach properly)
  • fraud avoidance (put the sensor into a separate freezer box and claim it’s “in the meat”)

Rene
LuxTag.io

3 Likes

First off, I really like your project luxtag.io :slight_smile:

I’m happy you asked these questions:

Yes, you are right in that regard. Having constant updates in the real world is indeed harder than it looks. I’ve thought this through quite a bit, and am currently experimenting with hardware to see how this can be implemented. I am about to start testing with mijin-test.

  1. As far as connectivity, I am currently working out a solution to where the sensor data going to be saved to be later uploaded to a node.

  2. This one I am still exploring. I will update with more details as my project goes on.

  3. I plan to fix the sensors on the board for now, though it would be nice to have a modular design.

  4. Perhaps something like multiple quality assurance inspectors (like what is in the Catapult example?)

  5. This is a very good point, I have not thought about this. If there are multiple devices, perhaps they can cosign if they have the same conditions (though they theoretically just put them all in the freezer)? Another aspect to this is including a GPS module, but again the battery issue arises.

If you have any advice please share, I’m still exploring this idea :slight_smile: .

If I make an breakthroughs or discover any disadvantages, I will update here.

1 Like

You could also do things like write the data far less often but add an alarm/write when the temperature gets close to or above a certain point.
Not sure if if the same as sensors I have seen, but some sensors can log process data quite fequently but only write to memory when instructed.
Think Gps can be configured in power save mode too, so as to hibernate and only switch into normal mode and record a location when the controller/program requests it.

High resolution logging of data is not always better you have to optimise it for the task.

Cheers

1 Like

Those are great ideas, thank you my dude!!

1 Like

Progress update: the device is up and running with the necessary components programmed to do what they need to in regards to temperature, when it is offline etc. I now just need to handle the signing and serialization of a transaction on the board itself, as this is necessary with Catapult.

2 Likes

This reminds me of Modum, they were doing this same thing for medical supplies. The only thing is that the medical industry is already using tamper proof stickers that change color when the temp goes out of range. I was excitedly telling my cousin, who works in the industry all about MOD. He didn’t really get it, said they use these stickers as standard and they work fine.

I also never really understood this tracking of consumables on the blockchain. WABI were trying to do that also, but it really doesn’t make sense. Why do you need a distributed ledger to track a straight line? Can’t you just print the name of the farm on the box? Consumer protection laws are pretty strict in the west, if you see organic on the box, it’s almost certainly organic. On the other hand in the developing world, most don’t care at all where the meat came from.

1 Like

Love the engagement. I did not know that about the stickers, quite fascinating!

I think tracking consumables is a viable method to ensure quality. It can also help to identify any incidents (i.e the romaine lettuce) and track it back to the shipment from the farm that grew the crop. What if the shipment was exposed to unsafe temperature? I believe a customer has the right to know what the food has been through.

I believe “developing” countries also deserve to know their food what it has been through, no? I know for a fact farmers in India would love to be able to track the logistics of their crop.

This has way more use cases than just meat, by the way. Another example are expensive probiotics used to replenish bacteria in the body. They are required to be stored at colder temperatures so the bacteria survives.

Or instead of temperature, you can track the exact GPS coordinates of an expensive parcel.

Or perhaps the air quality of the farm or factory.

Why blockchain?

Sure, this could be done with a traditional database, but that could easily be hacked. The blockchain is simply a convenient way to keep a record of events, and a more secure way of doing it. It isn’t the magical band aid to all problems, but it certainly can be used for a great deal.

But hey, what do I know. I’m just a dev lol.

Would appreciate anymore feedback.

Haha, yea right. A dev. So my line of thinking is that a disruptive solution should be an order of magnitude better than the status quo in order to achieve adoption. Peoples rights and desires will only be fulfilled if there is also a possibility for people to make money off it. So for example you mentioned that databases can be hacked. In this case, it may be cheaper to improve security on the database that to bring on a whole new system. Then you have to ask yourself, what actual loss will result from the database being hacked to make it worth hacking. You could think of it like somebody trying to rob my 11th floor house through the window. Sure they could rappel off the roof and come in the window to take my laptop, but does that really mean that I need to install cages in the windows? If I had diamonds and a hoard of bitcoin in an unsecured wallet, yes, but otherwise maybe not.

I’m living in China and most people here are not poor, but not really wealthy either. These fancy lettuces that you speak of cost more for one piece than an entire meal costs for a family. Basically up to 5$. I, even with a relatively high income, won’t purchase them. Only the very wealthy do. Imagine then in India, or sub-saharan africa, no way can they afford it. Luckily, there is a huge demand for this sort of thing in the United States. It’s a shame because it comes as a result of corruption in the government. In Europe, we have much higher standards for our foods overall. In Ireland for example, all of our meat is organic and grass fed, just because that’s how we farm. We can get our meat from the local butcher and know exactly which farm it came from.

Supply chain is an interesting use case, but as far as I know, it is more useful in that blockchain can provide a distributed ledger for shipment tracking and automated dispatching of transport for the next leg of the journey. In this case the products need only be scanned in via barcode and the real magic happens on the distributed ledger.

1 Like

This is not just about lettuce :wink: I will be updating with progress on this idea. It may turn into a total flop, but I will never know until I try.

Best of luck

Yea, you gotta keep trying and tweaking. Every failure just teaches you, I know it’s cliche, but I’ve had a few myself already. It’s the only way to build knowledge and experience and to ultimately succeed. My project for example, I have already tried to implement on a very small scale, at a local school, but I found that there just isn’t the motivation for them to implement. I had to put it on the back burner and keep thinking on it. That was four years ago now, and in my current version, I have discovered an incentive system to get it implemented on a higher level where the individual homes or companies will not need to make a decision on it. It will be profitable for governments and industry to apply it to all the smaller parts operating within them to save hundreds of millions of dollars. That motivation is stronger than a single business saving a few k a year so we focus on the higher levels.

1 Like

Great stuff. I cannot wait to see your project :slight_smile:

Whole foods and other businesses have people going around the store checking temperatures every so many minutes (on the salad bar, and in the various coolers). If that can be automated using your system and NEM blockchain, then it’d be a useful fixed product.

2 Likes

Interesting, I didn’t know that. I think this has many applications, I listed some use cases over at https://cryptoconfirm.io/ (site not quite finished yet).

Cheers @crackTheCode!! Would be really good to have this in reality as an end user. Have been working on the supply chain problem for trade finance. So can relate the thought process for the food industry. For the prototype, technically surely is suitable to go well over a block chain.

However, as one of the users highlighted, the main problem that occurs is the adoption of such a technology. People involved in trade don’t really want this. How do we incentivise the acceptance of this practice? That’s the tricky part :wink:

Unless you have the food regulatory body convinced! :smiley:

Also found some IoT company make similar hand gloves that check the temperature, weight and maintain the ledger while being transferred point to point. Can see your idea nicely integrate for the beef use case!

All the best with the proto! Any thoughts on the incentivisation would be useful!

Cheers,
Shilpa

1 Like

Hey @Shilpa_Karkeraa! This is some great feedback. I’ve still been working out incentivization aspect, I understand no one will want this if they can’t make money somehow.

They won’t do it out of the goodness of their heart :smiley:

That glove project sound WAY cool. Please link it, I’d love to take a look :slight_smile:

If you or anyone else have any ideas on incentivization that would be great.

1 Like