Routing Data to Cloud: Qubitro
Watch a video of this tutorial
In previous tutorials you've learned about the Blues Notecard, and used it to collect data and send it to Notehub, the Blues cloud service.
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, to a data cloud like Snowflake, to dashboarding services like Datacake or Ubidots, or to a custom HTTP or MQTT-based endpoint. The tutorial below guides you through sending data to several popular services, and teaches you how to build visualizations using that data.
Don't see a cloud or backend that you need? Notehub is able to route data to virtually any provider. If you're having trouble setting up a route, reach out in our forum and we will help you out.
Introduction
This tutorial should take approximately 30-40 minutes to complete.
In this tutorial, you'll learn how to connect your Notecard-powered app to Qubitro, and learn how to start creating simple visualizations with sensor data.
This tutorial assumes you've already completed the initial
Sensor Tutorial to capture
sensor data, saved it in a Notefile called
sensors.qo
, and sent that data through the Notecard to Notehub (or that
you've already created your own app with sensor data and are ready to connect
your app to external services).
Create a Route
A Route is an external API, or server location, where Notes can be forwarded upon receipt.
Routes are defined in Notehub for a Project and can target Notes from one or more Fleets or all Devices. A Project can have multiple routes defined and active at any one time.
Before you create a Route, ensure the data you want to route is available in Notehub by navigating to the Events view.
We'll start with a simple route that will pass Notecard events through to webhook.site, where you can view the full payload sent by Notehub. Using this service is a useful way to debug routes, add a simple health-check endpoint to your app, and familiarize yourself with Notehub's Routing capabilities.
-
Navigate to webhook.site. When the page loads, you'll be presented with a unique URL that you can use as a Route destination. Copy that URL for the next step.
-
Navigate to the Notehub.io project for which you want to create a route and click on the Routes menu item in the left nav.
-
Click Create Route.
-
Select the General HTTP/HTTPS Request/Response route type.
-
Give the route a name (for example, "Health").
-
For the Route URL, use the unique URL you obtained from webhook.site.
-
In the Notefiles dropdown, choose Select Notefiles and enter the name of the Notefile to monitor. For example, we used
sensors.qo
for the sensor tutorial. -
Make sure the Enabled switch remains selected, and click Create Route.
-
Return to webhook.site. This page will update automatically with data from your Notecard as it is received in Notehub. The data from your sensor is contained within the
body
attribute. Notice that Notehub provides you with a lot of information, by default. In the next section, we'll look at using transformations to customize what Notehub sends in a Route.
Use JSONata to Transform JSON
Before moving on to routing data to another external service, let's briefly explore using JSONata to transform the data Notehub routes.
As mentioned above, Notehub provides a lot of information in each Route request. You may want to trim down what you send to the external service, or you might need to transform the payload to adhere to a format expected by that service. Either way, Notehub supports shaping the data sent to a Route using JSONata.
More About JSONata
To learn more about JSONata, have a look at the Blues JSONata Guide.
Transform Your Data
Let's try a simple query to the webhook.site route created in the last section.
-
Navigate to the Routes page in Notehub and click View next to the Route you wish to edit.
-
In the Transform JSON drop-down, select JSONata Expression.
-
In the JSONata expression text area, add the following query to select the temp and humidity from the body, create a location field that concatenates the
tower_location
andtower_country
fields, and create a time field.{ "temp": body.temp, "humidity": body.humidity, "location": tower_location & ', ' & tower_country, "time": when }
-
Click Save Route. Then, navigate back to your webhook.site url. As requests come in, you'll see your custom, JSONata-transformed payload in the Raw Content section.
JSONata is simple, powerful, and flexible, and will come in handy as you create Routes for your external services. To explore JSONata further, visit our JSON Fundamentals guide.
Route to an External Service
Now that you've created your first Route and learned how to use JSONata to shape the data sent by a Route, you'll connect Notehub to an external service.
In this section of the tutorial, you'll connect your app to Qubitro, a no-code/low-code device data platform that enables companies of any size to instantly connect, manage, process, and analyze IoT device data.
Create a Qubitro Account
If you haven't already, create your free Qubitro account. The default (free) tier allows you to add two devices (e.g. Notecards).
Create a New Qubitro Project
After logging in, you'll be redirected to your personal dashboard. From here, you'll be able to add and edit projects, manage devices, update settings, and create dynamic data dashboards.
Let's start by creating a new project!
-
Click the New Project button.
-
Provide a name for the project, along with at least one identifying tag, and a short description of the project.
-
After the project is created, click to open it, and click the New Source button.
-
Click the Notehub tile. On this screen, you'll be provided with unique identifiers for your project which you'll use to configure your Notehub Route. Leave this tab open for now.
The next step is to create a Route in Notehub to securely transmit new events to this Qubitro project.
Create a Route in Notehub
-
Back in Notehub, navigate to the Routes menu option and click the Create Route button.
-
Scroll until you see the Qubitro route type and click the Select button.
-
Provide a name for your route. Then, back in your Qubitro project, copy the provided
projectId
andwebhookSigningKey
values. Paste them in the relevant fields provided in your Notehub Route settings. -
Under the Filters section, choose to only sync the
sensors.qo
Notefile, and select Body Only from the Transform Data dropdown. You can certainly experiment with other transformations (like JSONata expressions) after completing this tutorial. -
When you're done configuring your Notehub Route, click the Apply Changes button to save the Route.
View Sensor Data in Qubitro
-
Back in Qubitro, click the Go to project button to return to your project dashboard.
-
Assuming sensor data is still being sent from your Notecard to Notehub in the
sensors.qo
Notefile, you should see your Notecard device appear in Qubitro.If no devices appear in the table, add additional Notes to your
sensors.qo
Notefile on your Notecard. Sync the data with Notehub and then click the provided Refresh button in the Qubitro device table. Your device should then appear. If you still don't see any devices or data, check the Logs tab of your Notehub Route. -
Click on the device and navigate to the Storage tab. On this page you'll see all of the raw data previously routed from Notehub to Qubitro.
As new sensor readings are delivered to Notehub, they will be actively routed to your Qubitro project. Your next step is to create a data dashboard using the web-based interface provided by Qubitro.
Build Data Visualizations
-
Navigate to the Dashboard tab of your Qubitro project and click on the Go to Dashboards link.
-
From the provided dropdown menu, choose to create a new Blank dashboard.
-
Open the provided blank dashboard, click the toggle to Edit, and create your first dashboard widget by clicking the New Widget button.
-
Choose a widget type of Chart, add a title to your widget (e.g. "Temperature"), and then click the Add point button.
-
When the Connect Data Point modal opens, select your project, device (your Notecard), and the data point you would like this chart to display (e.g.
temp
). -
Click to Save the data point and then Save Widget to save changes made to your widget.
-
Repeat the above process to add another widget for your
humidity
data. -
When done adding widgets, be sure to click the Save Changes button on your dashboard BEFORE toggling back to view your dashboard. (Otherwise you may lose the changes made to your widgets!)
-
After your dashboard is saved, toggle back to the View option to see your live data visualizations.
Be sure to visit the Qubitro documentation to discover additional capabilities of the Qubitro platform.
Next Steps
Congratulations! You've created your first Route and connected your Notecard app to an external service.
If you're following the Blues Quickstart, you're done! But we do have some suggestions for next steps:
- Browse the Blues Example Apps to find open-source example applications, code snippets, and best practices.
- Bookmark the Notecard API for quick reference.
- Follow the Notehub Walkthrough to get more out of using Notehub.
At any time, if you find yourself stuck, please reach out on the community forum.