Once you have data flowing into Notehub from your Sparrow hardware, you’ll likely want to send that data to other cloud applications or services.
One powerful feature of Notehub is routes, which allow you to forward your data from Notehub to a public cloud like AWS, Azure, or Google Cloud, a messaging platform like MQTT, or a custom HTTP/HTTPS endpoint.
For the most part Sparrow projects work like any other Notehub-based project. As such, you can refer to the following Notehub resources for more information on routing data.
A list of the the available route types and how to use them.
A step-by-step tutorial to routing Notehub data to a variety of popular services, such as Azure and AWS, as well as routing to general HTTP/HTTPS endpoints.
However, there are a few routing considerations that are unique to Sparrow projects. In this article we’ll look at how to differentiate between multiple Sparrow nodes in routes, and how to use the Sparrow Reference Web Application to view and manage your data.
Distinguishing Between Nodes
In most Notehub-based apps the main identifier you care about is the DeviceUID, which uniquely identifies the Notecard that is sending data. In Sparrow apps, however, you usually are more interested in knowing which Node data originated from.
Each Sparrow Node also has a unique identifier, and by convention it appears in the file
field of each of your project’s *.qo
events. For example, the air.qo
event below originated from a Node with an id of 2037335832365003004e001d
.
You can derive this identifier in your route’s end destination, however, if you want this identifier to appear as a top-level property in your JSON, you can also use JSONata to pull the identifier out of the file
field.
To do so, create a new route in Notehub and scroll down to the Data section. In this section, set Transform Data to JSONata Expression, and paste in the code below.
$merge([$, { "node": $substringBefore(file, "#") }])
Now, Notehub will apply this new JSONata expression before routing your data, and add a new node
field that contains your node’s identifier. You can see an example of how this works in the JSONata Exerciser below.
Sparrow Reference Web App
The Sparrow Reference Web App is a project for jump-starting professional Sparrow solutions, by providing a customizable dashboard for viewing and updating your Sparrow data.
The Sparrow Reference Web App allows you to:
Easily start a Sparrow-based web application.
Route your data from Notehub, and store it in a Postgres database.
View, and manage your data on an interactive web dashboard.
Host your web app and database on a number of popular hosting platforms.
If you’re curious what the app looks like in action, check out the official Blues demo to see live sensor data from around the United States. And when you’re ready, check out the project’s README on GitHub for more information on how to get up and running with your own data.