Sunday, April 06, 2014

SensorTag and Raspberry Pi revisted

A year ago I posted some notes on my experiments with the Texas Instruments SensorTag and the Raspberry Pi - Raspberry Pi and TI CC2541 SensorTag.  From the comments received it's apparent that several others have done much the same.  So, thanks to their feedback this weekend I updated my ble-sensor-pi  github repository with a fix for more recent versions of the Bluez bluetooth library.  You'll also find in the README some notes on installing gatttool and enabling the bluetooth adaptor.
In the repository I've added a few extra files for anyone wanting to try sharing their data using Xively.  If you'd like to  try this out then you'll need to register - it's free - and create a new 'device'.  I've called mine 'Wearable Pi' which give a hint as to what I'm hoping to do with it.  Once you've created the device entry on Xively you'll need to create the following channels -
t006, accl_x, accl_y, accl_z, humd_t, humd_rh, baro_t, baro_p, magn_x, magn_y, magn_z, gyro_x, gyro_y, gyro_z
As the code is at present it will collect 10 measurement from each sensor at the default rate of one per second and then upload to Xively.  I did try uploading every second, but the Xively API only allowed this for burst of a few seconds.  There's obviously an opportunity here for some clever optimisation -  upload at a high rate when the data is changing rapidly (shake the SensorTag) and at a lower rate when readings are stable.  It will depend on your intended application.
As before I'm happy to take corrections and questions in the comments.  It would also be nice to know what others are doing with their SensorTag Raspberry Pi combo - so please share.
I'll be taking mine along to the 3rd International Space Apps Challenge on 12/13 April 2014 and maybe hacking some prototype space wearable tech.  


Doug said...

I was using this to check some Java code we wrote to do the temperature calculations. Am I misunderstanding the floatfromhex function? is converting '2c', 'ff' to -211. I come up with $ff21 -> -212.

t = -(float.fromhex('ffff') - t)


t = -(float.fromhex('10000') - t)


It's only .05 C or so, but I want to be sure I understand what the code is doing!

Tony Huy said...

Thanks for the info. Curious on how long the battery life lasts.

Tony Huy said...

hi. thanks for the info. I'm curious on how long the battery life lasts.