Revision [22126]
This is an old revision of SensorPuck made by ToBo on 2015-10-17 03:21:25.
Sensor Puck
"The sensor puck demonstrates Silicon Laboratories optical sensor (Si1147M01 Si1147-M01) RH and temperature sensor
Si7021 and low power MCU (EFM32G210 Gecko). The data is broadcast using a Bluetooth Low Energy (BLE)
module and can be displayed on a mobile device (Apple iOS or Android) that supports the BLE protocol.
By using broadcast mode, a connection does not have to be established, making it possible to display the data
from several modules at the same time."
Microcontroller EFM32G210
http://www.silabs.com/products/sensors/Pages/environmental-biometric-sensor-puck.aspx
Broadcast Format Specification
http://community.silabs.com/mgrfq63796/attachments/mgrfq63796/6/10653/1/Silicon%20Labs%20Sensor%20Puck%20App.pdf
# Code based on the implementation from http://amperture.com/?p=23
# With additions by Andreas Tobola, October 2015, http://tnotes.de/SensorPuck
import subprocess
import os
proc = subprocess.Popen(['hcidump --raw'], stdout=subprocess.PIPE, shell=True)
hrmStateStr = ['Idle', 'No Signal', 'Acquiring', 'Active', 'Invalid', 'Error']
while True:
line = proc.stdout.readline()
if ">" not in line:
hexarray = line.split()
N = len(hexarray)
os.system('clear')
if N==14:
print "== Enviromental Mode ==\n"
# Humidity uint16 deciprecent
humidity = (int(hexarray[6], 16) << 8) + int(hexarray[5], 16)
humidity = float(humidity)/10
# Temperature int16 decidegrees (can be negative -> twos complement)
temp = (int(hexarray[8], 16) << 8) + int(hexarray[7], 16)
temp = float(temp)/10
# Ambient Light uint16 lux/2
amblight = (int(hexarray[10], 16) << 8) + int(hexarray[9], 16)
amblight = float(amblight)/2
# UV Index uint8 index
uvidx = int(hexarray[11], 16)
# Battery Voltage uint8 decivolts
vbat = int(hexarray[12], 16)
vbat = float(vbat)/10
print "Humidity: %.1f " %humidity
print "Temperature: %.1f C" %temp
print "Ambient light: %.1f Lux" %amblight
print "UV index: %.1f" %uvidx
print "Battery voltage: %.1f V" %vbat
elif N==18:
print "== Biometric Mode ==\n"
# HRM State uint8 none
hrmState = int(hexarray[5], 16)
print "HRM state: " + hrmStateStr[hrmState]
# HRM Rate uint8 bpm
pulseRate = int(hexarray[6], 16)
print "Pulse rate: " + str(pulseRate) + " bpm"
# HRM Sample Array uint16[5] none
# ...
print " "
# With additions by Andreas Tobola, October 2015, http://tnotes.de/SensorPuck
import subprocess
import os
proc = subprocess.Popen(['hcidump --raw'], stdout=subprocess.PIPE, shell=True)
hrmStateStr = ['Idle', 'No Signal', 'Acquiring', 'Active', 'Invalid', 'Error']
while True:
line = proc.stdout.readline()
if ">" not in line:
hexarray = line.split()
N = len(hexarray)
os.system('clear')
if N==14:
print "== Enviromental Mode ==\n"
# Humidity uint16 deciprecent
humidity = (int(hexarray[6], 16) << 8) + int(hexarray[5], 16)
humidity = float(humidity)/10
# Temperature int16 decidegrees (can be negative -> twos complement)
temp = (int(hexarray[8], 16) << 8) + int(hexarray[7], 16)
temp = float(temp)/10
# Ambient Light uint16 lux/2
amblight = (int(hexarray[10], 16) << 8) + int(hexarray[9], 16)
amblight = float(amblight)/2
# UV Index uint8 index
uvidx = int(hexarray[11], 16)
# Battery Voltage uint8 decivolts
vbat = int(hexarray[12], 16)
vbat = float(vbat)/10
print "Humidity: %.1f " %humidity
print "Temperature: %.1f C" %temp
print "Ambient light: %.1f Lux" %amblight
print "UV index: %.1f" %uvidx
print "Battery voltage: %.1f V" %vbat
elif N==18:
print "== Biometric Mode ==\n"
# HRM State uint8 none
hrmState = int(hexarray[5], 16)
print "HRM state: " + hrmStateStr[hrmState]
# HRM Rate uint8 bpm
pulseRate = int(hexarray[6], 16)
print "Pulse rate: " + str(pulseRate) + " bpm"
# HRM Sample Array uint16[5] none
# ...
print " "
The Sensor Puck has two modes Enviromental and Biometric Mode.
If the finger is on the optical sensor, the sensor switches into Biometric Mode.
Depending on the mode the sensor broadcasts different data.
== Enviromental Mode == Humidity: 51.4 % Temperature: 20.5 C Ambient light: 1.5 Lux UV index: 0.0 Battery voltage: 3.0 V
== Biometric Mode == HRM state: Active Pulse rate: 72 bpm
Siehe auch • • • • • • • •