Third-Party Sensor Data in DT Cloud
Last updated
Was this helpful?
Last updated
Was this helpful?
When using Disruptive Technologies sensors, your data is continuously captured and forwarded by a Cloud Connector to the DT Cloud where it is stored for 31 days. While our current already covers many use cases, some sensor types, like barometric pressure, are yet not in our repertoire. However, while we continue to expand our offerings, a method of including third-party sensor data into our cloud does exist.
In this application note, we will take a look at how a can be used to sample barometric pressure data from a breakout board, then periodically publish events to the DT Cloud using our Python . This lets the third-party pressure data propagate our cloud just like any first-party sensor, allowing you to effortlessly expand your integrations.
Navigate to the DT Studio project into which to forward your third-party sensor data.
Make sure you have a Service Account with a role of Project Developer or higher that is granted membership in the project.
Take note of both the sensor- and project IDs as these will be used for publishing the events.
This application note uses a Raspberry Pi with an Environment Click breakout board, but the implementation would be the same for any other platform. However, the GPIO pins and Python environment makes the Pi a good choice for quick and easy prototyping.
We'll be using the I2C communication protocol to exchange information between the Pi and Environment Click breakout board. By default, this is disabled on the Pi, but can be enabled through the shell.
sudo raspi-config
-> Interface Options > I2C > Enable
Install the Disruptive Python API package with pip3 install disruptive
.
The Environment Click requires no configuration other than connecting it to the Pi.
As we're using I2C, connect the SDA and SCL pins between both devices.
Power the breakout board using the Pi 3V3 and GND pins.
Once you have a working Python 3 environment and the breakout board is connected, the sensor can be sampled by the Pi, then published as an event to the DT Cloud. The following snippet does exactly this.
Initialize an instance of the bme680 sensor which the Pi will sample every 1 second.
For each new pressure sample, append a buffer list for storage between publishing events.
Once every 60 seconds, publish the median pressure value to an emulated device.
Remember to replace variables on the form <VARIABLE>
with your own details.
Again, our cloud thinks the data is from a temperature sensor, but this is only a visual side-effect. If you choose to interact with- or forward the data it is, of course, unaffected.
Now that your third-party sensor data is in our cloud, all services that are available to our first-party devices can be utilized. Here are a few examples of what you can do with your data.
Development Platform A or any other development board that can connect to our REST API. It is assumed that you are at least familiar with your platform of choice.
Third-Party Sensor An or any other third-party sensor that can be sampled by your platform.
Service Account Creating, deleting, and interacting with emulated devices require that your User or has been granted the role of Project Developer or higher.
Only minimal setup is required to recreate the steps in this application note.
For each third-party sensor data stream, you wish to forward, . We will use the Temperature Sensor type as a proxy to our data, even though we sample pressure data.
It is assumed that your Pi is set up with the latest version of and has a working internet connection. If you're unfamiliar with this process, you should read the .
We'll use the to publish emulated sensor events with only a few lines of code. Therefore, a working Python 3 environment must be configured.
Install Python 3.7 or greater, either through the use of or the official repository with sudo apt install python3 python3-pip
.
Additionally, install any device driver packages to interact with your sensor. For our Environment Click board which hosts the sensor, has a readily available package we can use pip3 install adafruit-circuitpython-bme680
.
Authenticate the package using your Service Account credentials.
You probably notice that we use the to publish our data. This is because a pressure event type does not exist, and since the data type is simply a floating-point number, it does not matter.
Once your script is running on your Raspberry Pi, head over to . Here you should see the sensor data updating at each publishing interval. Using the Dashboard, a card can be created to inspect how your data behaves over time.