Arduino Bluetooth LE Logger for TI SensorTag (and others)

Arduino Bluetooth LE Logger for TI SensorTag (and others)

Ever since I laid my hands on a TI SensorTag, I was quite fascinated. Such a small elegant package, packed full of sensors (ambient and IR temperature, humidity, barometer, gyroscope, accelerometer, compass in the version I first got – current versions sport additional sensors), and all powered by a coin cell battery that can last a year or more!

I saw that someone had used the SensorTag to collect data from an amateur rocket launch ( You had to either fly an iPhone with the rocket, or limit the data collection to at best 300 feet of flight data (the best case range for Bluetooth LE).

There are so many different scenarios under which a SensorTag can be used to collect data

  • rocket launch data of course, but also
  • Weather data like temperature, humidity and pressure changes in your garden, in your birdhouse
  • Track your G forces in flight, if you are a pilot
  • Track data for your RC plane or copter
  • And so much more!

In all of these cases, it would be great to untether the SensorTag from your smart phone – and let it collect data even when you are not there. Thus was born the Arduino Bluetooth LE Logger for TI Sensor Tag! It connects over Bluetooth LE (BLE) in master mode to the TI Sensor Tag, and turns on notifications for the characteristics you have selected (via push buttons), and starts logging the data to a microSD card, along with the timestamp, in a Comma-separated value (CSV) format, for easy importing into spreadsheets for additional processing and graphing.

Arduino Bluetooth LE Logger for TI SensorTag (and others)

Of course, the choice of hardware (Arduino) was dictated by the fact that I started hacking with an Arduino, and wanted to see what I could achieve with it (an 8 bit microcontroller with 32k sketch size (more like 30k since the bootloader takes up 2k) and 2k ram – fitting all of the functionality of the Logger into this proved to be quite a challenge).

The Arduino Bluetooth LE Logger for TI SensorTag (and others) is a compact unit (slightly bigger than the SensorTag) that is chock full of features, for logging not only SensorTag data, but also any other Bluetooth LE device, such as a Heartrate monitor, Health Thermometer, Blood Pressure, and so on, by modifying the Arduino sketch suitably.

Ok, let’s look at the various features of the Logger!

        Arduino Bluetooth LE Logger for TI SensorTag (and others)

Microcontroller – Arduino Pro Mini 3.3v (I chose this because the form factor is very small, and the fact that it is 3.3v meant that I did not need another additional voltage regulator to handle 5v to 3.3v conversions. This also enabled me to power it via a 1 cell Lipo Battery, which provides 3.7v.

Bluetooth LE – For this, I chose Bluegiga’s BLE112. The BLE112 can be used in both master and slave modes. I needed a module that would support master mode, if I was to connect to a slave (e.g. the SensorTag) and log its data. BLE112 also supports bglib, which is ported to run on Arduino ( – Thanks Jeff Rowberg!), so I can have a full featured master MCU that can connect, discover resources, turn on notifications and process data. BLE112 also provides BGScript, a custom scripting language for on-module applications – i.e. you can run your own custom logic in the BLE112, without the need for C programming or an expensive IAR compiler license).

Real Time Clock – A data logger is incomplete without a real time clock to log the time the data was collected. For this, I chose the DS1339, because it is a) tolerant of a wide range of voltages (so I could use it with the Arduino Pro Mini 3.3v), b) battery backup to maintain the date and time, c) The presence of an alarm (2 to be precise!) (so it is possible to get timed interrupts and potentially use this for low power operation of the Arduino) d) as a bonus, it also has a trickle charger (I’m not using the alarm and trickle charge functionalities, but you could!). The Logger has a coin cell battery holder for the RTC.

MicroSD card slot – The data from the SensorTag (along with timestamp from the RTC) is logged to a microSD card. I used a push-push socket so it is easy to insert and remove. The SD card slot is also oriented such that if the Logger is placed vertically in a rocket, the high G-forces from the launch will not dislodge the SD card (since it would be oriented horizontally). Similarly, the coin-cell battery holder is also oriented horizontally. The LED13 of the Arduino Pro Mini also shows SD card activity.

I have provided 3 buttons (the image above shows 4, but Rev 5 only has 3 buttons – I’ve left Digital 3 connected to the host-wakeup pin of the BLE112 module, if you want really fancy power management, and Digital 0 and 1 for uploading sketches and serial output, so I’m out of digital ports. (I could use the A6 and A7 (analog read only) pins of the Arduino Pro Mini for some additional buttons if needed) and 8 leds that you can repurpose as you wish! Currently, the 3 buttons are used to select the data to log (temperature, humidity, barometer, accelerometer, gyroscope, compass) – each button toggles a set of two features. LED 7 is used to indicate Bluetooth LE connection status, and LED 8 is used to indicate BLE module communications.

Arduino Bluetooth LE Logger for TI SensorTag (and others)

Finally, in the rear of the board, I have a JST connector for a 3.7v LiPo battery, as well as a power switch. And to make the system fully configurable and hackable, I’ve added a CC debugger connector, so you can upload different BLE112 firmware (including your own application logic written with BGScript!).

The version of the board show in the picture has a jumper wire, but Rev 5 of the board has this problem fixed and the jumper wire is no longer necessary.

Changing the Arduino sketch to connect to any other BLE device and log data would be quite trivial, and you can hack it into something else altogether, because of the all the configurability built in.

Of course, if you don’t want to hack anything, you can use it without much ado to log your SensorTag data!

-Sridhar Rajagopal



26 thoughts on “Arduino Bluetooth LE Logger for TI SensorTag (and others)

      1. Hello! I was just wondering if we can discuss how you used the SD card with the sensor tag. I am trying to implement something similar. I want to save data onto the SD card and then send it over bluetooth.


  1. Hi Sridhar,
    Quick question: the setup with the BLE 112 would work with any similar BLE enabled tag, right? Considering I want only UUID lookups, could I use any generic BLE tag on the market in this setup?
    I’m planning to use a BLE Mini from RedBear with an Uno as the master, and a generic BLE tag for logging. Any possible issues?

    Thanks for your help!

    Liked by 1 person

    1. Hi Akash,

      Are you asking if you can replace the BLE112 with a generic BLE tag? In that case, the answer would be no. BLE112 offers bglib, which is a way by which you can do communications with any BLE slave’s GATT profile, including reading/writing.

      If you are asking if the above setup with the BLE112 can be used to read any arbitrary BLE device’s gatt profile (as opposed to reading the Sensor Tag), then yes.

      I’m not sure I understand your second question – if you are already using your BLE Mini with Arduino as master, why would you need a generic BLE tag? You can just log using the Arduino in that case.



  2. Hallo! I’m very interested in your code aswell, I’ve just gotten a RealTag (which I guess is a SensorTag knockoff), that exposes gyro and temperature via BLE GATT, and am just trying to make it log just like yours do! Please github share soon. 🙂

    Question – do you think your code would work with a HM-10 bluetooth module instead, as that is BLE capable, and if so (it doesn’t hurt to ask) would you or any other reader know of an Arduino HM-10 (CC2541-based) library that supports the GATT functions?

    Many thanks!

    Liked by 1 person

    1. Hi Henrik,

      The HM-10 module exposes a serial interface and as such is used to enable serial communication between two devices (using HM-10).

      My code is designed to work with the BLE112 and bglib, which supports master and slave mode, and the ability to read and write and query the GATT profile of any BLE device. It won’t work with a HM-10 BLE module (replacing the BLE112), but it can certainly read/write to a HM-10 module’s GATT profile.

      I had been meaning to clean up my code first before putting it up on github, but looks like due to popular demand, I’m just going to put whatever I have out there first, and then clean it up later! 🙂

      I will post an update to this blog post’s comment when I have put up my code on github! 🙂



  3. Hello Shridhar,

    Thank you for sharing your experience. Please let me know if you have your code for public. Also can you please navigate me how can I start the coding from scratch? I do have the theoretical picture, But not sure how to start coding to receive/log the data from sensortag. I am using Red bear Duo board which has both slave and master BLE mode.


    Liked by 1 person

    1. Hi Sachet,

      I will be sharing my code soon! I had wanted to clean it up first, but have not had any time. I will go ahead and put it up first, and then clean up later when I have time! 🙂

      Hopefully, that will help you get started with the coding.



    1. Hi Vidya,

      Thanks! I had not checked comments in a while, and it looks like there were many requests for the code! I had been meaning to clean it up first, but have not had the time. I guess I will first put it up on github and clean it up later!

      PS – Watch out for a comment here from me when I have finished posting to github.


      1. Thanks a lot Sridhar! I really appreciate your prompt reply and help. I am pretty sure that you have made our lives very easy already to deal with Sensor tag. All of us need some basic code examples or some steps and direction to read the data from SensorTag. No one is worried even if the code messy. You did the best thing that posted whatever you had. I will surely keep an eye on comments and also get back to you if I need more help. Thanks a lot again!

        Liked by 1 person

    1. Nice, it’ll be fun to poke around in and learn from. 🙂 I’m only just getting started with BLE and GATT, so regardless of device, it’ll be a good practical example to learn from. (There are way too much theory and too little ‘short clean examples to study’ that I’ve found.)

      Liked by 1 person

  4. Hi Sridhar,

    Great work! You think you can share a technical drawing of the circuit board? I am trying to synchronize 6 of this with just one RTC, do you have any ideas. Thanks for the code btw!


    Liked by 1 person

    1. Hi Martin,

      In that case, you have 6 I2C masters wanting to talk to the same RTC (the slave), which is a multi-master scenario (the DS1339 RTC talks via I2C). You can search the web for I2C multi-master. There are a lot of links that will give you pointers.

      Hope that helps!


Leave a Reply

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

You are commenting using your 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