First of all I would like to Thank you Silicon Labs for the Thunderboard Sense Kit ! Tiny but Swiss Knife of Sensors. 


Trust me it is !




I have decided to go with IoT demo using this kit which sends Temperature, Humidity and Battery Level to Cloud.


I choose RaspberryPi 3 Model B to collect the data from Sense Kit and then upload it to https://thingspeak.com/ portal.


Thingspeak is very easy to create and use platform. I have created my channel there with three fields. It gives you unique API Key using which you can push data to cloud and on Thingspeak you can view the graph of your logged data. There is limit on it so you can push data once at every 15 seconds only.



Thingspeak Dashboard !



Thingspeak Graph !


Project posted by @Namo_Aton helped me to to start things and find characteristics I want to read out and push data to cloud.


As I want to read Battery Level, Temperature and Humidity I have find out those three characteristics first and then read it. It will read parameters at every 1 second but push to cloud at 15 second interval.


Here is the python script to connect with Sense Kit, Read data and push to Cloud.

from __future__ import division
import sys
from bluepy.btle import *
import struct
import thread
from time import sleep
import urllib2


#Base URL of Thingspeak
baseURL = 'https://api.thingspeak.com/update?api_key='

def vReadSENSE():
	scanner = Scanner(0)
	devices = scanner.scan(3)
	for dev in devices:
		print "Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi)

		for (adtype, desc, value) in dev.getScanData():
			print "  %s = %s" % (desc, value)
	num_ble = len(devices)
	print num_ble
	if num_ble==0:
		return None
	ble_service = []
	char_sensor = 0
	non_sensor = 0
	bat_char = Characteristic
	temperature_char = Characteristic
	humidity_char = Characteristic
	count = 15
	for i in range(num_ble):
			char_sensor = char_sensor + 1
			print "Connected %s device with addr %s " % (char_sensor, devices[i].addr)
			non_sensor = non_sensor + 1
		for i in range(char_sensor):
			services = ble_service[i].getServices()
			characteristics = ble_service[i].getCharacteristics()
			for k in characteristics:
				print k
				if k.uuid=="2a19":
					print "Battery Level"
					bat_char = k
				if k.uuid == "2a6e":
					print "Temperature"
					temperature_char = k
				if k.uuid == "2a6f":
					print "Humidity"
					humidity_char = k
		return None
	while True:
		bat_data = bat_char.read()
		bat_data_value = ord(bat_data[0])
		temperature_data = temperature_char.read()
		temperature_data_value =(ord(temperature_data[1])<<8)+ord(temperature_data[0])
		float_temperature_data_value = (temperature_data_value / 100)
		humidity_data = humidity_char.read()
		humidity_data_value =(ord(humidity_data[1])<<8)+ord(humidity_data[0])

		print "Battery: ", bat_data_value
		print "Temperature: ", float_temperature_data_value
		print "Humidity: ", humidity_data_value
		if count > 14:
			f = urllib2.urlopen(baseURL + PRIVATE_KEY +"&field1=%s&field2=%s&field3=%s" % (bat_data_value, float_temperature_data_value, humidity_data_value))
			print f.read()
			count = 0
		count = count + 1 

while True:


Here is the video for the same.



Cheers !


  • Projects
  • Sensors
  • Bluetooth Low Energy
  • Wireless
  • Superb Harshadbhai! Smiley Happy

  • Setup for this demo !



  • Great job.

    Is the sensors starting the advertise without any setup needed ?

    Had you to modify the factory set firmware ?

    Thanks, nice day


  • Thanks!

    This works like a charm, and is a great help in getting me started with my project..


    Simon M

  • HallMark - great project and thanks for sharing all the detail. If you don't mind I have a couple of questions (am a Sense newbie); 


    1. Do you know if there is anyway to get access to sensor data without going through BLE? Ideally would like to pick it up through I2C bus and handle the upload to the cloud from there (using another dev board). 


    2.  Did you have to modify any of the code on the Sense board itself? Does it have good standalone performance (i.e. running for 24 hours, reporting every 15 seconds)?


    Ideally I'd like to make a standalone sensor board, which updates every now and then, to the cloud, and stores necessary data. I understand the Thunderboard Sense doesn't have Wifi, so trying to work out how to do this without my phone / PC being around all the time.  


    Thanks and look forward to hearing from you. 

  • @HallMark

    I'm going through your code and seem to be getting somewhere (good news). 


    How would one adjust your code to connect only to the Thunderboard Sense, and not any other BLE device around..? I imagine we would just need the MAC address (00:0B:57:36:63:FF). 




  • Battery:  61
    Temperature:  20.73
    Humidity:  4050
    Battery:  61
    Temperature:  20.73
    Humidity:  4050

    It's working! Thanks, seem to have figured it out. It connects only the Thunderboard Sense now, and nothing else. Information flowing through!

  • @HallMark


    In your code, can you explain to me the reading and conversion of the humidity data?


    humidity_data = humidity_char.read()
    		humidity_data_value =(ord(humidity_data[1])<<8)+ord(humidity_data[0])

    I'm really not sure that the above does (obviously converting it from one form to the other) however the number I get out doesn't seem right with vales of 4096...

    Is that perhaps 40.96% humidity? It did rise from 3840 when I blew on it ... so there is valid stream of data coming through. 


    Humidity:  4096
    Battery:  60
    Temperature:  20.65
    Humidity:  4096
    Battery:  59
    Temperature:  20.65
    Humidity:  4096
  • Hi Neal,

    Since the humidity and temp sensor are the same unit I treated the data in the same way, and divided by 100, but now you have got me thinking...


    Yours Simon M.

  • @samarkh 


    humidity_data = humidity_char.read()
    		humidity_data_value =((ord(humidity_data[1]) <<8)+ord(humidity_data[0]))/100

    Essentially I just divided the whole thing by 100 and am getting a number which might be closer to normal (perhaps as I don't understand). 



    Battery: 58
    Temperature: 23.12
    Humidity: 39.56


    Let me know what you see, or what you suggest.