I cant get data to transmit from LoRa Notecard but its connecting to the Notehub

Hi, I’m new to this and think I’m probably just missing something silly, but cant see it.

I have a Lorawan starter kit and have set up my notehub and blues lora gateway, all good so far.

I’m using an ESP32 card to deal with the monitors I’m making and have this connected to the notecard. When I power everything up after a short while it shows the notecard is connected in the notehub but no data is being transmitted, even though looking at the serial monitor I get a response of “note queued ok” and then “data sent” . Below is the serial monitor output and the sketch from the arduino ide, i must be missing something bot just cant spot it, Chatgpt had me off of a wilde goose chase, so any help would be appreciated

Temp: 20.00 C | Moisture: 100 %
Note queued OK
Data sent

#include <Wire.h>

#include <Notecard.h>

#include <OneWire.h>

#include <DallasTemperature.h>

// ----------------------

// PIN DEFINITIONS

// ----------------------

#define SDA_PIN 21

#define SCL_PIN 22

#define ONE_WIRE_BUS 4

#define MOISTURE_PIN 34

// ----------------------

// SENSOR SETUP

// ----------------------

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

// ----------------------

// NOTECARD

// ----------------------

Notecard notecard;

// ----------------------

// CALIBRATION VALUES

// ----------------------

int dryValue = 3000; // adjust after calibration

int wetValue = 1500; // adjust after calibration

void setup() {

Serial.begin(115200);

delay(2000);

// I2C for Notecard

Wire.begin(SDA_PIN, SCL_PIN);

notecard.begin();

// Start temp sensor

sensors.begin();

// ----------------------

// SET PRODUCT + MODE

// ----------------------

J *req = notecard.newRequest(“hub.set”);

JAddStringToObject(req, “product”, “MyproductID - Redacted”);

JAddStringToObject(req, “mode”, “periodic”);

JAddNumberToObject(req, “outbound”, 1); // fast for testing

notecard.sendRequest(req);

// ----------------------

// DEFINE NOTETEMPLATE (REQUIRED FOR LORA)

// ----------------------

J *tmpl = notecard.newRequest(“note.template”);

JAddStringToObject(tmpl, “file”, “sensors.qo”);

JAddNumberToObject(tmpl, “port”, 1);

JAddStringToObject(tmpl, “format”, “json”);

J *body = JCreateObject();

JAddNumberToObject(body, “temp”, 0);

JAddNumberToObject(body, “moisture”, 0);

JAddItemToObject(tmpl, “body”, body);

notecard.sendRequest(tmpl);

// ----------------------

// FORCE INITIAL SYNC

// ----------------------

J *syncReq = notecard.newRequest(“hub.sync”);

notecard.sendRequest(syncReq);

Serial.println(“System started”);

}

void loop() {

// ----------------------

// READ TEMPERATURE

// ----------------------

sensors.requestTemperatures();

float tempC = sensors.getTempCByIndex(0);

// ----------------------

// READ MOISTURE

// ----------------------

int rawMoisture = analogRead(MOISTURE_PIN);

int moisturePercent = map(rawMoisture, dryValue, wetValue, 0, 100);

moisturePercent = constrain(moisturePercent, 0, 100);

// ----------------------

// PRINT DEBUG

// ----------------------

Serial.print("Temp: ");

Serial.print(tempC);

Serial.print(" C | Moisture: ");

Serial.print(moisturePercent);

Serial.println(" %");

// ----------------------

// SEND TO NOTECARD

// ----------------------

J *req = notecard.newRequest(“note.add”);

JAddStringToObject(req, “file”, “sensors.qo”);

J *body = JCreateObject();

JAddNumberToObject(body, “temp”, tempC);

JAddNumberToObject(body, “moisture”, moisturePercent);

JAddItemToObject(req, “body”, body);

// Send and check response

J *rsp = notecard.requestAndResponse(req);

if (rsp != NULL) {

Serial.println("Note queued OK");

notecard.deleteResponse(rsp);

} else {

Serial.println("Error sending note");

}

// ----------------------

// FORCE SYNC (SEND DATA NOW)

// ----------------------

J *syncReq = notecard.newRequest(“hub.sync”);

notecard.sendRequest(syncReq);

Serial.println(“Data sent”);

// ----------------------

// WAIT

// ----------------------

delay(60000); // 1 min (testing only)

}

Hey @wallywombat,

And welcome to the Blues community! The issue in your example is how you’re creating your Note template with the note.template request.

  1. You need to use "format": "compact" instead of "format": "json".

  2. You’re providing 0 as a data type for both "temp" and "moisture", which is invalid. See this list to see all our template types, but I’m guessing you want to use something like 14.1 (4-byte float) for temp and 21 (2-byte unsigned integer) for moisture. So that’d be JAddNumberToObject(body, "temp", 14.1); JAddNumberToObject(body, "moisture", 21);

And as a side note: if you’re using LLMs to help with your firmware development we recommend installing the Blues Expert MCP server. The MCP includes a tool that verifies all Notecard API arguments are valid, which in theory would help catch things like this. It’s AI so it’s all still non deterministic, but it should up your odds :stuck_out_tongue: If you have any other questions let me know.

TJ

Brilliant, thanks that fixed it, were up and running :grinning_face_with_smiling_eyes: