Change a Variable w/ HTML

I have worked hard to minimize the bandwidth for an Electron Project that monitors pressure sensors and CT’s.
My code uses #define(s) to establish publish delays for various sensors. The Electron is remotely deployed.
I’d like to swap from using hard coded #define delays to a Particle Variable that I will change every few days remotely, verses a full OTA firmware flash any time I want to modify the publish delays.

I believe I’ve previously read a thread or tutorial on what I want to accomplish, but I can’t find it now.

Any advise or direction to take for the inexperienced ?
Basically, I need to change an Electron variable from the Cloud (not very often), but avoid any unnecessary data usage.

Your question is a bit open-ended. Are you asking how one might technical issue an update to a Particle variable? If so, use a Particle.function. Are you asking how to setup a recurring job to update? If so, that really depends on what server platform (AWS, Azure, etc) and technologies you are using.

I appoligize for my ignorance. Here’s another try:

My Electron code currently works with several defines above Setup() such as:

#define publish_delay_long       300000       
#define alarm_delay             3600000
int ThresholdCurrent =              30; 

blah blah.......   
void setup()

I would like to be able to use variables instead of the define statements and integers, But be able to remotely change these variables (w/ HTML,command line, etc) to fine-tune the electron’s publishing rate and subsequent data usage. The electron is 2 hours away from my office and it’s a fairly lengthy program for OTA flashing.

Should I use a Particle.Variable inside void loop(), or Particle.Function outside?
Which method will “push” a new Integer to the electron, without the electron constantly checking ?

Thanks in advance for the Help.

Hi @Rftop

You need a Particle function to set values–Particle variables are read-only. Here’s a simple tutorial to help you along (note the syntax for Particle variables has been simplified since this was written, so check the doc):

1 Like

Thanks @bko and @harrisonhjones !
I really appreciate it :sunglasses:

1 Like