# How to refresh data up to cloud by setting?

**URL:** <https://discuss.blues.com/t/how-to-refresh-data-up-to-cloud-by-setting/1365>\
**Category:** Uncategorized\
**Created:** [April 11, 2023, 10:43am UTC](https://discuss.blues.com/t/how-to-refresh-data-up-to-cloud-by-setting/1365 "2023-04-11T10:43:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![williamzoe2002](https://avatars.discourse-cdn.com/v4/letter/w/76d3ee/32.png) [@williamzoe2002](https://discuss.blues.com/u/williamzoe2002)\
**Post date:** [April 11, 2023, 10:43am UTC](https://discuss.blues.com/t/how-to-refresh-data-up-to-cloud-by-setting/1365/1 "2023-04-11T10:43:05Z")

</div>

```auto
// M4 Feather to Notecard
  serialDebug.begin(115200);
  notecard.begin();
  notecard.setDebugOutputStream(usbSerial);
  
  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
  notecard.sendRequest(req);

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

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

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

/////////

notecard_data_update_counter++;
  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]);
      }
      notecard.sendRequest(req);
    }
    if( req != NULL ){
      J *rsp = notecard.requestAndResponse(notecard.newRequest("card.location"));
      gps_time_s = JGetInt(rsp, "time");
      NoteDeleteResponse(rsp);
    }
    notecard_data_update_counter = 0;
  }

```

i’m use M4 feather CAN + notecard  
it can only up date to [notehub.io](http://notehub.io) once when power on, that’s all.  
i need it can be pump up the data to [notehub.io](http://notehub.io) 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!!!

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [April 11, 2023, 1:19pm UTC](https://discuss.blues.com/t/how-to-refresh-data-up-to-cloud-by-setting/1365/2 "2023-04-11T13:19:02Z")

</div>

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](https://dev.blues.io/guides-and-tutorials/notecard-guides/asset-tracking/).

Thanks,  
Rob

---

<div class="post-metadata">

**Author:** ![williamzoe2002](https://avatars.discourse-cdn.com/v4/letter/w/76d3ee/32.png) [@williamzoe2002](https://discuss.blues.com/u/williamzoe2002)\
**Post date:** [April 12, 2023, 1:46am UTC](https://discuss.blues.com/t/how-to-refresh-data-up-to-cloud-by-setting/1365/3 "2023-04-12T01:46:32Z")

</div>

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?
