# NFC in farmOS Field Kit

**URL:** <https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179>\
**Category:** Development\
**Created:** [January 8, 2020, 5:38pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179 "2020-01-08T17:38:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul121](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@paul121](https://farmos.discourse.group/u/paul121)\
**Post date:** [January 8, 2020, 5:38pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/1 "2020-01-08T17:38:07Z")

</div>

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:

- adding `cordova plugin add phonegap-nfc` to the Field Kit app (this adds a line to `package.json` which includes the [phonegap-nfc library](https://github.com/chariotsolutions/phonegap-nfc)
- Created an “NFC” Field Module" with a main “view” that largely resembles this Cordova NFC Sample: [https://github.com/c4software/vuejs-cordova-sample/blob/master/src/views/Nfc.vue](https://github.com/c4software/vuejs-cordova-sample/blob/master/src/views/Nfc.vue)
- When the NFC view is `mounted` a Tag listener is created via `nfc.addTagDiscoveredListener()`. After this, NFC tags are registered within the app, rather than the Android System Default.
- In the NFC view `beforeDestroy` `nfc.remoteTagDiscoveredListener()` removes the listener, and NFC events are handled _by the system_, not Field Kit.
- Also, a good reference on Cordova NFC: [Writing NFC Apps with Apache Cordova](https://don.github.io/slides/2014-04-07-apachecon-nfc/)

The phonegap-nfc library should support Android and iOS, although I haven’t tested on iOS. Notably, it looks like one [additional step](https://github.com/chariotsolutions/phonegap-nfc#nfcbeginsession) 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 ([Web NFC](https://w3c.github.io/web-nfc/)) 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 ([Web NFC API](https://www.w3.org/TR/nfc/)) but the link above and the Web-NFC [GitHub](https://github.com/w3c/web-nfc/) 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.

- This brings up the `nfc.addMimeTypeListener` ([GitHub - chariotsolutions/phonegap-nfc: PhoneGap NFC Plugin](https://github.com/chariotsolutions/phonegap-nfc#nfcaddmimetypelistener)) - Theoretically, tags could be written with a custom mimetime of `application/farm_asset` or `application/farm_area`, and be used to trigger specific mime-type listeners. This seems promising to me!

**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.

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [January 8, 2020, 6:43pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/2 "2020-01-08T18:43:30Z")

</div>

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

Here are two related discussions:

- [https://www.drupal.org/project/farm/issues/2396617](https://www.drupal.org/project/farm/issues/2396617)
- [https://github.com/farmOS/farmOS-client/issues/275](https://github.com/farmOS/farmOS-client/issues/275)

That first one was actually the first feature request in the farmOS issue queue on [Drupal.org](http://Drupal.org) I think. 🙂

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).

---

<div class="post-metadata">

**Author:** ![jgaehring](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/jgaehring/32/927_2.png) [@jgaehring](https://farmos.discourse.group/u/jgaehring)\
**Post date:** [January 9, 2020, 4:45am UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/3 "2020-01-09T04:45:44Z")

</div>

This is great! And fantastic documentation @paul121!

> [@paul121](#):
>
> (and potentially trigger the opening of the Field Kit native app).

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?

> [@mstenta](#):
>
> 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).

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!

---

<div class="post-metadata">

**Author:** ![paul121](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@paul121](https://farmos.discourse.group/u/paul121)\
**Post date:** [January 9, 2020, 5:10am UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/4 "2020-01-09T05:10:45Z")

</div>

> [@jgaehring](#):
>
> 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?

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](https://github.com/chariotsolutions/phonegap-nfc#ndefrecord)

```auto
val msg = NdefMessage(
        arrayOf(
                ...,
                NdefRecord.createApplicationRecord("com.example.android.beam")
        )
)

```

Then by modifying `AndroidManifest.yml` I think we can enable [launching-your-android-application-when-scanning-a-tag](https://github.com/chariotsolutions/phonegap-nfc#launching-your-android-application-when-scanning-a-tag)

> [@jgaehring](#):
>
> In my mind NFC tags are much more preferable to QR codes or barcodes.

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)

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [January 9, 2020, 5:30pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/5 "2020-01-09T17:30:34Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![paul121](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@paul121](https://farmos.discourse.group/u/paul121)\
**Post date:** [January 14, 2020, 2:06am UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/6 "2020-01-14T02:06:04Z")

</div>

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](https://github.com/chariotsolutions/phonegap-nfc#launching-your-android-application-when-scanning-a-tag))

- 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](https://ourcodeworld.com/articles/read/101/how-to-list-your-cordova-app-in-open-with-menu-in-android-and-handle-the-intent-event)

---

<div class="post-metadata">

**Author:** ![paul121](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@paul121](https://farmos.discourse.group/u/paul121)\
**Post date:** [January 14, 2020, 4:33am UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/7 "2020-01-14T04:33:52Z")

</div>

**Finished a draft of the NFC “Field Module” - the main chunk of NFC code is [here](https://github.com/paul121/farmOS-client/blob/nfc/src/field-modules/nfc/components/NFC.vue) 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!

---

<div class="post-metadata">

**Author:** ![paul121](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@paul121](https://farmos.discourse.group/u/paul121)\
**Post date:** [February 6, 2020, 1:40am UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/8 "2020-02-06T01:40:14Z")

</div>

A short demo of the writing functionality is here: [https://drive.google.com/open?id=1OAFTZb7ftjtPC4HhFOLxkWsL0ERjQbF0](https://drive.google.com/open?id=1OAFTZb7ftjtPC4HhFOLxkWsL0ERjQbF0)

I bought NFC tags from GoToTags (Made in Spokane, WA!) - [https://store.gototags.com/nfc/nfc-tags/](https://store.gototags.com/nfc/nfc-tags/)  
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**

---

<div class="post-metadata">

**Author:** ![Lars](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@Lars](https://farmos.discourse.group/u/Lars)\
**Post date:** [February 7, 2020, 11:24pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/9 "2020-02-07T23:24:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sam\_uk](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@sam\_uk](https://farmos.discourse.group/u/sam_uk)\
**Post date:** [February 11, 2021, 10:04pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/10 "2021-02-11T22:04:50Z")

</div>

I’m very excited by NFC & FarmOS. Has there been any progress on this?

---

<div class="post-metadata">

**Author:** ![Symbioquine](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/symbioquine/32/284_2.png) [@Symbioquine](https://farmos.discourse.group/u/Symbioquine)\
**Post date:** [February 12, 2021, 3:50am UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/11 "2021-02-12T03:50:29Z")

</div>

Not trying to derail the thread or dissuade anyone from pursuing NFC, but I’d like to make counter-points to some of those presented here;

> [@jgaehring](#):
>
> 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.

- QR codes have the potential to be a lot more environmentally-friendly;
  - For some applications you can print them on regular paper - admittedly paper isn’t always the most environmentally-friendly thing, but I’m pretty confident it is way better than high-cardinality e-waste
  - If you have access to a low power laser etcher (like at a local maker-space), you can print them on bits of scrap wood

- For other applications, a pretty good price-point can be hit with waterproof paper by optimizing the software for formatting many codes on a single page
- You’re making a choice about whether QR codes are single use or not, it’s pretty trivial to add a layer of indirection where the final reference in the tag/code/link of the QR code is re-assignable

> [@jgaehring](#):
>
> 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!

This is a pretty complicated cost trade-off. With something like a QR/bar code the hardware for reading/writing is ubiquitous and intuitive to humans whereas wireless electronic tags are opaque to humans and require dedicated hardware for reading/programming them.

---

<div class="post-metadata">

**Author:** ![jgaehring](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/jgaehring/32/927_2.png) [@jgaehring](https://farmos.discourse.group/u/jgaehring)\
**Post date:** [February 12, 2021, 5:24pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/12 "2021-02-12T17:24:09Z")

</div>

Ok, ok, you got my wheels turning now, @Symbioquine.

I’m wondering now if there is some kind of reusable material that could be used, with no electronic parts, to “print” the QR code onto. I’m thinking about something that might be sensitive to heat, or a particular frequency of UV light, etc. It would just need two states, light and dark, which could then be used as binary data for the QR printer.

If such a thing exists, it could achieve most of our goals: waterproof, sunproof, durable, eco-friendly, etc. The remaining question would be cost and ubiquity, but again, I’m less concerned with ubiquity, b/c I think there are better signifiers that don’t require the creation of a new artifact to track (I have a whole theory about this which I won’t go into now). Long story short, I see physical tagging as sort of an edge scenario to begin with, so I don’t see cost and ubiquity as much of a barrier.

---

<div class="post-metadata">

**Author:** ![Symbioquine](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/symbioquine/32/284_2.png) [@Symbioquine](https://farmos.discourse.group/u/Symbioquine)\
**Post date:** [February 12, 2021, 5:33pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/13 "2021-02-12T17:33:04Z")

</div>

Yeah, or an open version of [https://www.meshtag.com/](https://www.meshtag.com/) so the scannable references could be trivially hand-written/carved/burned/etc…

---

<div class="post-metadata">

**Author:** ![jgaehring](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/jgaehring/32/927_2.png) [@jgaehring](https://farmos.discourse.group/u/jgaehring)\
**Post date:** [February 12, 2021, 5:33pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/14 "2021-02-12T17:33:38Z")

</div>

> [@sam\_uk](#):
>
> I’m very excited by NFC & FarmOS. Has there been any progress on this?

Sorry, to get back to your original question, @sam_uk, I don’t think there’s been a lot of development here, but perhaps @paul121 would know better.

A major hurdle at this point is the reliance on native API’s, because NFC is not yet available through web browsers. We have experimented with these API’s via Cordova, which gives us access to the native API’s but at considerable cost. We’ve decided, at least for the time being, to direct our focus towards the progressive web app (PWA) for Field Kit, rather than the native iOS and Android releases. More info on that here:

> [@Field Kit: a platform dilemma](https://farmos.discourse.group/t/field-kit-a-platform-dilemma/433):
>
> Hi everyone! As you might know, we’ve been in the beta phase for farmOS Field Kit for quite some time, while we try to nail down the core functionality and reach a level of relative stability. As we do so, we encourage users to test it out and provide feedback, and because we’re using a “Hybrid App” approach, we’re able to do so across 3 separate platforms: native Android (via the Play Store), native iOS (via Apple’s TestFlight), and on the web as a Progressive Web App (PWA) at [https://farmos.a…](https://farmos.app)

---

<div class="post-metadata">

**Author:** ![jgaehring](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/jgaehring/32/927_2.png) [@jgaehring](https://farmos.discourse.group/u/jgaehring)\
**Post date:** [February 12, 2021, 5:34pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/15 "2021-02-12T17:34:47Z")

</div>

Oh, that’s AWESOME!! Thanks, @Symbioquine!

---

<div class="post-metadata">

**Author:** ![Symbioquine](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/symbioquine/32/284_2.png) [@Symbioquine](https://farmos.discourse.group/u/Symbioquine)\
**Post date:** [February 12, 2021, 5:40pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/16 "2021-02-12T17:40:51Z")

</div>

> [@jgaehring](#):
>
> A major hurdle at this point is the reliance on native API’s, because NFC is not yet available through web browsers. We have experimented with these API’s via Cordova, which gives us access to the native API’s but at considerable cost. We’ve decided, at least for the time being, to direct our focus towards the progressive web app (PWA) for Field Kit, rather than the native iOS and Android releases.

Not to beat a dead horse, but QR code scanning is already feasible in a PWA with something like [qr-scanner - npm](https://www.npmjs.com/package/qr-scanner)

> [@jgaehring](#):
>
> Oh, that’s AWESOME!! Thanks, @Symbioquine!

Sure thing! I’m not convinced that service should be used as-is, but the idea is golden…

---

<div class="post-metadata">

**Author:** ![sam\_uk](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@sam\_uk](https://farmos.discourse.group/u/sam_uk)\
**Post date:** [February 12, 2021, 6:00pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/17 "2021-02-12T18:00:38Z")

</div>

QR codes would certainly be better than nothing. Last time we tried FarmOS it didn’t work out as the data entry barrier/ time was just too high. It was easier and quicker to use paper records.

QR might cut it, but it’s still a bit fiddly.

Workflow something like;  
Try to focus camera with muddy fingers, take the photo.  
Try again, finally save the photo,  
Add data.  
Wipe the mud off the screen as best you can.

NFC seems like its potentially quicker and easier, but I understand it’s not technically easy. Is this the thing you’ve already tried? [https://web.dev/nfc/](https://web.dev/nfc/)

---

<div class="post-metadata">

**Author:** ![Symbioquine](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/symbioquine/32/284_2.png) [@Symbioquine](https://farmos.discourse.group/u/Symbioquine)\
**Post date:** [February 12, 2021, 7:17pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/18 "2021-02-12T19:17:29Z")

</div>

Thanks for sharing that! farmOS and especially Field Kit certainly need to be designed with these UX challenges at the forefront of the design constraints.

@jgaehring I think you are already probably thinking along these lines… What does a “Field First” UX design ethic for Field Kit look like?

---

<div class="post-metadata">

**Author:** ![jgaehring](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/jgaehring/32/927_2.png) [@jgaehring](https://farmos.discourse.group/u/jgaehring)\
**Post date:** [February 12, 2021, 9:34pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/19 "2021-02-12T21:34:57Z")

</div>

> [@Symbioquine](#):
>
> I think you are already probably thinking along these lines… What does a “Field First” UX design ethic for Field Kit look like?

Ok, I’ll give you the whole screed now… 😛

My reluctance to use QR codes, or any kind of physical tagging mechanism, comes from the belief that, in most cases, this adds a layer of “accidental complexity”, which we should try to eliminate by rethinking the problem we’re trying to solve.

A tag introduces a new physical artifact as a proxy to the actual physical entity you want to track. This is done with the presumption that the proxy will be easier to identify than the entity itself. However, it introduces the need, at some level, to keep track of two representations of the object, whereas before there was only one. It also requires that we create the tag in the first place (and maintain it, replicate it, etc, if it’s not sufficiently durable), affix it physically to the entity in some reliable fashion, and similarly link its digital identifier to the digital representation of the entity. All of this is preliminary to the task of reading the tag, and must be taken into account when evaluating costs and benefits.

Once again, this is all done in the service of identifying the original physical entity; we aren’t doing this because we care about tracking the tag itself, but what the tag represents. Ultimately, we are trying to link the digital representation of the entity (eg, a farmOS asset) to its physical reality. For that, we need some kind of _signifier_. The tag seems like an ideal and unambiguous signifier, because it has physical attributes which directly represent a digital identity, but again, there are tradeoffs.

I would argue that, in most cases, there are sufficient _natural signifiers_ to identify an entity without the overhead of creating and maintaining a tag. And I’ll go a step further to argue that, in ideal circumstances, the best approach is to focus on how we track the digital entity, rather than the physical entity itself.

Think of these natural signifiers as context clues. Some good examples are the current time, the user’s geolocation, the identity of the user, visual information embedded in the environment or the entity itself. If you want to identify which crop you’re about to weed or harvest, you’re probably in geographic proximity to as many crops as you can count on one hand. If your device has you logged in, and the task has been assigned to you, it should be able to use your geolocation and the time on the clock to infer what task you’re about to do. Then, good UX should take over and provide the user with the most likely actions to perform on that task, like check off that the bed has been weeded, or provide a field for entering the number of crates harvested, with as few clicks/taps to get there as possible.

Ok, that’s low hanging fruit, and probably not somewhere you’d think to use tags anyways. So…

A bigger challenge is inventory items, or basically anything in a container, because these tend to be stacked or stored close together, which rules out geolocation almost immediately. It may not help to have the user id in these cases either, because there’s a good chance the user may be interacting with dozens if not hundreds of different containers of the same kind. They’re also probably hard to distinguish visually. I’m thinking here of seed trays in a greenhouse or bins in a walk-in cooler. So now we don’t really have natural signifiers to fall back on, what we do?

First, I’ll remind you that in these circumstances tagging also becomes that much harder, b/c you need to be able to produce, affix and assign tags to each and every item individually. Also take into account that tags in these kinds of scenarios are going to be fairly ephemeral, while the containers are reusable. So you are going to need to have a process for removing old tags from your bins or trays once you change them out, otherwise it will create confusion when you try to assign new tags to the bins.

This is where I would advocate for using more advanced _reading_ technology, rather than writing technology.

OCR technology is quickly becoming ubiquitous and cheap, and I think is the right path forward for these scenarios. So instead of having to produce, affix and assign a tag to a container, you just use a grease pencil, or tape and sharpie. Using natural language to identify bins comes with the added benefit that it’s human-readable as well as machine-readable, so you don’t have to go to extra effort to mark a bin twice (once with pencil, once with a tag), or leave it to the next person to have to pull out their phone just to know whether its beets or onions in that freshly seeded tray. Probably most folks are already writing the names of stuff anyways.

There are lots of other scenarios which fall in between, and even scenarios where a tag might be warranted (tracking animals comes to mind). But I think the vast majority will fall into one of these two use cases.

One key to this approach is to always prefer lo-tech writes and hi-tech reads, rather than hi-tech writes and lo-tech reads. There is also a built in assumption that there will be robust planning and record-keeping so you can trace the life of an asset in data first, and use that to infer when and where an activity will occur. Now that can be a lot to ask, I admit, because no information system is infallible, but I think it’s the right solution we should be striving to reach.

\</screed\>

---

<div class="post-metadata">

**Author:** ![jgaehring](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/jgaehring/32/927_2.png) [@jgaehring](https://farmos.discourse.group/u/jgaehring)\
**Post date:** [February 12, 2021, 9:47pm UTC](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179/20 "2021-02-12T21:47:13Z")

</div>

> [@sam\_uk](#):
>
> NFC seems like its potentially quicker and easier, but I understand it’s not technically easy. Is this the thing you’ve already tried? [Interact with NFC devices on Chrome for Android - Chrome for Developers](https://web.dev/nfc/)

We did something a little different in the past, using a Cordova plugin, but the NFC Web API you link to above is what we would prefer to use. Problem is it’s not standard and only supported in Chrome Android:

> **[Web NFC API - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_NFC_API#browser_compatibility)**
>
> The Web NFC API allows exchanging data over NFC via light-weight NFC Data Exchange Format (NDEF) messages.

[Next page](https://farmos.discourse.group/t/nfc-in-farmos-field-kit/179.md?page=2)
