Category: BLE

Blue Maestro sensor, openHAB or Home Assistant and HomeKit

28. June 2019 21:27 by Jens Willy Johannsen
Categories: BLE | Home Automation

Since I’m already working on a device for showing the temperature reported from a Bluetooth sensor (read more) and I’ve also been doing some home automation stuff using openHAB and Home Assistant, I thought it ought to be possible to get the openHAB server to report the temperature as well. It is. This is how it works:

  1. The BLE device reports the current temperature in BLE advertisement packages.
  2. The Raspberry Pi server runs a Python script as a service that performs BLE scanning and looks at the advertisement packages, identifying and parsing packages from the BLE device.
  3. Whenever a matching BLE advertisement package is found, the current temperature is extracted (along with humidity and dewpoint) and posted to an MQTT server.

For openHAB:

  1. The openHAB server running on the same Raspberry Pi uses the MQTT Binding to connect to the MQTT server and things and items are configured to subscribe to the appropriate topics and expose the temperature and timestamp.
  2. The openHAB server also uses the HomeKit Add-on to publish the temperature as a HomeKit compatible temperature sensor so it's available on all my iOS/watchOS/macOS devices.

For Home Assistant:

  1. The Home Assistant running on another Raspberry Pi using uses an MQTT connection to expose the values as sensor readings.
  2. … and also uses the HomeKit integration to publish the temperature to Apple HomeKit. Which works perfectly out of the box.

Awesome. But there were several steps along the path. Read on for the details and code...

Read the entire post »
Comments 8 comments »

Antenna design and matching

17. October 2018 21:25 by Jens Willy Johannsen
Categories: BLE

At the moment, I'm working with Bluetooth Low-Energy devices and it very quickly became apparent that designing a PCB with a BLE antenna (no matter which type) is nowhere near as simple as designing the kind of boards I usually work with (MCU, digital circuitry and senors and a couple of actuators).

Starting to read up on the topic of antenna design only served to confuse me even further. So while this blog post is not a comprehensive guide to antenna design, but more of a brief recap of what I have learned so far, I hope it can help others about to learn antenna design.


The basic premise is that we want to build a device consisting of a transmitter and receiver (since BLE is two-way communication) that can communicate as efficiently as possible with another transmitter/receiver device. A higher degree of efficiency means a longer range for the same power usage (sure, you could just pump several megawatts of power into a poorly designed antenna and get a good range out of it but we don't want to do that for many reasons).

Within very few minutes of starting to read about antenna design you will encounter the term "impedance matching". And that is basically what this entire post is about. In a system where impedances are perfectly matched, all of the power leaving the transmitter IC (in our case a Nordic Semiconductor nRF51822 BLE SoC) will be delivered to the antenna. In a system where impedances a not matched at all, none of the power leaving the IC will be converted to RF energy and the resulting range of the device will be zero. The more power that reaches the antenna, the better efficiency we achieve and the better range we get. A perfect match is simply not possible so we're just trying for "as good as possible given the constraints of power, space, time, money and level of ambition".

Read the entire post »

Comments 5 comments »

Flashing a Minew D15 iBeacon using nRF51 Development Kit

3. June 2018 21:34 by Jens Willy Johannsen
Categories: BLE

I've been looking a various replacements for the Bluegiga BLE112 and BLE113 modules I've been using so far for all projects involving BLE. Not that there is anything wrong with them, but they are a bit expensive.

So right now, I'm looking at the Nordic Semiconductor nRF51822 chip. It's got a couple of things going for it:

  • It is pretty cheap
  • It only requires relatively few support components
  • The free version of the Keil IDE can be used for most projects. And this is important since the Keil µVision IDE costs about $4000
  • The free, online IDE can be used
  • There's lots of documentation and many people are using it

I bought the nRF51 Development Kit (which has an onboard programmer) then I remembered I had a bunch of Minew D15 iBeacons lying around (From Alibaba). And since they are populated with nRF51822's, I figured I'd try to see if I could them flashed with my own firmware. (Spoiler alert: I could.)
Here's a short writeup of what I did.

Read the entire post »

No comments No comments »