This document’s purpose is to explain the process on how to use a RFID reader and record data on the IOTA tangle. It is a step-by-step guide that I wrote after I failed trying to make any solution working that I had found on the internet. Please let me know if you see anything that needs improvement.

This paper is just an example in how easy it is to use IOTA but be careful when you want to use this idea in an environment that requires long-term storage of the data. Reason: to maintain a small IOTA ledger database, IOTA deletes on an irregular basis all transactions with zero balances (it is called Snapshot). The transactions we are generating in our example fall in this category. Only permanodes will be keeping track of the entire history and those nodes are incentivized to get paid per query.

1. Hardware Setup

1.1 Components

In addition, you will need for the setup: USB keyboard, USB mouse and HDMI cable.

1.2 Assembly

The assembly is straight forward.

RFID Reader: You will need to solder the pin header onto the module board. Be careful with this step as otherwise the system will not work (you will not be able to read/write tags). I for example had one pin not soldered correctly and it took me a long time to identify and solve this problem as I originally thought it was a software problem.

Connecting: Connect the reader to the Raspberry the following way:

2. Software setup

To operate your Raspberry Pi you will need a micro-SD card. To install the operating software, follow this process: https://www.raspberrypi.org/documentation/installation/installing-images/README.md. Install the full version of Raspbian. Insert the SD card into the Raspberry Pi.

Connect to the Raspberry Pi:

Monitor using the HDMI cable

Mouse and keyboard

Power cable

After reboot, select menu →Preferences → Raspberry Pi configuration, then select tab Interfaces and enable: SSH, SPI, and VNC.

If you prefer to connect remotely to the Raspberry Pi perform the following steps:

On the Raspberry open the terminal and use the following codes:

sudo apt-get update

sudo apt-get install realvnc-vnc-server realvnc-vnc-viewer

To get the raspberry Pi ip address (for example 192.168.1.20), type in the terminal: ifconfig

Reboot the Raspberry Pi:

sudo reboot

On your computer download the VNC viewer: https://www.realvnc.com/en/connect/download/viewer/ and follow the instructions.

Once installed use the Raspberry Pi IP address as well as username and password to log into your Raspberry.

3. Installation of RFID software

Once your Raspberry Pi has finished rebooting, open the terminal and check if spi_bcm2835 is listed:

lsmod | grep spi

If you don’t see spi_bcm2835, you have not activated SPI in the configuration (see above)

1. Ensure your Raspberry Pi is running the latest version of all the software. Run the following two commands on your Raspberry Pi to update it.

sudo apt-get update

sudo apt-get upgrade

2. Install the python package

sudo apt-get install python

3. Clone the Python Library SPI Py and install it to your Raspberry Pi to interact with the RFID RC522.

cd ~

git clone https://github.com/lthiery/SPI-Py.git

cd ~/SPI-Py

sudo python setup.py install

cd ~

git clone https://github.com/pimylifeup/MFRC522-python.git

To test, if the system is functioning correctly, lets write a small program:

cd ~/

sudo nano rfidreader.py

this will open the Raspberry editor

Copy the following code into the editor:

To save the file press Ctrl + X then press Y and then press Enter.

Now run this program:

sudo python rfidreader.py

And hold a tag next to the RFID reader. This should give an output like:

To write the name onto a card, follow these instructions

4. Activate IOTA

To communicate with the IOTA tangle you need to install the PyOTA library (https://github.com/iotaledger/iota.lib.py):

cd ~/

sudo apt-get install libffi-dev (to avoid the error: “failed building wheel for cryptography”)

sudo pip install pyota[ccurl]

git clone https://github.com/iotaledger/iota.lib.py.git

To test if the installation was successful (this will take around 10 minutes):

cd iota.lib.py

python setup.py test

Additional information you find on the official IOTA webpage.

5. Recording Data on the Tangle

For this step you will need an IOTA address. For this I recommend installing the trinity wallet on your computer (https://trinity.iota.org) and get a new address.

To record data on the Tangle we will write a small program that will ask the user to cast a vote (yes or no) and then record this value together with the RFID tag number and name on the Tangle.

Lets now create the program. In the Terminal type the following commands:

cd ~/

sudo nano cast-a-vote.py

insert this program:

Don’t forget to insert your IOTA address (row 11) after CleaningLogAddr

To save the file press Ctrl + X then press Y and then press Enter.

3. Now let’s run our program:

sudo python cast-a-vote.py

4. You now can use an IOTA Explorer (for example thetangle.org) and check that the data was recorded successfully.