After the fantastic reception that my magnetic door locks video got, I got a lot of questions about doing a RFID Card Reader video. I did it. 🙂
Today we are going to use the arduino sketch esp-rfid. Go to the repository and download the Zip file. Open it up and find the bin folder. Than open up your FlashEZ and put the firmware.bin folder and drag and drop it into the FlashEZ program. For this project, I’m gonna use a NodeMCU board, and no that doesn’t mean Marvel. I’m using it because it has the same voltage as the electric lock on my door. Some NodeMCU boards recommend 9v max. You could use a D1 mini but than you’d have to also supply a 5v power supply. The tricky part about using a MCU board is that you have to use a special driver, because of the USB serial converter that it has on the board. It’s not too hard to find though. The driver you need it the CP210x USB to UART Bridge VCP Drivers. They should have Drivers for your operating system, so find the one that is for your operating system and download it. Save, open, extract, yadda yadda bada bing badda boom. Now go back to your Flash EZ folder. FlashEZ is actually flashESP8266.exe you can get from ESPeasy_megaxx.zip from here
https://github.com/letscontrolit/ESPEasy/realeses
Plug in the NodeMCU board into your computer, click on flashEZ, firmware.bin, than click flash. Now that’s done and now it goes into AP mode which allows you to connect it to a wifi device and put in your network settings and information. Find the wifi network the MCU board is broadcasting in your computers wifi settings. It’ll be ESP RFID and a bunch of other stuff. Connect to that, and then open a web browser. Go to either 192.168.4.1 or go to esp-rfid.local. It’ll ask you to log in. The first time you use it the Default password is admin. First thing you want to do is go into settings and network settings to put in your wifi settings. Now go into the hardware settings. If you are using the same RFID reader that I am, the MFRC-522, than you want to set that as the reader type. If you are using a different one, change that to the reader type. If you want you can also change the SPI port if you want. I put it onto GPIO 15 because it puts the wires in a line. GPIO 15 is D-8 on the NodeMCU board, and we are already using D-5, D-6, and D-7, it made sense to put it into a line. There is also a relay board, which you can connect a relay to and you can directly connect or disconnect. So instead of using the Sonoff SV, like I did before, you could just use this and the relay connected to the GPIO pin. Make whatever changes needed, than save it. Make sure to save it after every time you change something. It’ll give you a message at the bottom to tell you how to make the changes permanent. You can do that after you’ve changed all the settings you want. General settings is a place where you can set your Admin password, and you can change the Hostname if you don’t want the default. This will show up in your router. I’m also gonna set it to restart every 30 days. You may have problems with the board if you don’t restart it every once and awhile. I need to use SonWeb to set all my TasmotiZzed Sonoffs to restart on a schedule. Under the MQTT settings is where you put all of your broker information. The IP address, username, password etc… The topic needs to be unique for each NodeMCU/Reader you have. On the last page you can put in your time zone. For now that’s all. Make sure to preview the changes, than hit save and reboot. Hit the try to reconnect to ESP button. Now you can sign in with your new admin password.
Now let’s get the pins connected. On the gethubs page, you’ll see a pin layout chart. The ones we care about is the 522 and NodeMCU column. The first pin is the SDA pin. This is the SPI SS pin we assigned in the software. According to the chart, it should be connected to the D8 pin. The pin next to that one is the clock pin. That one should connect to the D5 pin. Next is the MOSI which is connected to the D7 pin on the NodeMCU board. Then I’ll connect it to the MISO board. That one connects to the D6 pin. Skip the next pin, then you have a ground pin. You can skip the next one, the reset pin, and then the last one is a 3v. And now it’s connected.
Now what you can do is add some users. I have 6 different tags. 3 cards and 3 key chains. I want each one to be assigned to each member of the house. To do so you have to go to the User’s tab on the ESP-RFID website, and click add user or scan your tag. When you scan it, it’ll give you the ID, and you can change the username and the access type. Than you can save your changes. Now you can repeat the process for the other tags that you want.
To get the full use of these RFID readers, I made a couple of automations. The first one is for the office lock. I set it so that the trigger is an MQTT message on the topic of esprfid and I set the payload to either Justin or Janis. When you add users, it changes the payload to the name of the user. With no Users, use the Code Number as the payload. Now only my RFID or my wife’s RFID will open this lock. I’ll also use a toggle so that my RFID can both lock and unlock the door. The next one is the shop lock. This one exists on a different NodeMCU board, so the topic is different. I called it esprfid2. Note that with no payload defined, the trigger will activate with ANY message received on that topic. This makes it so that if anyone with an RFID it’ll toggle on or off, lock or unlock. Than boom it works. For only a few dollars you can get your own badge scanning entree system. The kids aren’t too keen yet on having these implanted into their bodies. They must have forgotten that Dad can put them to sleep and implant them surgically. 🙂
That’s all for now. Until next time, Adios.