NFC in farmOS Field Kit

Wanted to start a forum post for talking about NFC in Field Kit.
See other relevant issues:

  • @mstenta you said there are some other issues you could link here?

After some quick hacking with Field Kit, I’m excited to say I got some initial support for reading NFC tags in the native farmOS field kit app! I accomplished this with the following:

The phonegap-nfc library should support Android and iOS, although I haven’t tested on iOS. Notably, it looks like one additional step is required in the code: (

iOS requires you to begin a session before scanning a NFC tag.
nfc.beginSession(success, failure);

I first tried using the Web NFC standard ( but didn’t have any luck. As far as I can tell, this is only supported in Chrome and requires the #enable-webnfc flag which is disabled by default. Originally I thought the NFC web standard was not being supported ( but the link above and the Web-NFC GitHub show activity as of yesterday. This is promising and should be revisited to potentially bring support for NFC in the PWA version of Field Kit.

Some considerations for further development of NFC for Field Kit:

  • NFC support in Field Kit core would be idea. With this, tags could be “read” at anytime the app is open (and potentially trigger the opening of the Field Kit native app).
  • Creating a Field Kit NFC API could allow Field Modules to interface with NFC to read/write to tags themselves. Having an internal NFC API might simplify support for future web-nfc, too, because Field Kit core could detect 1) if it is running as PWA or Native and 2) detect if the device hardware supports NFC (via the web-nfc standard and phonegap-nfc library)
  • We need to brain storm how the NFC listeners will be structured in Field Kit core API - perhaps multiple listeners can be registered, so any Field Module that registers a listener could be used. Some info from the phonegap-nfc library:

Multiple listeners can be registered in JavaScript. e.g. addNdefListener, addTagDiscoveredListener, addMimeTypeListener.

On Android, only the most specific event will fire. If a Mime Media Tag is scanned, only the addMimeTypeListener callback is called and not the callback defined in addNdefListener. You can use the same event handler for multiple listeners.

There also needs to be some thought into the UI

  • @jgaehring had an interesting idea where, when an NFC tag is read, a popup could display that allows the user to select how to handle the event - i.e. “View Asset”, “Create Observation for ___”, etc… and Field Modules could register these actions.
  • Other use cases might be more “background” where, when editing a log, if an asset tag is read, the asset should automatically be added to the log. Something similar could be done with areas.
  • There will need to be an interface for writing to NFC tags. Perhaps a core interface that allows writing standard farmOS mimetypes, as well as allowing Field Modules to write custom tags.

Use cases (feel free to add!!)

  • Create/read tags for farmOS assets (animals, equipment, etc)
  • Auto-add assets to logs
  • Create/read tags for farmOS areas
  • Auto-add areas to logs
  • An “action” to “Create Observation Log” when an asset or area tag is created
  • Create/read tags for managing inventories
  • An “action” to auto increment/decrement an inventory when a tag is read
  • An “action” to “Clock In” on an employee timesheet when a tag is read
  • … (please, add other ideas!)

In the meantime, I’m going to continue working on a draft NFC Field Module to explore this more. We specifically need to play with writing NFC tags and see if the mime-types will work as expected. I’ll publish my fork once I’m further along for development reference.


I can’t tell you how excited I am to see this start to take shape! :smiley:

Here are two related discussions:

That first one was actually the first feature request in the farmOS issue queue on I think. :slight_smile:

It was focused on QR codes, but I was thinking more generally about being able to tie IDs to assets/areas in other ways as well (RFID, barcodes, etc). The basic idea being that we could have different ways of assigning IDs to assets and then use those for quick look-ups in different contexts (Field Kit is the PERFECT place to do this).

1 Like

This is great! And fantastic documentation @paul121!

Oh I like this! Does this relate to what you were talking about earlier how NFC tags can have an associated app name or identifier? Is that how the system knows what app to launch?

In my mind NFC tags are much more preferable to QR codes or barcodes. QR’s are write-once, you need a method of printing them, and they have to be able to endure the elements without fading or falling apart. NFC or RFID tags on the other hand are read/write and much more durable. They might be more costly (although I even wonder about that; Google barcodes printer prices if you’re curious), but I feel that these kinds of physical id’s are really best for long-term areas and assets anyways (like a field or a tractor, as opposed to a particular planting or bushel of product). So yea, lots of potential here!


Yea! I believe this is all controlled with Mime types (think like a content-type header in HTTP) - one such Mime type specifies an Android Application Record. Just saw this documented on the phonegap-nfc library here

val msg = NdefMessage(

Then by modifying AndroidManifest.yml I think we can enable launching-your-android-application-when-scanning-a-tag

Yea - especially with long-term “things”. They can really provide an alternative method of inputting data to the phone, even. Rather than typing a value, you can have NFC tags nailed to the wall that you tap. I think this would make sense for certain repetitive workflows where typing slows things down. (Seeding in trays comes to mind)

1 Like

In my mind NFC tags are much more preferable to QR codes or barcodes.

They might be more costly

I think that’s the equation that will make the choice clear in each specific operation/use-case. Big difference between managing 100s of assets vs 1000s or 10,000s.

I intend to allow farmOS (server) to support any/all of the above. Maybe Field Kit only supports a sub-set, depending on demand… we can see what folks ask for.

In playing with trying to autolaunch Field Kit with a mime type of application/farmos I had to add an <intent-filter> to AndroidManifest.xml (from the docs)

  • The problem is that Cordova doesn’t provide a way to edit AndroidManifest.xml. I manually edited the file that is generated after running cordova platform add android and cordova build android at: platforms/android/app/src/main/AndroidManifest.xml and this worked.
  • It looks this might be possible with the cordova-custom-config plugin. Wanted to document this, haven’t tried. Tutorial here

Finished a draft of the NFC “Field Module” - the main chunk of NFC code is here in my fork.

  • Read a tag and display all records that are saved to a card.
  • Support for writing to cards, but I haven’t been able to fully test this…

Unfortuantely I have NXP MifareClassic cards, which use a proprietary format, and require that hardware has an NXP chip to interface with the cards. This is a well-known issue. Some older devices have the hardware required, but most newer devices do not. Interestingly enough, I can read from the cards - I just can’t write to them.

  • Something worth noting: I am able to write to these cards using the nfc-tools Android App on a Pixel 3. (I believe this app is doing something special to crack the NXP encryption). Anyways, I am able to create custom application/farmos records with that app and interface with them in Field Kit.

Now to find the best source of some compatible NFC cards… I do believe the writing functionality should work!

1 Like

A short demo of the writing functionality is here:

I bought NFC tags from GoToTags (Made in Spokane, WA!) -
With these tags, you can specify the NFC Chip that is used. Most any of the NXP NTAG2XX chips will work! In general, the higher numbers have more memory than lower numbers. DON’T buy the get the Mifare Classic Chip

1 Like

This sounds like a really cool project and implementation. It would be very useful to track harvested products from the field to the sales point. Like what one would need for Global GAP.