# Multiple Routes / Device

**URL:** https://discuss.blues.com/t/multiple-routes-device/1941
**Category:** Notehub.io
**Created:** [February 9, 2024, 12:28am UTC](https://discuss.blues.com/t/multiple-routes-device/1941 "2024-02-09T00:28:15Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![drewcssv](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@drewcssv](https://discuss.blues.com/u/drewcssv)
#### Post date: [February 9, 2024, 12:28am UTC](https://discuss.blues.com/t/multiple-routes-device/1941/1 "2024-02-09T00:28:16Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)
#### Post date: [February 9, 2024, 2:28pm UTC](https://discuss.blues.com/t/multiple-routes-device/1941/2 "2024-02-09T14:28:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![drewcssv](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@drewcssv](https://discuss.blues.com/u/drewcssv)
#### Post date: [February 17, 2024, 4:26am UTC](https://discuss.blues.com/t/multiple-routes-device/1941/3 "2024-02-17T04:26:56Z")

</div>

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…):

```auto
 // 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:

```auto
{
   "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:

```auto
{
    "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!

---

<div class="post-metadata">

### Author: ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)
#### Post date: [February 18, 2024, 1:36am UTC](https://discuss.blues.com/t/multiple-routes-device/1941/4 "2024-02-18T01:36:12Z")

</div>

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:

![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/2X/8/81a937806c8ffe4aeef256499cf100980464dfd0.png)

Routes are executed as soon as matching Notes appear in Notehub.

Rob

---

<div class="post-metadata">

### Author: ![drewcssv](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@drewcssv](https://discuss.blues.com/u/drewcssv)
#### Post date: [February 18, 2024, 2:19am UTC](https://discuss.blues.com/t/multiple-routes-device/1941/5 "2024-02-18T02:19:51Z")

</div>

Rob, here’s the log for Route 2:

 ![Screenshot 2024-02-17 at 6.14.49 PM](https://us1.discourse-cdn.com/flex020/uploads/blues/original/2X/f/f588d40a70c86ee44f32a49e92d53be1183e200d.png)

…and here’s the log for Route 1:

 ![Screenshot 2024-02-17 at 6.16.21 PM](https://us1.discourse-cdn.com/flex020/uploads/blues/original/2X/e/eca939624f4bebb9eb4ac486e2a92840c512e990.png)

Under EVENTS the green diamond tells me “All Routes Successful”:

 ![Screenshot 2024-02-17 at 6.18.54 PM](https://us1.discourse-cdn.com/flex020/uploads/blues/original/2X/6/67ef7e8391566d117cdac56802b9fee7602f0b4c.png)

Is there another diagnostic I can look at to see what’s going on?

Drew

---

<div class="post-metadata">

### Author: ![noforan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/noforan/32/618_2.png) [@noforan](https://discuss.blues.com/u/noforan)
#### Post date: [January 4, 2025, 3:45pm UTC](https://discuss.blues.com/t/multiple-routes-device/1941/6 "2025-01-04T15:45:34Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![drewcssv](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@drewcssv](https://discuss.blues.com/u/drewcssv)
#### Post date: [January 4, 2025, 4:34pm UTC](https://discuss.blues.com/t/multiple-routes-device/1941/7 "2025-01-04T16:34:01Z")

</div>

@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.

---

<div class="post-metadata">

### Author: ![noforan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/noforan/32/618_2.png) [@noforan](https://discuss.blues.com/u/noforan)
#### Post date: [January 5, 2025, 9:23pm UTC](https://discuss.blues.com/t/multiple-routes-device/1941/8 "2025-01-05T21:23:33Z")

</div>

@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!!
