Oracle IoT – Working with Sigfox/Thinxtra Devices

How to use the Thinxtra devices and Sigfox network with the Oracle IoT cloud service.

Introduction

There are lots of activities happening today in the world of IoT (Internet of Things).  The market is growing at a staggering pace.  Oracle, of course, is providing services in this area, mainly to support our many great SaaS applications.  Almost every application can benefit from data coming from devices on machines, automobiles, medical devices, human wearables and such.  However, there are several issues people face:

  • How to work with all the various devices.
  • How to manage the devices and information.
  • How to integrate these with other systems in the enterprise.
  • Deployment of devices, configuration, maintenance, versions, upgrades, Etc.

Oracle IoT Cloud service is designed to help with these issues, but it is often overwhelming to get a given device’s data initially into the IoT cloud.  Case and point is with the wonderful devices from Thinxtra which uses the Sigfox network.

Thinxtra is the operator of Sigfox in the Australian, New Zealand and Hong Kong areas.  They focus on IoT devices specifically with requirements such as:

  • Small message payloads
  • Small message rates
  • Long battery life
  • Inexpensive unit costs
  • Easy setup
  • Global network (no Wifi/4g requirements)

This accounts for most IoT scenarios.  Their list of devices and solutions is pretty amazing: https://www.thinxtra.com/solutions/.

I was disappointed to learn how they didn’t have a well-documented solution to use their devices in the Oracle IoT cloud, so I set out to fix it!

Demo Video

All the details are in the text below, but if you just want a video demo, here it is:

Thinxtra XKit – Device

The first device I looked at was the Thinxtra XKit.  This is a development kit to test things and get ideas on how to use the other devices.

Following their basic developer’s guide, I installed the sample Arduino demonstration code from github on the device.  This code is quite simple and sends sensor data up to the Sigfox cloud periodically or when you press the on-board button.  Once the data was flowing into Sigfox, I needed a way to send the data into the Oracle IoT cloud.

Oralce IoT Setup

The first thing I needed to do was to create a device type in the Oracle IoT cloud.  This can be done manually, but I love using simple REST calls when possible.
curl -X POST -u : -H ‘Content-Type: application/json’ -d ‘@deviceXkit.json’ http:///iot/api/v2/deviceModels/

The deviceXkit.json contains all the message types; which I built using the developer’s guide.  This file and all the code I’ve written can be found on github:
https://github.com/gravesjohnr/Sigfox-Thinxtra-Oracle-IoT-Bridge

After running this curl script, the device type shows up in Oracle IoT cloud.

Selection_735.jpg

This deals with the device type, but not each instance of the XKit.  I decided to simplify this whole process by writing a bit of code to automatically register and activate devices the first time it sends data.  This makes it very easy to set up new devices.

To follow along with where I am on the journey, let me show you a diagram created by my friend and colleague Stuart Coggins.

diagram

Steps 1 & 2 are done.  The steps 3 and 6 will happen automatically based on my code.  So now, I need to set up a callback in Sigfox to send data to the IoT cloud service.  This requires a little bit of code to manage some data manipulation and security and device management in the Oracle IoT cloud.  I could have done this in any number of ways, but I found it easiest to write a little NodeJS code and deploy it into the Oracle Application Container Cloud Service (ACCS).  This is a very easy way to get a bit of code running in a production quality environment with almost no effort.  I put the code in github, linked this to my instance of Oracle Development Cloud Service and created some simple build and deploy into ACCS.  Wow, full continuous development and integration in about an hour!

Selection_736.jpg

Again, the code is simple and can be found here:
https://github.com/gravesjohnr/Sigfox-Thinxtra-Oracle-IoT-Bridge/blob/master/xkitbridge.js

In this code I do some simple data manipulation based on the developer’s guide and use the javascript libraries to send the data to Oracle IoT cloud.  It also registers and activates the device if it doesn’t already exist.

Sigfox Callbacks

Based on the diagram above, only one more step is needed, step 8, configuring the callback.  This is done in the Sigfox portal and is configured for a given device type.Selection_737.jpg

The callback configuration requires three key elements:

  1. Callback URL
  2. Custom payload config
  3. Content body

The URL, in my case, was the ACCS instance running:

Selection_738.jpg

The custom payload config was pretty easy to setup based on the developer’s guide:

temperature::uint:16:little-endian pressure::uint:16:little-endian photo::uint:16:little-endian x_acc::int:16:little-endian y_acc::int:16:little-endian z_acc::int:16:little-endian

And the payload is just simple json code to be sent to the ACCS instance; which then forwards the data on to the Oracle IoT cloud.

{
"time" : "{time}",
"device" : "{device}",
"duplicate": "{duplicate}",
"snr": "{snr}",
"rssi":"{rssi}",
"avgSnr":"{avgSnr}",
"station":"{station}",
"lat":"{lat}",
"lon":"{lng}",
"seqNumber":"{seqNumber}",
"temperature" : "{customData#temperature}",
"pressure" : "{customData#pressure}",
"photo" : "{customData#photo}",
"x_accelerator" : "{customData#x_acc}",
"y_accelerator" : "{customData#y_acc}",
"z_accelerator" : "{customData#z_acc}"
}

Here is a screenshot:

Selection_739.jpg

That’s it…. data now flows wonderfully.

Selection_740.jpg

Thinxtra Oyster

The next device I wanted to integrate was the Oyster.

This is a very nice little GPS tracker.  It was funny, when the wonderful guys at Thinxtra sent this to me via Aus Post, I was able to track it using their assets online portal.

Selection_741.jpg

I followed the same steps and generalised the NodeJS code to handle both devices.  This was very easy and all the code is included on github.

Next Steps

There are several directions I’d like to see this take:

  • More work between Oracle and Thinxtra.
  • Oracle IoT cloud as a well-defined solution for Thinxtra and other Sigfox providers.
  • Enhance the Oracle IoT code to utilise our new IoT Apps capabilities including fleet management and asset management.  This would be perfect for that scenario.

Conclusions

Thanks again to the wonderful people at Thinxtra, especially Guy Langlois, for giving me the opportunity to get this working.  The devices I’ve used and seen have been of the highest quality and I believe they will have much success in this market.

After configuring several devices, including the Anki Car Demo, into the Oracle IoT cloud service, I’m finding it very easy to do so.  This entire exercise took about three days to implement.  It is important for companies to come up with a good IoT device management strategy which works well with existing systems and built on enterprise solutions.  I believe the Oracle IoT cloud service has a bright future.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s