How to refresh data up to cloud by setting?

// M4 Feather to Notecard
  J *req = notecard.newRequest("hub.set");
  JAddStringToObject(req, "product", productUID);
  JAddStringToObject(req, "mode", "continuous"); // periodic / continuous
  JAddNumberToObject(req, "outbound", 20);
  JAddNumberToObject(req, "inbound", 60); // up load data frequency, in mints

  req = notecard.newRequest("card.location.mode");
  JAddStringToObject(req, "mode", "periodic");  // periodic / continuous
  JAddNumberToObject(req, "seconds", 60);   // periodic and <300s

  req = notecard.newRequest("card.location.track");
  JAddBoolToObject(req, "sync", true);
  JAddBoolToObject(req, "heartbeat", true);
  JAddNumberToObject(req, "hours", 1);

  req = NoteNewRequest("card.motion.mode");
  JAddBoolToObject(req, "start", true);


  if(notecard_data_update_counter > 50000){
    J *req = notecard.newRequest("note.add");
    if( req != NULL ){
      JAddStringToObject(req, "file", "sensors.qo");
      JAddBoolToObject(req, "sync", true);
      J *body = JAddObjectToObject(req, "body");
      if (body){
        JAddNumberToObject(body, "temp", temperature);
        JAddNumberToObject(body, "humidity", humidity);
        JAddNumberToObject(body, "cell_L", cell_min);
        JAddNumberToObject(body, "cell_H", cell_max);
        JAddNumberToObject(body, "SOC", cell_SOC);
        JAddNumberToObject(body, "Motor_temp", engine_temp[0]);
        JAddNumberToObject(body, "Motor_rpm", motor_speed[4]);
        JAddNumberToObject(body, "Km/h", wheel_speed[2]);
    if( req != NULL ){
      J *rsp = notecard.requestAndResponse(notecard.newRequest("card.location"));
      gps_time_s = JGetInt(rsp, "time");
    notecard_data_update_counter = 0;

i’m use M4 feather CAN + notecard
it can only up date to once when power on, that’s all.
i need it can be pump up the data to every 5 mints or maybe 10 mints.
also GPS can be keep pumping the location every 60s.
can someone help me to optimized the code?
not sure where is wrong…
thanks lot!!!

Hi @williamzoe2002,

It’s important to remember that you can’t have the cellular modem and GPS module active at the same time. Some of your configurations are causing the Notecard to try and switch between them too quickly, leading to nothing working very well! Here is what I would suggest:

  1. In your hub.set call, outbound should be 5 or 10 (this is how often the Notecard will try to sync data OUT to Notehub).
  2. In the same call, set inbound to something high, like 1440. This is how often the Notecard will try to sync INBOUND data from Notehub.
  3. In card.location.track, remove the sync:true argument. This is forcing the Notecard to try and sync too frequently based on your other configurations.
  4. Remove the JAddBoolToObject(req, "sync", true); line from your note.add call. This is also forcing Notecard to sync too frequently (just rely on the hub.set outbound syncing).

For other best practices, be sure to check out our asset tracking guide.


thank you so much,

here has another question,
I use Arduino IDE to coding

J *req = notecard.newRequest(“hub.set”);
req = notecard.newRequest(“card.location.mode”);
req = notecard.newRequest(“card.location.track”);
req = NoteNewRequest(“card.motion.mode”);

  1. all of these req are put them at “void setup()”, or “void loop()”?

  2. is M4 feather need give the command to notecard to switch syn all the time?
    or notecard will syn data itself by setting once?