Hi,
At this moment I am experimenting with a tag reader (RC522 + arduino nano clone). I want to use a tag to disarm the security system. In addition, I prefer a wired connection to the rpi on which Domoticz runs.
By trial and error I succeeded in having tags read and a recognized tag sets pin 9 from the nano to low and after 5 seconds back to high. Pin 9 is connected via wire to a piface and thus the security system can be deactivated.
Code: Select all
//Programa : RFID - Toegangscontrole RFID
//https://www.filipeflop.com/blog/controle-acesso-leitor-rfid-arduino/
#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);
char st[20];
int ledPin = 8; // Gate BS170 verbinden met pin 8, source met massa en drain met betreffende ingang Piface
void setup()
{
Serial.begin(9600); // Initialiseer seriële communicatie
SPI.begin(); // Initialiseer SPI bus
mfrc522.PCD_Init(); // Initialiseer MFRC522
pinMode(ledPin, OUTPUT);
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
// Toon UID tag
Serial.print("UID van de tag :");
String inhoud= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
inhoud.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
inhoud.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Melding : ");
inhoud.toUpperCase();
if (inhoud.substring(1) == "55 22 56 BE") //UID 1 - Jan
{
Serial.println("Lezer 1, tag Jan");
Serial.println();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hallo Jan!");
lcd.setCursor(0,1);
lcd.print(" Alarm uit!");
digitalWrite(ledPin, LOW);
delay(3000);
digitalWrite(ledPin, HIGH);
openingstekst();
}
}
void openingstekst()
{
lcd.clear();
lcd.print("Houd uw tag");
lcd.setCursor(0,1);
lcd.print(" voor de lezer!");
}
A recognized tag also generates a serial print.

- RFID output.PNG (11.36 KiB) Viewed 4255 times
1. Is it possible to send the serial print via Modbus RS485 RTU to Domoticz (for example to a text sensor)? If so, I get a log that states which tag has been read and when. How can I achieve this goal?
I have a USB> RS485 and some TTL> RS485 modules in stock. I will succeed in connecting the hardware (Google).
Further help is very desirable.
Thanks in advance.