Hello,
Suppose I do io.connect() in the setup() function and send data in the loop() function. After each "send" is complete, I have a delay(DELAY_TIME) statement to wait for awhile before sending more data. How long does the connection to IO stay open? If I send data only once every minute or so, will the connection still be open? If not, can I move the io.connect() into the loop() function to re-open the connection each time?
Thanks.
How long will IO stay connected?
Moderators: adafruit_support_bill, adafruit
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
- brubell
- Learn User Page
- Posts: 2017
- Joined: Fri Jul 17, 2015 10:33 pm
Re: How long will IO stay connected?
Which hardware platform and software library are you using to connect to Adafruit IO? I can give you an exact answer based off that.
- earthres
- Posts: 231
- Joined: Fri May 28, 2021 10:48 am
Re: How long will IO stay connected?
I'm using a HUZZAH32 with the Adafruit IO libraries for that board.
- brubell
- Learn User Page
- Posts: 2017
- Joined: Fri Jul 17, 2015 10:33 pm
Re: How long will IO stay connected?
The KeepAlive time is part of the MQTT specification, it's defined in the Adafruit MQTT library here and defaults to five minutes:earthres wrote:I'm using a HUZZAH32 with the Adafruit IO libraries for that board.
https://github.com/adafruit/Adafruit_MQ ... QTT.h#L104
It gets sent to IO when io.connect() is called. You may change it by editing that file on your computer.
- earthres
- Posts: 231
- Joined: Fri May 28, 2021 10:48 am
Re: How long will IO stay connected?
OK. Thanks. That's a VERY helpful answer. As I'm sure you know, there are a ton of online resources for posting environmental data to IoT dashboards, including Adafruit IO. Almost always, posting such data more frequently than every few minutes is a waste of data storage space and, for outdoor solar/battery-powered systems, a waste of power. Using a BME280 sensor to upload temperature, relative humidity, and pressure is a perfect example of a project where posting data at intervals under five minutes makes perfect sense and posting more frequently than that makes no sense for those particular measurements.
- brubell
- Learn User Page
- Posts: 2017
- Joined: Fri Jul 17, 2015 10:33 pm
Re: How long will IO stay connected?
Yep - that is a variable for you to adjust to your specifications!
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.