I started out with an OpenHab installation on linux, then started adding some sensors.
The easy ones were existing items already compatible and computer based, NUT for UPS, Plex and with a bit of effort server load, temp and memory usage.
I had a couple of raspberry Pis floating around, so after some reading I added a 1 or 2 DHT22 sensors (http://bit.ly/2gR7wcP). Including one raspberry pi with 2 sensors. These work well with MQTT and feed in both temperature and humidity.
But doing that required a fair bit of wiring, and a raspberry pi with power costs around the $80 NZD mark, so I start looking a iBeacons, as some include temperature sensors. The idea being I would have a central device (a Rasbperry Pi most likely), with a bluetooth receiver, and it would take a feed from a number of bluetooth based sensors.
I received one, but could never get the temperature sensor to activate and the support was a little lacking.
Then I stumbled across Blue Maestro (http://bluemaestro.com) . They sell "smart" pacifiers and environmental sensors, all using Bluetooth LE. After some back and forth discussing how they work and their intended use, I purchased a Tempo Disc (https://www.bluemaestro.com/temp-disc-bluetooth-sensors-data-loggers/).
It came with a link to an IOS app for pulling the internal data via bluetooth.
So after looking at it on and off for a couple of months, and with a release on an updated API document, I finally found a set of commands for reading the raw data off the unit without having to make a proper connection.
For some background a bluetooth device will push out advertising packets at defined intervals. These include the MAC address, the UDID of the device and version numbers. But also hidden in another packet is some of the specific manufacturer information and specific instructions, in this case temperature, humidity and dewpoint numbers.
After a lot of trial and error I finally found that wireshark would read a bluetooth dump.
sudo hcidump -w btle.cap
On one SSH session and
sudo hcitool lescan --duplicates
on a second would create a dump file that you could then load into to wireshark. The 2nd command is a bluetooth scan. Its sends out requests for all devices in range and the response from each device is generally 1 or 2 advertising packets (SCAN_RSP - defined by the hex 04 at the start).
Before I found wireshark, at this point all I would see was a dump of hex:
04 3e 2a 02 01 04 01 xx xx xx xx xx xx 1e 1d ff 33 01 00 d9 02 ae 00 c0 02 41 00 d9 02 ae 00 93 00 c0 02 41 00 80 00 d0 02 82 00 89 b8
A blog post a read said that Wireshark could load a dump file from hci dump and interrogate the packets. This made life so much easier to decode the packets, as you saw the hex and ascii.
This is the first packet (above). It contains the mac address (in reverse). There's no specific sensor information in this packet though.
The interesting one is the 2nd one:
04 3e 2b 02 01 00 01 xx xx xx xx xx xx 1f 02 01 06 11 ff 33 01 16 5e 0e 10 00 08 00 bf 02 b0 00 81 01 00 09 09 54 65 6d 70 48 75 6d 33 b3
This one also contains the mac address, and at the far right is actually the devices' name, Preceded by the length of the name. In this case it's 9 characters and is 54, 65, 6d, 70, 48, 75, 6d, which when you convert to ASCII is "TempHum3"
The interesting data is in the middle though. 00 bf (28-29) is the temperature in hex. so 00 bf converting to decimal is 191 - or 19.1 Degrees. Following, the 02 bf, is the humidity, or 688 decimal, or 68.8% and lastly is the dewpoint, 00 81 or 129 = 12.9 Degrees.
Once I had that then I knocked together a quick python program which will pull the advertising packets and put the mac address, temperature, battery, humidity and dewpoint into an object.
MAJOR: 70 48 None
MINOR: 75 6d None
Humidity: 02 5e None
Name: TempHum3 9
Battery: 57 None
I also tested for the company id, which which is the blue maestro company identifier for this specific packet.
Then a send python script calls this one every 10 mins, if the packets are returned then I use MQTT to push the data to openhab. At this point I used the mac address as a main topic...and push the name also. Meaning what ever name I give the device is independent to the mac address and can be use for defining the room.
When it's all complete it looks as follows in OpenHAB;
So now that it's in OpenHab I can move to centralise the collection of environmental data to a couple of raspberry pis.
I'm intending to put the code on github and will link to it when done. The outer is generic, but the inner class is specific to these Blue Maestro discs. But could be adapted for any type of similar device as long at it also used the advertising packets.
UPDATE: Here's a link to github. Both python files in this folder are required. Link Here
Other related posts:
Controlling a 12v fan from a raspberry Pi.
Comment by plas, on 17-Jan-2017 12:30
These look pretty good. I want to add some humidity sensors to the bathrooms and let openhab turn on/off the extraction fans depending on the humidity in the room.