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