Reading NFC info - how?

I’d like to read the tag identity via NFC for configuration purposes but not getting anywhere

my tags are Ruuvi Tag B, FW v.3.31.1+default - from the repo I’d guess this supports NFC

is “Add new sensor via NFC” via Ruuvi Station supposed to work with this firmware version? no reaction - batteries look ok

I tried to read the tag info via NFC Tools, NXP Tag Info or some other mobile app, both iOS and Android - none of those apps detect the Ruuvis (?)

same for NFC Tools on MacOS with ACR122U reader - not recognized?

eventually I’d like to do this with an esp32 app and a m5stack RFID2 reader - I can read and write assorted tags just fine, but dont get any reaction with a ruuvi tag either

I suspice I am missing smething fundamental?

thanks in advance
Michael

Hi Michael, yes NFC reading should be available in this FW version. Maybe @otso would have idea what is going on here.

1 Like

Hello Michael,

Sorry about the problem with the tags.

We read the NFC of tags as a part of our quality control process, but of course anything is possible.

Have you tried to read other NFC devices with the mobile app or reader? Some phones are really picky about NFC antenna positioning, especially when a phone cover is in between the tag and phone. I use personally NFC Tools on Android

Hi Otso

I will give it another stab with assorted Android phones later today and report

I can read all my assorted tags with the two Android Samsung phones and an iPhone, as well as the ACR122U reader on MacOS

very weird

meanwhile I’ve cooked a reader which I’ll try to mutate into dealing with Ruuvis: GitHub - mhaberler/M5StackRFID2-Reader: RFID Reader for M5Stack RFID 2 Unit (WS1850S/MFRC522 I2C)

thanks!

Michael

1 Like

what reader/software do you use in production to read out the tags?

We use standard Android phones with software we have written ourselves. The software does not have any special features related to NFC.

I made progress and am able to read one of the two RuuviTags tried - positioning is critical

I documented my findings here: GitHub - mhaberler/M5StackRFID2-Reader: RFID Reader for M5Stack RFID 2 Unit (WS1850S/MFRC522 I2C)

what puzzles me is that the older tag (Ruuvi5668) is not NFC-readable, the newer Ruuvi2B44 works fine (see above link for details)

Michael

1 Like

has anybody ever tried reading the RuuviTag with nfc-tools?

I’m getting halfway there to some reaction using nfc-mfclassic:

$ nfc-mfclassic r a u ruuvitag.mfd
NFC reader: ACS / ACR122U PICC Interface opened
Warning: tag is probably not a MFC!
Found MIFARE Classic card:
ISO/IEC 14443A (106 kbps) target:
ATQA (SENS_RES): 00 44
UID (NFCID1): 5f 3e 20 3f 0e ae 5e
SAK (SEL_RES): 20
RATS support: yes
Guessing size: seems to be a 1024-byte card
Reading out 64 blocks |nfc_initiator_transceive_bytes: Mifare Authentication Failed
nfc_initiator_transceive_bytes: Mifare Authentication Failed
nfc_initiator_transceive_bytes: Mifare Authentication Failed
nfc_initiator_transceive_bytes: Mifare Authentication Failed
nfc_initiator_transceive_bytes: Mifare Authentication Failed
nfc_initiator_transceive_bytes: Mifare Authentication Failed
nfc_initiator_transceive_bytes: Mifare Authentication Failed
nfc_initiator_transceive_bytes: Mifare Authentication Failed
nfc_initiator_transceive_bytes: Mifare Authentication Failed
!
Error: authentication failed for block 0x3f

but of course that is not the right incantation because the RuuviTag is not a Mifare Classic but a Type 4 tag

if that worked I could clone the method for the MRFC522

Michael

what puzzles me is that the older tag (Ruuvi5668) is not NFC-readable, the newer Ruuvi2B44 works fine (see above link for details)

It is possible that the older tag has been physically damaged at some point, if they’re both running same firmware there should not be any software- or hardware based reason why one would not be readable and other not.

after quite a safari, I have a working example for reading a Type4 Tag (in my case a Ruuvi) via an MFRC522 (or similar) reader connected to an ESP32

@otso you were right, the other tag was defective

edit: this thread was essential

2 Likes

I have some questions on the Ruuvi’s Type4 tag contents

is that NDEF message settable via an NFC write operation, or is this only meant to be driven by the firmware loaded and read-only in nature?

related:

let’s assume I read an NDEF message of some tag X.

how do I know X is a Ruuvitag just based on the contents of the NDEF message?

some magic in the UID?
the manufacturer bytes of the MAC address?

Michael

Hello,

The writable record is related to our previous plans to make tags NFC-configurable, however that feature is not on our roadmap at this time. We don’t have any strict guarantee on how to identify NFC device as a RuuviTag, but every RuuviTag produced since 2018 or so has these 4 UTF-8 records:
“id”, “ad” “sw”, “dt”, where the 2-character code is misused country code. “id” has unique ID of RuuviTag, “ad” has MAC address, “sw” has s firmware version and “dt” depends on firmware version.

thanks! that should be good enough to uniquely identify a Ruuvi NFC response

appreciated!

Michael

1 Like

I eventually achieved what I wanted:

I can read Ruuvitags, and Mifare1k tags with a custom message with a microcontroller and a MFRC522-compatible reader:

thanks for the help!

Michael

2 Likes

a bit off-topic, but possibly interesting for others:

I’m integrating the above repo into a flight display application which reports Ruuvis but also other sensors (BLE and non-BLE)

I can add the Ruuvis directly via NFC, but other sensors lack this capability - so I use an NFC key fob or an adhesive tag

I call these “proxy tags” as they stand in for a sensor

I can attach those proxy tags in a convenient location - some sensors are mounted in inaccessible locations

these tags contain short JSON configuration fragments for the application, and a link to the devices’ manufacturer website

I found I get by without any configuration file in the app proper - all I do is scan the Ruuvis and NFC tags

If I accept the tag info, the config information is stored in the flash filesystem and read on startup

that is super quick and way more convenient compared to editing config menues or an on-device website, and useful if you need to reconfigure frequently (which is my situation)

We are currently testing with the M5Dial which should work 1:1 as is has the same RFID chip (WS1850S ) as I used with the external reader

Michael

1 Like

ATM we’re still held up by this issue

1 Like

@ Michael_Haberler I successfully use NFC tools by Wakdev with an iPhone Xs Max.
It is very sensitive to orientation and the time the iPhone is in range of the tag (as in swiping the iPhone across the tag)
Sometimes the tag is recognized but the Ruuvi NDEF record are not received.

Regarding the RTD (record Type Definition ) https://engineering.purdue.edu/ece477/Archive/2012/Spring/S12-Grp14/Specs/NFC/NFCRTD. +pdf

2.1.1 Global starts with an UPPER-case letter defined by NFC forum
At the present time I cannot locate a list of the NFC forum global definitions other than paying $100!
2.1.2 Local Type start with a lower-case or number.
When there is no need to define its meaning outside of the local context.
MAY be reused by another application in a different context and with different content.

“NFC Forum Local Type SHALL start with a character in the range or as defined in Chapter 3”

The 3.31.1 codes used by Ruuvi tags are (UPPERcase):
“SW” “MAC” “ID”

There is a forth record with bytes not in the ASCII printable text range wHich I suspect vary depending on the firmware version.
For example:
From NFC tools:
Payload: 4 bytes
02 64 61 A3

Payload: 8 bytes
02 64 74 44 61 74 61 3A

Payload: 27 bytes
02 64 74 05 06 1D 9C 3F C6 BB FE B4 03 9C 00 00 8B 56 E1 6D 73 C3 F5 C3 73 45 0A

Payload: 27 bytes
02 64 74 05 10 1E 4D A4 C8 43 FF F4 00 90 03 D4 A1 B6 00 5D 98 E5 CB 91 6B 66 A9

05 12 2A FF FF FF FF 80 00 80 00 90 96 00 00 0D D3 51 78 72 EC 0F

There is also:
ruuvi.drivers.c/src/nrf5_sfdk_platform/communication/ruuvi_nrf5_sdk15_communion_nfc.c
Which contains ri_nfc_data_set
which includes code which adds records
id, addr, fw and bin

@dgerman yes, the NFC Tools by WAKDEV only recognize the tag’s UUID and type - they cannot decode Type 4 tags like the Ruuvi, only MIFARE and similar Type 2 tags

the repo listed above can decode Type 4 tags, for the Ruuvi it shows

{
  "ID": "C5:5A:B4:FC:52:5C:F4:B2",
  "MAC": "C2:6E:D1:70:2B:44",
  "SW": "Ruuvi FW v3.31.1+default"
}

(I skip the mystery fourth record)

It is hard to get NFC specs - the field is marred with NDA’s and proprietary documents

I used some of the public drafts put up for ballot which are usually online, assuming the final standard is by and large the same

after an extensive Google safari and spending too much time on this repo, I think it is pretty much the only code for embedded controllers which can decode Type4 tags

Michael

1 Like

I didn’t expect you to read this reply so soon. PS Where are you?
I reviewed my references to the source code and removed some.

I don’t have any trouble with NFC tools displaying the first 3 records.
Example:
NFC Record

Type:
Text record: T (0x54)

Format:
NFC Well Known (0x01)
Defined by RFC 2141, RFC 3986

Value:
Encoding: UTF-8
Language: ID
Text: ID: A2:87:FC:4A:76:7F:F2:67

Text: MAC: E5:CB:91:6B:66:A9
Text: SW: Ruuvi FWv3.31.1+debug

In any case, As we agree, Ruuvi tag 3.31.1 INCORRECTLY uses uppercase global codes and the 4th record is poorly defined.
I will look into this more tomorrow. g’night.

you’re correct, NFC Tools for iPhone does read Type4 tags, as does the Android version, and NXP TagInfo

the Desktop version (at least on MacOS using an ACR122U reader) does not

early bird in Austria here :wink:
Michael