Hi Rob, quick questions about multiple routes for a single device. I have a simple demo app that is using 2 routes, one for each Thingspeak channel that are used to store data collected by the firmware running on the device and uploaded via Notecard. The first route I defined continues to work as expected, but I don’t see the 2nd, newer route being fired (the “Log” tab shows no route events.) Is there something I need to do in the host firmware to identify or otherwise kickoff the execution of this second route, or is this done automagically? In other words, how does Notecard/Notehub know about the route(s) and are they executed sequentially (in which order?) or some other way? Is there a limit on how many routes I can fire/device? Thanks!
Hi @drewcssv,
The routes are fired automatically, so as long as the route itself is enabled and the Note matches parameters specified in the “filters” section, it should absolutely work just like the other one.
Rob
Rob, makes sense, but not what’s apparently happening. The note.add in my firmware loads values into the body, and the first route is executed (at some point…not clear when routes are executed or what exactly triggers them…the sync request?) But the second route - very similar to the first except for some different values - doesn’t fire. Here is the code that loads the values into body. Note that all of the values I wish to route are loaded here, some for Route 1, others for Route 2 (I am assuming this is OK…):
// send data to cloud
J *req = notecard.newRequest("note.add");
if (req != NULL) {
JAddBoolToObject(req, "sync", true);
JAddStringToObject(req, "file", "env.qo");
J *body = JCreateObject();
if (body != NULL) {
JAddNumberToObject(body, "temperature", senTemp);
JAddNumberToObject(body, "humidity", senHumid);
JAddNumberToObject(body, "pm1", PM1_0);
JAddNumberToObject(body, "pm25", PM2_5);
JAddNumberToObject(body, "pm10", PM10_0);
JAddNumberToObject(body, "co2", co2);
JAddStringToObject(body, "comments", comments);
JAddStringToObject(body, "icon", icon);
JAddStringToObject(body, "trackname", trackName);
JAddStringToObject(body, "user", user);
JAddItemToObject(req, "body", body);
}
notecard.sendRequest(req);
}
Here is Route 1:
{
"api_key": $thingspeak_Write_Key_A,
"field1": $round(body.pm1,1),
"field2": $round(body.pm25,1),
"field3" : $round(body.pm10,1),
"field4": $round(body.temperature,1),
"field5": $round(body.humidity,1),
"field6": where_lat ? where_lat : tower_lat,
"field7": where_lon ? where_lon : tower_lon,
"field8": body.co2
}
…and here is Route 2:
{
"api_key": $thingspeak_Write_Key_C,
"field1": body.user,
"field2": where_lat ? where_lat : tower_lat,
"field3": where_lon ? where_lon : tower_lon,
"field4": $round(body.pm25,1),
"field5" : body.trackName,
"field4": body.icon,
"field7": body.co2,
"field8": body.comments
}
Anything here that might be causing Route 2 to not go? Thanks!
Hi @drewcssv,
If you navigate to the route and click the “Logs” tab, you should be able to see what’s going on (or not) with the 2nd route:
Routes are executed as soon as matching Notes appear in Notehub.
Rob
Rob, here’s the log for Route 2:
…and here’s the log for Route 1:
Under EVENTS the green diamond tells me “All Routes Successful”:
Is there another diagnostic I can look at to see what’s going on?
Drew
Happy New Year @RobLauer & @drewcssv !
I am sending data to a single ThingSpeak channel and now I would like to do exactly what Mr. Clark is attempting and send additional data from the same remote device to a different ThingSpeak channel (as each TS channel is limited to eight fields).
Was there a resolution to the problem described here - or could someone point me to some documentation that addresses this specific use case?
thanks much and cheers,
…Norm…
@noforan, I believe the issue was resolved as coding error on my part.Looking closely at the “Route 2” you can see duplicate JSONata entry for “field4”. As I recall, when I fixed this both routes fired correctly.
@drewcssv – thanks for your speedy reply! I have to admit I can’t see what’s wrong with your Route 2, except that Field 4 also appears in Route 1 (that seems like it would be allowed).
Nonetheless I have been able to successfully send additional device data to a second channel on ThingSpeak. Your route examples pointed the way. Thanks much!!