- Silicon Labs Community
- Welcome and Announcements
- Silicon Labs Knowledge Base
- 8-bit MCU
- 32-bit MCU
- Bluetooth / Wi-Fi
- Other Products Category
- Optical/RH/Temp Sensor
- Other Products
- Hardware and Software Tools
- Simplicity Studio and Software
- General Discussions and Suggestions
- Chinese Forum
- Software Libraries
- Development Kits
- Reference Designs
- Third Party Tools
- White Papers
- Official Blog of Silicon Labs
- Chinese Blog
12-17-2016 08:56 AM - last edited on 12-19-2016 09:26 AM by Nari
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 # PRIVATE_KEY = '2HL151HLWNJNENQD' #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): try: devices[i].getScanData() ble_service.append(Peripheral()) ble_service[char_sensor].connect(devices[i].addr,d
evices[i].addrType) char_sensor = char_sensor + 1 print "Connected %s device with addr %s " % (char_sensor, devices[i].addr) except: non_sensor = non_sensor + 1 try: 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 except: return None while True: bat_data = bat_char.read() bat_data_value = ord(bat_data) temperature_data = temperature_char.read() temperature_data_value =(ord(temperature_data)<<8)+ord(temperature_dat a) float_temperature_data_value = (temperature_data_value / 100) humidity_data = humidity_char.read() humidity_data_value =(ord(humidity_data)<<8)+ord(humidity_data) 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() f.close() count = 0 count = count + 1 sleep(1) while True: vReadSENSE()
Here is the video for the same.
02-27-2017 07:59 AM
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.