Control sensor sampling interval with Epoch time

I’m a total newbie to blues wireless. I’ve got a basic blues weatherstation working well with the cellular notecard, but want to control sensor sampling to correspond/sync to Epoch time. For example, I want sample sensors and execute the notecard.sendRequest at intervals synced with local time. 11:05, 11:10, 11:15 … I have done that on other platforms using epoch time and time libraries. I’m sure lots of people are doing this with the blues cellular notecard, any pointers or examples of folks doing this. Thanks

Hi @micromet and welcome to the Blues community!

After your Notecard powers on and connects to Notehub you’ll have access to the current epoch time via the card.time API. You can use your host to base syncing intervals around this time going forward. Hope that helps!

Rob

Thanks, this is function I used - GPT4o assisted. Seems to work for ESP32. Is this a good approach, let me know if there is more efficient method. I assume there is template or sort for requesting info from the card and parsing the JSON to snag the vars you want to using in the mcu firmware.

unsigned long getEpochTimeFromNotecard() {
J *req = notecard.newRequest(“card.time”);
if (req == NULL) {
Serial.println(“Failed to create request”);
return 0;
}

J *rsp = notecard.requestAndResponse(req);
if (rsp == NULL) {
    Serial.println("Failed to get response");
    return 0;
}

// Check if 'time' field is present in the response
if (!JIsPresent(rsp, "time")) {
    Serial.println("No time field in response");
    JDelete(rsp);
    return 0;
}

// Get the epoch time
unsigned long epochTime = (unsigned long) JGetInt(rsp, "time");
JDelete(rsp);

return epochTime;

}

This looks good to me!