Hi ScruffR, hmm… could it be the stack has a limit to store subscribed variables ? If so, then instead of using so many subscribe handlers I will try to combine them into a single subscribe then… as what you did with your code, you stored temp and press into enum… it does seem complicated for me since it is my first time seeing enum being used.
I will try to understand the enum part before applying it to my code…
Update, I think ill combine temp and press publish into one function and publish them!
- Getting overflow on device 2 which publishes these by calling timer to set interval
Timer timer1(5000, env_data);
Update 2: Even after an hour of reading, I dont understand anything about comparing str event in order to combine multiple publish as one, or subscribing to a single event handler that holds all 3 data, and comparing str event .
Tutorial: Webhooks and Responses with Parsing (JSON, Mustache, Tokens)
Is there a limit to how many variables I can particle.subscribe to? - #4 by BulldogLowell
Particle.publish variable
Update 3 - I finally understand the webhook example!
Sub “D8”
Pub “D8_Door/D8_temp/D8_press”!
Because particle sub handlers will foo - food, foo, fool, foodprata, as long as the subscribed event name contains the specified name. Now my im able to use
void d8_handler(const char event, const char data)
if(strstr(event,“temperature”){
log.trace("%s, %s",event,data)
}
Update 4 - I can get the data now… I’ve observed that i have string data ! I converted them to float for temp and press vals, and to char str. I also used (!strcmp(event, “D8_temp”)) instead of
(strstr(event, "temp)) !
void env_data(){
temp = bmp.readTemperature();
press = bmp.readPressure();
char envdata[128];
snprintf(envdata, sizeof(envdata), "%.2f~%.2f", temp, press);
Particle.publish("D8_data", envdata, PRIVATE);
}