This device is in the "Happy Bubbles" series of open hardware and open source IoT and home-automation devices. The Wifi NFC device is easy to use, easy to make yourself, and cheap.
Its purpose is to send NFC/RFID tags that you touch to it to an HTTP URL on whatever server you'd like.
What you need to build it:
Easiest is to download the release and use your favorite ESP8266 flashing tool to flash the bootloader, the firmware, and blank settings. Detailed instructions are provided in the release notes, thanks tve!
RC522 NFC pin | NodeMCU pin | ESP8266 GPIO |
---|---|---|
SDA | D8 | GPIO 15 |
SCK | D5 | GPIO 14 |
MOSI | D7 | GPIO 13 |
MISO | D6 | GPIO 12 |
IRQ | Not connected | Not connected |
GND | Ground / GND | Ground |
RST | D4 | GPIO 2 |
3.3V | 3.3V / VCC | VCC |
If there is interest, I can create a PCB for you guys to make this easier. Let me know if anyone would like these and I could put them up for sale.
An RGB LED is useful as a status indicator to tell you when you're in config-mode, when a tag is hit, and the server response can even change its colour!
WS2812 pin | NodeMCU pin | ESP8266 GPIO |
---|---|---|
GND | GND | GND |
Data-In | D1 | GPIO 5 |
5V Power | VIN | not applicable |
Just insert a microUSB cable in the NodeMCU! When it boots up, its red LED should be lit. If you have a WS2812b hooked up, it will glow orange.
If it doesn't, try holding the "FLASH: button on the nodeMCU board held down for about 10 seconds. Holding the button down lets to change between config mode and RFID-scanning mode. I left these two seperate for security, so that while your device is acting as an RFID scanner, someone can't just connect to its hostname and start messing with your settings.
Hold down the "FLASH" button on the NodeMCU board for about 10 seconds. The red LED on the NodeMCU should turn on, and if you have an RGB LED hooked up, it will blink purple a few times, fast. It's now reading tags! Every time you touch a tag, the RGB LED will light pink quickly.
Every time you touch a tag to the device, it will send an HTTP POST request to the URL you specified in the config. The REQUEST payload will be JSON that looks like this:
{
"device_id": "CONFIG-DEVICE-ID",
"tag_uid": "THE-TAGS-UUID",
"counter": 3,
"hash": "7cac4442e6caf834ce20a359ff7ee9ff34525691"
}
The "device_id" is the "Device ID" you specified in the config. The "tag_uuid" is the unique ID of the tag that was detected by the reader. The "counter" and "hash" are optional security authentication parameters described below in the "Optional Authentication" section.
After you touch the tag, the device expects a 200 OK response with a JSON payload. Don't worry about having to send one, it's optional:
{
"r":5,
"g":250,
"b":2,
"delay":2000
}
The "r", "g", and "b" are RGB colour values for the optional WS2812B LED. The server could tell the LED to light up a certain way after the request. This way you could give the user some kind of indication of what happened.
The "delay" is the number of milliseconds to keep the color after a request. If you make it 0, the LED will stay lit that way forever, or until the next reqest...or until you remove power!
The way this authentication works is that the Happy Bubbles NFC device will send a "hash" string in its JSON response. This "hash" is an SHA1-based HMAC, its input is the device-id, the NFC tag-ID, and the counter all concatenated together with no spaces. The 'counter' increments every time your server sends back a 200 OK response. It is used as a 'nonce' to prevent replay attacks on this authentication mechanism. This string is then SHA1-HMAC'd hashed against the "device secret" from the config menu. You can use this on the backend to ensure no one is spoofing tag-hits, it's optional.
This project wouldn't have been possible without my standing on the shoulders of giants such as: