Direct connection from Windows to SensorTag without Cloud or smartphone

Standard connection to SensorTag

The SensorTag from Texas Instruments is a great piece of hardware for evaluating the CC2650 microcontroller or… just for fun ! It comes with a lot of sensors (IR temperature, barometric, humidity, ligh, movement,…) you can read using your favorite radio interface. In this article, I will use the BLE (Bluetooth Low Energy) interface.

It also comes with Apps (for Android or iOS) so that you can look at its data on the tiny screen of your smartphone. And of course, since we live in a world where the desktop computer tends more and more to be considered as a prehistoric object, (almost) nothing exists if you want to explore the SensorTag data on the big screen of your computer.

I write « almost nothing » because you can do the following:

  • connect to the SensorTag with your smartphone
  • ask the App to send the data to the Cloud
  • from your computer, get the data from the Cloud

It is explained here more in details.

Simple, isn’t it ? You have 2 objects (the SensorTag and a computer) in your house and to make one communicate with the other one you need a third object (your smartphone) and you need to send your data around the world before getting them displayed less than 10 meters from where they are collected !

 

Is there a better solution ?

Fortunately, some companies and people have made a great job in order to make possible a direct connection between a Windows computer and a SensorTag.

The first thing you will need is a BLED112 dongle, from Bluegiga. It is a BLE dongle with a virtual serial port. You can use it on any computer (Windows, Linux, Mac).

The BLED112 can be controlled through a API (BGAPI) which has implementations in various languages, thanks to Jeff Rowberg (https://github.com/jrowberg/bglib).

Jeff and other people also worked (and obviously are still working) on PyGATT, a Python wrapper on gattool (used on Linux) and BGAPI. The origin of PyGATT is explained here.

We have now all what we need: a Windows PC, a bluetooth dongle, a Python library and the SensorTag documentation. Let’s code a demo !

 

Demo

I created a simple dashboard in order to display the data collected from the SensorTag. Using PyGATT is extremely easy, I just added in my Python program a Tornado Websocket server in order to communicate between this program and the browser-based dashboard.

What you can see on the video is the result of the SensorTag took from rest, put under a light during a few seconds and put back to rest. Sorry, I have no simple mean to make changes in the barometric pressure 😉
The data collection is updated every seconds, but you can change it easily on the SensorTag.

 

A tutorial ? Some code ?

Yes, it is coming soon, please be patient. As you probably know, making something clean and shareable takes far more time than making this kind of prototype.

Stay tuned ! Updates will be sent via my Twitter account.

 

Next step(s)

Another thing that may be useful is to communicate between a microcontroller and the SensorTag in order to control hardware stuff (relays, motor, …) based on temperature, light,…

It is possible with the use of another product from Bluegiga, the BLE113. If soldering this kind of module is not your cup of tea, you can buy a breakout board there: http://www.jetney.com/breakouts/bluetooth-smart/ble113

You can then connect this breakout board to, let say, an Arduino (through their respective serial interface) and use the Arduino implementation of BGLib for the software part.

So, the next step is to write a SensorTag library based on BGLib. I started to do it and it should be finished soon.

And after, maybe, I will write a C library based on BGLib.