# Reasonable frequency to check environmental variables

**URL:** <https://discuss.blues.com/t/reasonable-frequency-to-check-environmental-variables/1830>\
**Category:** Uncategorized\
**Created:** [December 4, 2023, 8:09pm UTC](https://discuss.blues.com/t/reasonable-frequency-to-check-environmental-variables/1830 "2023-12-04T20:09:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TJK](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@TJK](https://discuss.blues.com/u/TJK)\
**Post date:** [December 4, 2023, 8:09pm UTC](https://discuss.blues.com/t/reasonable-frequency-to-check-environmental-variables/1830/1 "2023-12-04T20:09:05Z")

</div>

I have several Environmental Variables defined. A few of these will not change often and some will be updated more frequently. My question is when running this code(below) to get the EV what is a reasonable frequency to check? Once per minute, second hour. I am trying to avoid making too many requests on [notehub.io](http://notehub.io).  
J\* req = notecard.newRequest(“env.get”);  
if (req != NULL) {  
JAddStringToObject(req, “name”, “reading\_interval”);  
J\* rsp = notecard.requestAndResponse(req);  
int readingIntervalEnvVar = atoi(JGetString(rsp, “text”));  
if (readingIntervalEnvVar \> 0) {  
sensorIntervalSeconds = readingIntervalEnvVar;  
}  
notecard.deleteResponse(rsp);  
}  
defaultInterval=sensorIntervalSeconds;

---

<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:** [December 5, 2023, 3:44pm UTC](https://discuss.blues.com/t/reasonable-frequency-to-check-environmental-variables/1830/2 "2023-12-05T15:44:42Z")

</div>

Hi @TJK,

Just to be clear - a call to `env.get` is a request to the Notecard, not Notehub. Environment variables are synced only when the Notecard and Notehub are in communication. It’s really up to you how often you connect/sync with Notehub. If data usage is a concern I would recommend looking at our [guide on data usage estimates](https://dev.blues.io/notecard/notecard-walkthrough/low-bandwidth-design/#data-usage-estimates) to find the right balance of settings and sync cadence.

The best technique for polling the Notecard is to poll using [env.modified](https://dev.blues.io/api-reference/notecard-api/env-requests/#env-modified) every 15 seconds or however often it is convenient for the host. Only if `env.modified` indicates that an environment variable has changed would you then call `env.get` to refresh the environment variable values on the host.

Rob

---

<div class="post-metadata">

**Author:** ![TJK](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@TJK](https://discuss.blues.com/u/TJK)\
**Post date:** [December 5, 2023, 8:10pm UTC](https://discuss.blues.com/t/reasonable-frequency-to-check-environmental-variables/1830/3 "2023-12-05T20:10:24Z")

</div>

Thank you. I understand.  
Can you please point me in the direction of a tutorial illustrating the implementation of the concept? I assume I will provide the time of the last lookup or save the previous returned time. Unix time suggests millis() may not be the best choice.

---

<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:** [December 5, 2023, 10:27pm UTC](https://discuss.blues.com/t/reasonable-frequency-to-check-environmental-variables/1830/4 "2023-12-05T22:27:01Z")

</div>

Hi @TJK,

We have a couple of environment variable resources to share:

1. This guide on [Understanding Environment Variables](https://dev.blues.io/guides-and-tutorials/notecard-guides/understanding-environment-variables/#understanding-environment-variables) is a good place to start
2. All of [these open source Accelerator apps](https://dev.blues.io/accelerators/?category=&feature=environment-variables) use environment variables extensively, so there should be a code example or two to borrow from.

Let us know if you need any help though!  
Rob

---

<div class="post-metadata">

**Author:** ![Pius4109](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@Pius4109](https://discuss.blues.com/u/Pius4109)\
**Post date:** [October 18, 2024, 11:33am UTC](https://discuss.blues.com/t/reasonable-frequency-to-check-environmental-variables/1830/5 "2024-10-18T11:33:21Z")

</div>

Would querying the environmental variables every 1 second have any adverse effect on the notecard’s memory.
