Open Weather411 opened 3 years ago
I've been having this issue on an ESP32-S3, but I found a workable hack/potential fix. It looks like the crashes are being caused by too small of a buffer being allocated in the save() function of AdafruitIO_Group.cpp, Line 206:
char csv[150];
I changed the buffer size to 1024 bytes and it stopped the crashes/resets, but still only the first 6 feeds of the group were being updated. It looks like this truncation was due to the value similarly defined in Adafruit_MQTT.h, Line 110:
`
`
After changing both of these to 1024, I can send 9 values without issue. I'd guess these were both created with single feed values in mind rather than group transactions, but I might be missing something in the MQTT protocol. I'm not sure if this is a really fix or if it could cause issues with applications that assume/depend on a limited packet size. My IO account overview isn't showing any errors, so that side of things appears to be OK with this (as expected given the prescribed 1kb limit per "value" in the docs).
Relevant snippets of my now working code for reference:
AdafruitIO_Group *aq_group = io.group("air-quality");
...connect, get data...
aq_group->set("battery", battPer);
aq_group->set("temperature", ambientTemperature);
aq_group->set("rh", ambientHumidity);
aq_group->set("pm-1-dot-0", massConcentrationPm1p0);
aq_group->set("pm-2-dot-5", massConcentrationPm2p5);
aq_group->set("pm-4-dot-0", massConcentrationPm4p0);
aq_group->set("pm-10-dot-0", massConcentrationPm10p0);
aq_group->set("vocs", vocIndex);
aq_group->set("nox", noxIndex);
aq_group->save();
io.run();
It's been such a long time since I wrote this, I had given up hope that Adafruit (or anyone else) would ever address and/or fix. I have since figured out other methods (using URL concatenation with api calls) but it's good to know that there is this workaround within this library. Thanks for taking the time to write your solution, Andrew. Cheers!
--- PREVIOUSLY STATED ISSUE ON ADAFRUIT FORUM: https://forums.adafruit.com/viewtopic.php?f=56&t=172069 --- --- ADMIN REQUESTED THIS ISSUE BE POSTED HERE ---
Scoured the forum and I don't see this issue previously addressed. I've tried the same code on ESP8266 and ESP32, both show board stack errors/board resets in the Serial Monitor when I write data to more than 7 feeds to 1 group at one time. When I write data to 6 feeds (or less) to 1 group at one time, there are no stack errors/board resets. Was a weather station with many variables coming back, now simplified program to random number generator to troubleshoot.
Adafruit IO Arduino v4.0.1 ESP8266 Board v2.7.4 ESP32 Board v1.0.4
Code:
This program makes it easy to troubleshoot since I just have to comment/uncomment a few lines to add or decrease number of feeds writing to the one group ("Test_1").
When I decode my stack error, I get this:
I really want to be able to code more than 7 feeds to one group at once. I did test another version of this program where feed data is split amongst multiple groups, and in that case, I can send more than 7 feeds (just not ideal for my needs). This will significantly impact how I'm going to code my next project so any and all help is greatly appreciated - thanks in advance!