Raspberry Pi and Sensor Tag - Part II

In my last post on this subject, I documented how to set up your RPi for the purpose of connecting to a Sensor Tag by TI and then collect data through all its sensors.
In this second part of that journey I am going to show you how to accomplish the followings:
  1. Find the address of your Sensor Tag
  2. Connect manually to validate that Bluetooth works as expected
  3. Retrieve data from the sensors
Find Mac Address
There are a few commands that you will find useful in this quest of dealing with BT devices on Linux based systems.
With the following command, you can discover all the devices in discovery mode around you and their mac address. We’re interested into grabbing the one that reports “SensorTag”. Turn on your tag, launch the command and then Ctrl + C to stop as soon you spot it.
sudo hcitool lescan 
Copy the associated address in the clipboard and then run this command
sudo hcitool leech <your address here>

Read Sensors

Now let’s switch on the thermometer sensor and read its value through the use of the Gatt Tool.
gatttool -b 90:59:AF:0A:A8:4E –interactiveconnectchar-read-had 0x25disconnectexit
At this point if you encountered no error then we can move to the next phase. I learned all that stuff from reading Michal’s Saunby blog and his GitHub branch on the subject. Thanks, Michael!

Retrieve Data

Now we’re going to download some Python code and test all out. Enter the folder that we created last time “andromeda” and use the following command
That will download from Github the code to retrieve temp data from the sensor. To run it just type
python read_temp.py <your_sendor_tag_address>
You should see something like this
And, if you do then you should be very happy because after this we can move to the next phase that is: build some code in Node js to retrieve and store data.



Popular posts from this blog

Bring Boxee Box back to life

Postgres on Synology

Zen-inification - The art of decluttering