Wireless NFC Reader

Beside currently working on integrating the Zipato RFID Keypad into HA, I’d also like to use NFC tags.

Does anyone know a wireless NFC reader (bluetooth / z-wave) that works with HA or did anyone use an arduino or a raspberry for that?

Thanks!

Maybe this could work?:

It’s a Nfc reader that connects via bluetooth or usb and includes a battery.
According to the description, at least the usb connection, is Linux compatible.

There is also the ACR1311 where the only difference seems to be the missing battery.

The question is if it wouldn’t be better anyway to use either a more powerful powerbank or to directly connect it to a plug.

So I switched to completely doing this on my own by buying the listed items under https://www.openhardware.io/view/49/NFC-to-HTTP-Gadget

I hope that this will work even though I don’t know wheater I will use http or mqtt to pass the key ids to HA.
Anyone a suggestion on that?

In HA, I guess I should create some sort of software switch that can be turned on / off using a simple script that evaluates the given codes.

3 Likes

How is this working out for you?

I’m waiting for a new ESP8266 since 8 weeks now so I can’t tell you more about this at the moment.

As soon as I know something, I’ll let you know.

2 Likes

Anything yet?

I’m in the process of trying this out. Bought all of the parts, failed to compile locally so just grabbed the existing bin’s (here: https://github.com/happy-bubbles/nfc/releases), flashed the firmware but not seeing the WiFi access point to connect against.

It looks like the device I bought has a ESP8266EX chip despite being labeled as ESP8266. Not sure if this is an issue or not.

If anyone else has had success getting this going would appreciate the tips.

I gave up trying to flash existing BINs out there so instead wrote my own and this turned out to be much easier than expected. There’s only a couple of pieces needed:

  1. NFC522 scanner. Full library + example is available for ESP8266.
  2. HTTP Post to REST URI. Full library + example is available for ESP8266.
  3. Home Assistant to receive NFC UID. Lots of options here. I went with input_text to receive the UID.

I put these all together in an afternoon and now have a NFC reader which triggers a Spotify playlist on my Bose speakers. Sweeet!

Here’s the ESP8266 code:
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <MFRC522.h>

// LEDs
const short int BUILTIN_LED1 = 2; //GPIO2
const short int BUILTIN_LED2 = 16; //GPIO16

// WIFI
const char* ssid = “”;
const char* password = “”;
const char* host = “hassio.local”;

// RC522
#define RST_PIN 2 // Configurable, see typical pin layout from HappyBubbles NFC
#define SS_PIN 15 // Configurable, see typical pin layout from HappyBubbles NFC

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

void setup()
{
Serial.begin(74880);
delay(100);

pinMode(BUILTIN_LED1, OUTPUT); // Initialize the BUILTIN_LED1 pin as an output
pinMode(BUILTIN_LED2, OUTPUT); // Initialize the BUILTIN_LED2 pin as an output

digitalWrite(BUILTIN_LED1, LOW); // Turn the LED ON by making the voltage LOW
digitalWrite(BUILTIN_LED2, HIGH); // Turn the LED off by making the voltage HIGH

// Init the RC522
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F(“Scan PICC to see UID, SAK, type, and data blocks…”));

// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

delay(500);

while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}

Serial.println("");
Serial.println(“WiFi connected”);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

void loop()
{
// Look for new cards
if (!mfrc522.PICC_IsNewCardPresent())
{
return;
}

unsigned long uid = getID();
if (uid == -1)
{
return;
}

// Turn the LED on
digitalWrite(BUILTIN_LED2, LOW);

WiFiClient client;
const int httpPort = 8123;
if (!client.connect(host, httpPort))
{
Serial.println(“connection failed”);
return;
}

Serial.print("RFID Detected with UID: ");
Serial.println(uid);

String jsonData = “{“entity_id”: “input_text.music”, “value”: “” + String(uid) + “”}”;

Serial.println(“Requesting POST.”);

// Send request to the server:
client.println(“POST /api/services/input_text/set_value?api_password=<your_passsword> HTTP/1.1”);
client.println(“Host: hassio.local”);
client.println(“Accept: /”);
client.println(“Content-Type: application/json”);
client.print("Content-Length: ");
client.println(jsonData.length());
client.println();
client.print(jsonData);

delay(500); // Can be changed

if (client.connected())
{
Serial.println(“Disconnecting from server”);
client.stop(); // DISCONNECT FROM THE SERVER
}

Serial.println();
Serial.println(“Closing connection”);

// Turn the LED off
digitalWrite(BUILTIN_LED2, HIGH);

delay(1000);
}

//
// mfrc522.PICC_IsNewCardPresent() should be checked before
// @return the card UID
//
unsigned long getID()
{
if (!mfrc522.PICC_ReadCardSerial())
{
// Since a PICC placed get Serial and continue
return -1;
}

unsigned long hex_num;
hex_num = mfrc522.uid.uidByte[0] << 24;
hex_num += mfrc522.uid.uidByte[1] << 16;
hex_num += mfrc522.uid.uidByte[2] << 8;
hex_num += mfrc522.uid.uidByte[3];
mfrc522.PICC_HaltA(); // Stop reading
return hex_num;
}

ok, verry interesting,

can you tell me where you bought that reader? does it include a battery power source?
can you also post some more details how you accomplished this in HA config?

thnx

So: After esphome got integrated to hass.io, I started using it and it works perfectly fine.

Everything you need is documented at the projects website and I just love it.