Field type error creating template

I see this error

{"err":"unrecognized template field type indicator: 11.110000 {template-incompatible}"}

when I run this code on an MCU connected over I2C to a notecard

  // establish sensor data template to optimise queue and data usage
  req = nc.newRequest("note.add");
  if (req != NULL) {
    // Create the body for a template that will be used to send notes below
    J *body = JCreateObject();
    if (body != NULL) {
      // Define the JSON template
      JAddNumberToObject(body, "ncvoltage", 11.11);
      JAddNumberToObject(body, "nctemp", 22.22);
      JAddNumberToObject(body, "battery", 33.33);
      JAddNumberToObject(body, "current", 44.44);
      JAddNumberToObject(body, "ftemp", 55.55);
      JAddNumberToObject(body, "pressure", 6666.66);
      JAddNumberToObject(body, "humidity", 77.77);
      // Add the body to the request
      JAddItemToObject(req, "body", body);
    else {
      nc.logDebug("Failed to create template body\n");

    // Create a template of the payload that will be used to send
    // notes below
    // JAddNumberToObject(req, "length", sizeof(myBinaryPayload));

    // Register the template in the output queue notefile
    JAddStringToObject(req, "file", "fred.qo");
    JAddBoolToObject(req, "template", true);
  else {
    nc.logDebug("Failed to create note template\n");

Please note that this code is derived from

Not sure where to start - what might be causing this issue? - thanks

Hi @nicbkw,

Thanks for pointing out that code sample in the note-arduino library. While functional, it’s outdated and there is a better (more intuitive) way of creating Note templates now with the note.template API.

When defining a template, the value you pass for each item needs to correspond to one of the defined template data types. So for example, your ncvoltage might be defined as this (for a 2 byte float):

JAddNumberToObject(body, "ncvoltage", 12.1);

Please take a look at our low bandwidth guide for more details on using templates, but in the meantime, here is the code I would try for your use case:

// this only needs to be run once

J *req = nc.newRequest("note.template");
JAddStringToObject(req, "file", "fred.qo");

J *body = JCreateObject();
JAddNumberToObject(body, "ncvoltage", 12.1);
JAddNumberToObject(body, "nctemp", 12.1);
JAddNumberToObject(body, "battery", 12.1);
JAddNumberToObject(body, "current", 12.1);
JAddNumberToObject(body, "ftemp", 12.1);
JAddNumberToObject(body, "pressure", 12.1);
JAddNumberToObject(body, "humidity", 12.1);
JAddItemToObject(req, "body", body);


Then, issue a note.add request like you would normally, being sure to specify the file argument:

J *req = nc.newRequest("note.add");
JAddStringToObject(req, "file", "fred.qo");

J *body = JCreateObject();
JAddNumberToObject(body, "ncvoltage", 3.45);
// etc etc...
JAddItemToObject(req, "body", body);


The response to this note.add should be {"template": true}.

Hope this helps!


Hi Rob, thanks for the quick reply.
This could be a couple of really dumb questions, but…
does the value 12.1 have any importance when related to a 2 byte float?
I have defined all variables as doubles
Is 12.1 still appropriate for pressure that would typically have a value of ~ 1000.00?

Sorry, should have RTFM - here:

1 Like

Yep, exactly! All of the data types are documented there. Let us know if you have further questions.