Dynamic Arduino RFID System

Project Name Dynamic Arduino RFID System
Type Escape Room Component
Completed December 2017
Programming 100%
Design 33%
Environment Arduino IDE
Language C++
This Arduino project allows for a dynamic amount of RFID sensors to be connected to an Arduino. Via the MQTT protocol each sensor can be assigned a tag, and whenever tags are placed on the right sensors the Arduino will communicate this back via MQTT.
Escape Lab came to me with the commission to provide the code for this dynamic RFID system to be used in an Escape Room.
Escape Lab provided the requirements (communication through MQTT, dynamic amount of RFID sensors, assignable tags) and hardware at a briefing. I designed the software system behind it. I really enjoyed working on this project as it required me to really consider the hardware limitations regarding memory and computation speed.

Activity Diagram

For this project I didn't need to strongly consider the user as there was very little direct interaction, but I needed an activity diagram for the program itself to have a clear view of the flow of the update loop and data concerned with it.

Click to view

UML Design

Before programming the system I like to create an UML diagram of what I am going to create, for communication purposes and because it provides an overview of what elements I need to consider. Here you see the UML diagram, and below a short explanation of the important aspects. Click to view the whole image.

Below I have written an elaboration on the classes displayed in the UML about their role in the system.

Click to view

This is the main Arduino file (.ino), here I put all variables the client needed to have accessible for changing, like network settings and the specific pins the readers are connected to.


As the control of the RFID readers was quite complicated, even with the external library MFRC522.h by Miguel Balboa, I decided to write a wrapper so the game functions wouldn’t get cluttered with code specific for the RFID readers.

communicationIn.h || communicationOut.h

To keep everything as clean as possible, all functions concerned with MQTT communication and Json parsing were separated to these two files.

Script Snippets


I always like to keep my code as clear as possible so reading back is no effort. When I'm working on commission I like to take it one step further, and document the code so the client won't even have to read back what was agreed concerning the use of the product. To show this I decided to share the setup part of the project.
View below.

String Functions

The Arduino framework is very barebones, it lacked some string functions I needed for the parsing of Json messages, which were sent via MQTT to conrol the game. For this I created my own helper functions.
View below.

Setup Project
String Functions