Search code examples
apicloudxbeezigbee

Communication between XBee Sensors, ConnectPort X4H and Digi Cloud


We are a Startup building remote construction monitoring platform for the construction industry. We are great at web development (web apps, web APIs, data visualization) however have 0 knowledge about RF low level engineering and programming.

What is more it is extremely hard to find any XBee developer in our area. To make it possible and deliver MVP we decided to purchase ready-to-use sets and Digi Cloud, therefore we got:

What we already know:

  • We discovered ConnectPort with visible ZigBee network in Digi Cloud, yes it is visible and can be configured online.
  • We know that ConnectPort has built in Python engine however only 2.4.3 Python version is supported.
  • We know that we can upload Python files directly to ConnectPort using Digi ESP for Python
  • We know that we can upload Python files to ConnectPort using Digi Cloud
  • We know that Sensors can sent data into Data Streams that will expire after some time
  • We know that we can use Monitor API to forward data into our own external web service each time it will be uploaded into Data Stream

What we want to achieve and have questions:

Scenario 1 (simple):

In this scenario we want to specify all settings and sampling using Digi Cloud online interface.

  • Create data streams using Digi Cloud Interface
    • As each XBee Sensors has 1 temperature, 1 humidity and 1 light sensor, we want to specify 3 Data Streams for each XBee Sensor. Having total 4 x 3 Data Streams.
    • Each Data Stream besides data value should have additional properties like: NodeId (Id of XBee Sensor), SensorTypeId (Id from dictionary of types), SamplingFrequency (value in milliseconds, 0 = real time) DateStart (date from what point should collect data), DateEnd (date after no data should be collected), MeasurementZoneId(Id of measurement zone specified by user, e.g. Floor 1), PlacementVector (x, y, z location inside construction)
  • Somehow link each data stream with each sensor inside XBee Sensors and “Enable Sampling”
  • Watch data changes online in Digi Cloud

Questions:

  1. Is it possible to extend data stream metadata with above properties?
  2. Is it possible to define one data stream per one sensor inside one XBee Sensor?
  3. Is it possible to define sampling frequency and enable sampling from Digi Cloud interface without writing Python code for ConnectPort (without the need for timer of infinity loop)?
  4. If python code is not necessary to enable sampling and data sending, how to do that?
  5. If python code is mandatory, does it mean that each time we want to assign XBee Sensors to different measurement zone we need to upload new Python file into ConnectPort?

Scenario 2 (extended):

In this scenario we want to configure devices and sampling from our own external API and use Digi Cloud as a middle man for configuration and data forwarding.

  • While having the same parameters, create data streams using Digi Cloud API from eternal web service (it will be .NET web service, written in C#)
  • While having the same parameters, create Data Forwarding to external web service (it will be .NET web service, written in C#) using Monitor API, each time new data will be uploaded to Digi Cloud
  • While having the same parameters somehow link each data stream with each sensor inside XBee Sensors and “Enable Sampling” using Digi Cloud API from eternal web service (it will be .NET web service, written in C#)
  • Receive data in eternal web service without the need of manual queries

Questions:

  1. Is it possible to extend data stream metadata with mentioned properties using Digi Cloud API from external web service?
  2. Is it possible to define one data stream per one sensor inside one XBee Sensor using Digi Cloud API from external web service?
  3. Is it possible to define sampling frequency and enable sampling using Digi Cloud API from external web service, without writing Python code for ConnectPort (without the need for timer of infinity loop)?
  4. If python code is not necessary to enable sampling and data sending, how to do that?
  5. If python code is mandatory, does it mean that each time we want to assign XBee Sensors to different measurement zone we need to generate and upload using Digi Cloud API new Python file into ConnectPort?

We will appreciate any help with above described scenarios.


Solution

  • It'll be hard to address everything specifically in your post given the breadth of it and the details required to give an accurate answer, but here's an attempt:

    Scenario 1:

    You have a couple options. You can write a custom python script that runs on the gateway since there are APIs for interacting with XBee nodes and for sending data points up to Device Cloud structured however you want. This gives you a lot of control without the overhead of a framework, but you might find you have to dig into a number of details to figure out how to accomplish each task.

    Alternatively, take a look at the DIA Python framework that can run on the Gateway (http://www.digi.com/support/productdetail?pid=3632&type=drivers). This framework attempts to abstract devices and reporting of data so that you can accomplish a lot primarily through configuration without having to write any code. I might recommend you at least get started with this and try it out and if you find it too burdensome to customize at least you have a starting point to look at.

    1. The device side API allows supplying a description along with each data point that is uploaded. While there is no inherent support for many of the things you listed, you could come up with a convention to include this information in the description field (such as formatting the description as json). There is no way to adjust reporting automatically on the server side and have it reflecting automatically on the device side. Device Cloud does have APIs that let you send messages to the device...so you could pass through reporting changes using that API.

    2. Yes, using Python and the data upload APIs you can layout your streams however you want. It definitely makes sense to have one stream for each unique source of data and would be the default way something like the DIA would lay the streams out.

    3. It may be possible with the DIA. I believe the XBee sensors can be configured to send IO samples on a periodic basis and then DIA would upload those to the server. You could then adjust the settings on the XBee nodes with regard to their IO sampling rate to have things change. This won't be extremely simple however.

    4. As mentioned, try out the DIA to see if it meets your needs. It can take some configuration and build a bundle of python code that runs on the Gateway without requiring you to write any python.

    5. You can send messages to your python code through APIs in Device Cloud. So, you could definitely implement it so there is some configuration file on your device that tracks the measurement zone for each device and then support receiving a message from Device Cloud to update and save the new measurement zone configuration. You won't be able to integrate this into the UI of Device Cloud itself, but you could execute the required API using the API Explorer in Device Cloud.

    Scenario 2

    1. You can get a list of all the streams and data points using APIs in Device Cloud. You can also create new data points or do things like edit the descriptions for the streams or data points.

    2. You can create data streams and lay them out however you want with the APIs in Device Cloud (see /ws/DataStream and /ws/DataPoint or their newer variant /ws/v1/streams)

    3. Assuming the solution to #3 in scenario one works, you can adjust the IO sampling frequency of the end XBee nodes using web service APIs in Device Cloud.

    4. Try out the DIA framework and see if it meets your needs.

    5. Same as before since it was using an API.