Introduction: UCL-IIoT-Strongbox With RFID and LCD Screen (Nodered,MySQL)

About: Odense, Denmark

Arduino project with RFID scanner and LCD.

Introduction

To conclude our course with micro controllers, more specifically the Arduino Mega which we have been using. We have been tasked with making a project that includes our Arduino Mega, other than that its up to us to decide on what to make with it. Since we haven’t had that much time to this project, we decided on a RFID scanner. This has been made a million times already, so we decided to add an LCD display to it. Which makes this project a little more unique. Although this has been done before as well, we decided that it would be fun anyway.

Arduino project with datalogging
We have decided so continue from our previous project, only that this time we will add datalogging. We have decided since we are short on time, we will just use the same project as last time – this way we can focus on datalogging since its part of our new course, Industry 4.0. In this project we will be using Node-red, which is a way to gather data from a device and access it on a webserver. This way of connecting everything to a cloud server this is an essential part of Industry 4.0.

Description

The first thing we did was check if we had all the necessary components to make this a reality, luckily we did. We decided that instead of making it a door lock, like you would traditionally, we decided it should be a lock to a strongbox or safe if you will. To do this, we made a wooden box, this was done with a laser cutter. We drilled and cut out holes and such for the components to fit in, that way it looked more realistic and a lot easier to manage all our wires and such. After we had made the box ready we simply put all our hardware and wires in, just plug and play basically. Since we had already tested and connected it beforehand. When its all connected and set up, all you need to do is ready a master key. This is done with the default chips you get with your RFID scanner, you simply load up the program and it will ask you to make a master key. When done so, you can choose to give access to other key’s. When you have all the key’s you wish to have access to your strongbox, you simply exist the setup with master key. Now when you scan your key, you can see on the LCD display whether, or not you have access. When you haven’t scanned any key’s, the LCD displays a text “Scan ID KEY”. When you scan a key and you don’t have access, it displays “Access Denied”, or if you have access it displays “Access Granted”. This is very simple and you can always write something different in the code, if you so desire.

Here’s the following components we’ve used in our project:

  • RFID Scanner (3.3 V)
  • LCD Screen 16x2 (5 V)
  • Arduino Mega 2560 R3
  • 12 V DC Solenoid
  • 1x Blue LED
  • 1x Red LED
  • 1x Green LED

Step 1: Fritzing Diagram

Here’s a diagram over how to connect the components in our project.

Step 2: The Code

Here is the code for the project:

If you're having issues with scanning your ID key's;

If you're having issues with scanning your key's, It may be due to your EEPROM being full. This means that you don't have anymore bits free to use for your ID keys. You should only get this issue If you have used your EEPROM before. In our code we do have a step to wipe the EEPROM, but unfortunately it does not work as intended. Therefore you have to use Arduino's default EEPROM reset, its in the default libraries.

Because we are using Nodered, we have out comment some serial.print in the code. This have no effect on the project, but it wont work with Nodered.

Step 3: Preview of the Project

Here you can see, how to add and remove the tag.

One of the tags is the Master key, with this you can change how many tags you want to have access to the strongbox.

Remove a tag, the same way you add a tag.

Step 4: Node-red

The first step is to figure out how your Arduino communicates with your pc. In our case we simply use our serial port in our pc, to communicate with our Arduino.

Node-red coding

In node-red you can drag a serial port block, where you define baud rate etc. your communication settings.

From here you link your Arduino port to those functions that you want node-red to execute. You drag a function, where you define the functionality. We have two paths of functions we use; The first is we delay the flow of msg from the Arduino, so we only get the RFID tags. Then we use a switch to send a granted, denied or unknown msg (notification), since we have predefined which tags are granted and denied in the switch. If the tag is unknown its denied and node-red sends a notification that, it's an unknown tag.

Our other path we send the data from the RFID to our mySQL database. Note that you need to be careful when accessing your mySQL database, since the names need to be exact, our you can't get a connection.

From here we send the information that we have stored in our mySQL database and show them in a table in the node-red dashboard. You just have to define the table size and such, using HTML code. We have an update button, so you can see the latest tags.

Step 5: MySQL Database

We're using WAMPserver to localhost our mySQL database. This is where we save our RFID tags and timestamps, for which we use node-red to broker the information from our Arduino and mySQL database.

The only thing you need to do in mySQL is define a table with 2 columns, one for ID and the other for the timestamps.

How we retrieve the information from the Arduino in node-red is described in the section about node-red.