DATA_FIELDS

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.
Locked
User avatar
fruito
 
Posts: 40
Joined: Thu Jul 07, 2022 11:40 pm

DATA_FIELDS

Post by fruito »

What is the meaning of DATA_FIELDS and where are they documented?

https://github.com/adafruit/Adafruit_IO ... del.py#L31

The example code always assumes the internet is there and IO is available. Well, what if it is not?

Would be nice if a microcontroller could be rebooted without losing data. (assuming time is known)

My current code takes care of intermittent internet to some degree, but it would be nice if we could have official examples.

Code: Select all

batch.append(Data(value=med, created_at=time.asctime(time.gmtime())))
try:
    aio.send_batch_data(temp.key, batch)
    batch = []
except requests.exceptions.ConnectionError:
    pass
What is the maximum size of the batch? When should the data be split in chunks?

User avatar
adafruit_support_mike
 
Posts: 67391
Joined: Thu Feb 11, 2010 2:51 pm

Re: DATA_FIELDS

Post by adafruit_support_mike »

fruito wrote:What is the meaning of DATA_FIELDS and where are they documented?
Those are names of fields that can exist in a 'data' object sent to or received from the Adafruit.io server. You can find descriptions of them here:

https://io.adafruit.com/api/docs/#data
fruito wrote:The example code always assumes the internet is there and IO is available. Well, what if it is not?
Then you shouldn't be trying to run such code.

Broadly speaking, your code should check for a working network connection long before it tries to execute any code that needs such a connection to function. If you want to capture data while there's no internet connection, you'll need to write it to some other kind of storage like an SD card, then upload data on the card to Adafruit.io when the board gets its next working internet connection.
fruito wrote:Would be nice if a microcontroller could be rebooted without losing data. (assuming time is known)
That would require a layer of hardware memory management that doesn't exist in microcontrollers. You could build your own approximation by writing all data to FRAM or something, but it still wouldn't be robust against random crashes.
fruito wrote:What is the maximum size of the batch? When should the data be split in chunks?
The function .send_batch_data() is a front-end for an HTTP request, so there's no hard technical limit. In practice you'll run into the 60-updates-per-minute rater limiting or 1000-data-points pagination limit first:

https://io.adafruit.com/api/docs/#rate-limiting

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”