August 2017: Bluetooth Edition

Welcome to the August 2017 edition of the Embedded Artistry Newsletter! This is a monthly newsletter of curated and original content to help you build better embedded systems. This newsletter is intended to supplement the website.

This month we'll be covering:

  • MAX17055 - a new fuel gauge chip from Maxim
  • The Bluetooth 5 standard and changes to the PHY
  • Processors and development kits that support Bluetooth 5
  • The new Bluetooth Mesh standard
  • SDKs that support Bluetooth Mesh
  • A handy trick for when you can't read the part numbers on a chip

MAX17055 - New Maxim Fuel Gauge

Those of us who have used TI's GasGauge line understand how frustrating their parts can be. Undocumented behavior in the gauge firmware, required battery characterization, and per-product configuration can lead to frustrating bugs that are hard to debug. Unless you're a large customer, you have very little chance of getting help from TI and problems often stay unresolved.

One of my clients is using a new fuel gauge chip - the MAX17055 Fuel Gauge. Maxim claims that their gauge "eliminates battery characterization requirements and simplifies the host software interaction" and requires only 7µA of operating current. Unlike TI, Maxim provided great direct support for integrating this part into the new system.

Maxim provides a software implementation guide which describes various methods of using the part. By following the software guide, I implemented a driver for my system in less than an hour. Once the new boards arrived, the driver was working perfectly in a matter of minutes and the initial calibration resulted in readings that were within 5% of the actual voltage value. Since the Maxim Fuel Gauge is a learning gauge, this initial accuracy should improve over a few charge/discharge cycles.

If you're looking for a fuel gauge to use in your next battery-powered device, I recommend the MAX17055.


Bluetooth 5 & Bluetooth Mesh

We've seen two major Bluetooth specification releases in the past 12 months: Bluetooth 5 and Bluetooth Mesh.

It typically takes ~6 months for us to see devices once a new specification is released. We're well into that window for Bluetooth 5, so expect to start seeing new devices soon. Bluetooth Mesh is fresh off the press, so now is the time to start familiarizing yourself with the specification to stay ahead of the curve.

Next, I'll describe the changes involved with the Bluetooth 5 and Bluetooth Mesh specifications. I'll also provide some supplementary reading material and showcase some interesting Bluetooth 5 chips and development kits.


Bluetooth 5

The Bluetooth 5 specification was released in December 2016. The new specification claims a variety of improvements:

  • 4x range
  • 2.5x lower power (BLE)
  • 2x speed (supporting a new 2Mbit/s high-throughput mode)
  • Increased advertising data payload from 31B to 255B
  • Ability to chain advertising packets to create extended payloads
  • Improved coexistence with other WiFi, Bluetooth, and 2.4GHz devices via an improved channel hopping algorithm

The speed and range improvements are brought about by changing the physical layer (PHY) of the Bluetooth protocol stack. The Bluetooth PHY now supports two additional modes, which allow for increased speed or increased range. The three Bluetooth PHYs are:

  1. "LE 1M" - the PHY used in Bluetooth 4
  2. "LE 2M" - the 2Mb/s PHY, which doubles the speed of the LE1M PHY
  3. "LE Coded" - the new long-range PHY that adds error correction

The increased range does not involve any transmit power increases. Instead, the increase is provided by improving receiver sensitivity and utilizing Forward Error Correction (FEC). FEC adds redundant data bits to the transmitted packets. These redundant bits allow for error correction to be performed by the receiver and for messages to be correctly decoded at a lower signal-to-noise ratio (SNR). This provides a ~12dB improvement in receiver sensitivity, resulting in the 4x range improvement. Of course, the redundant information does come with a penalty in reduced data throughput due to the need to transmit redundant bits.

You can switch between PHYs by using the new HCI command "LE Set PHY". You can independently select the PHY to use for both transmit (TX) and receive (RX). This means that we can switch between PHY modes depending on our operational situation. Additional HCI commands are defined to support setting the default PHY and for querying the PHY capabilities of remote devices.

Bluetooth 5 is operationally compatible with Bluetooth 4.x devices. However, the changes to the Bluetooth 5 specification have been made at the PHY layer. You will be tied to the LE 1M PHY and will not be able to take advantage of Bluetooth 5 benefits.

For more details on Bluetooth 5, read these:

Bluetooth 5 Chips & Development Kits

Let’s take a look at some development kits and chips from Nordic and Silicon Labs that already support the new standard.

Nordic nRF52

Nordic offers Bluetooth 5 support in its nRF52 line, consisting of three chips: nRF52810, nRF52832, and nRF52840. All of the nRF52 chips support the new CSA algorithm, the LE 2M PHY, and increased advertising packet size. However, only the nRF52840 has support for the new long-range LE Coded PHY.

nRF52810 & nRF52 DK

The nRF52810 is the simplest of the three Bluetooth 5 chips, sporting a Cortex-M4 and a basic set of peripherals. Due to the reduced flash, RAM, and peripheral counts, this chip is useful as a dedicated Bluetooth processor in a multi-chip system.

The nRF52810 itself is not included on a development kit. Nordic recommends the nRF52 DK for exploring the low-end of the nRF52 series. This starter board is compatible with Arduino shields, allowing for some interesting prototyping options. The nRF52 DK utilizes a nRF52832, so you'll want to hold off on using unsupported features if you're going to uses the nRF52810.

nRF52810 Specifications:

  • 32-bit Cortex-M4 64MHz Processor
  • 1.7v to 3.6v operation
  • 192kB flash + 24kB RAM
  • Up to +4dBm output power
  • -96dBm sensitivity, Bluetooth low energy
  • 1 x Master/Slave SPI
  • 1 x Two-wire interface (I²C)
  • 1 x PWM (4 channels)
  • AES HW encryption
  • 8-channel 10/12-bit ADC
  • Quadrature decoder
  • 64-level analog comparator
  • Real Time Counter (RTC)
  • Digital microphone interface (PDM)

More on the nRF52810:

Nordic nRF52832 & Nordic Thingy:52

The nRF52832 is the mid-tier Bluetooth 5 chip. The nRF52832 is built on a Cortex-M4F processor. The nRF52832 provides a significant increase in flash, RAM, and peripherals over the nRF52810. These improvements make the nRF52832 an attractive choice as a primary processor for your system or for exploring new BLE features like IPv6 support. The nRF52832 includes an on-chip NFC tag to support out-of-band pairing. You can utilize the NFC pairing method for a simpler process of exchanging authentication information between two bluetooth devices.

The nRF52 DK supports the nRF52832, but Nordic also sells the Thingy:52 development kit. The Thingy:52 provides you with a variety of environmental sensors (temp, humidity, pressure, air quality, color, and light), a 9-axis IMU (accelerometer, gyro, and compass), a speaker, and a microphone. The range of components provided with this dev kit is impressive and useful for many Bluetooth prototyping scenarios. Nordic also supplies a Thingy:52 app and demo code to get you up and running as quickly as possible.

nRF52832 Specifications:

  • 32-bit ARM Cortex-M4F 64MHz Processor
  • 1.7v to 3.6v operation
  • 512kB flash + 64kB RAM
  • On-chip NFC tag for Out-of-Band (OOB) pairing
  • Up to +4dBm output power
  • -96dBm sensitivity, Bluetooth low energy
  • 3 x Master/Slave SPI
  • 2 x Two-wire interface (I²C)
  • UART (RTS/CTS)
  • 3 x PWM
  • AES HW encryption
  • 12-bit ADC
  • Real Time Counter (RTC)
  • Digital microphone interface (PDM)
  • On-chip balun

More on nRF52832:

nRF52840 & Preview DK

The nRF52840 is the king of the Bluetooth 5 chips and the only chip in the product line that supports 802.15.4 and the new Bluetooth 5 LE Coded PHY. The nRF52840 provides an impressive 1MB of flash and 256kB of RAM.The chip sports additional peripherals, such as the ARM Cryptocell cryptographic co-processor and a USB 2.0 controller. With an improved output power of up to +8dBm, the nRF52840 is definitely the chip to pick if you're looking at long-range Bluetooth communications.

Nordic has released a nRF52840 Preview Development Kit (PDK). This kit is more similar to the nRF52 DK than the Thingy:52. The PDK provides no external peripherals or sensors to play with, but like the nRF52 DK it is compatible with Arduino shields for easy prototyping.

nRF52840 Specifications:

  • 32-bit ARM Cortex-M4F 64MHz Processor
  • 1.7v to 5.5v operation
  • 1MB flash + 256kB RAM
  • Up to +8dBm output power
  • 802.15.4 radio support (ZigBee and Thread)
  • On-chip NFC
  • PPI –Programmable Peripheral Interconnect
  • 48 x GPIO
  • 1 x QSPI
  • 4 x Master/Slave SPI
  • 2 x Two-wire interface (I²C)
  • I²S interface
  • 2 x UART
  • 4 x PWM
  • USB 2.0 controller
  • ARM TrustZone CryptoCell-310 Cryptographic and security module
  • AES 128-bit ECB/CCM/AAR hardware accelerator
  • Digital microphone interface (PDM)
  • Quadrature decoder
  • 12-bit ADC
  • Low power comparator
  • On-chip balun

More on nRF52840:

Silicon Labs EFR32

Silicon Labs offers Bluetooth 5 support in the EFR32 Blue Gecko line of SoCs. Similar to the Nordic nRF52810, the EFR32 series is built upon a Cortex-M4 processor. The EFR32 line sports a whopping +19dBm of programmable output power in their beefiest configuration.

Silicon Labs provides a Blue Gecko Starter Kit to support EFR32 development. The starter kit is modularized to support a wide variety of radio daughter boards for easy prototyping and chip comparisons. The starter kit comes with two Bluetooth radio daughter boards. Only the provided EFR32BG13 radio board supports the LE Coded and LE 2M PHYs. The starter kit contains a few push buttons and a coin cell battery holder, but does not include other on-board peripherals. A wide variety of headers are supplied for your prototyping needs.

Unlike Nordic's nRF52 line, the EFR32 line has many different chip configurations. Also, not all EFR32 chips support the new 2M PHY and LE Coded PHY, so be sure to include those features in your search. Silicon Labs provides a full list of EFR32 SoCs, so you can find one that fits your needs exactly.

Sample EFR32 Specifications using maximum values:

  • ARM Cortex-M4 Processor (up to 40MHz)
  • Up to 1MB of flash
  • Up to 256kB SRAM
  • Up to +19dBm output power
  • AES256/128 hardware accelerator
  • 12-bit ADC
  • Current DAC (4-bit)
  • Up to 4x analog comparators
  • Low-energy UART
  • Up to 4x USART (SPI, UART, I2S, IrDA)
  • Up to 2x I2C
  • Up to 65 GPIOs
  • On-chip balun

EFR32BG12P632F512FM38 Specifications (Blue Gecko Starter Kit):

  • ARM Cortex-M4 40 MHz Processor
  • 512kB Flash + 64kB SRAM
  • +10dBm output power
  • -103.3dBm receiver sensitivity
  • AES-128/256 hardware accelerator
  • 12-bit ADC
  • Current DAC (4-bit)
  • Up to 4x analog comparators
  • 4x UART Ports
  • 3x USART ports (SPI, UART, I2C)
  • 2x I2C ports
  • 31 GPIOs

More on EFR32:


Bluetooth Mesh

Bluetooth Mesh is not included in the Bluetooth 5 standard. It was released in July 2017. Bluetooth Mesh provides the ability for Bluetooth devices to implement a many-to-many (m:m) network with a maximum size of 32,000 devices. Previously we were limited to a one-to-many (1:m) topology, where a central Bluetooth hub was responsible for broadcasting messages to the various nodes. In addition to m:m topology support, Mesh allows devices to relay data to other devices that are not in direct radio range. This re-broadcasting scheme allows the network to cover a larger area than with Bluetooth LE. Since Bluetooth Mesh is built upon Bluetooth LE, it can be utilized by both Bluetooth 4.x and Bluetooth 5 devices. Existing devices in the field can take advantage of Bluetooth Mesh as long as they are capable of firmware updates.

Bluetooth Mesh devices communicate using a publish/subscribe messaging system. Whenever a device publishes a message to a specific topic, all devices who are subscribed to that topic will receive a copy. Mesh also introduces the concept of device "state" which can be adjusted through published messages. The new "model" concept defines a mesh node's messages, states, and behavior.

Bluetooth Mesh utilizes a "managed flooding" approach, allowing for a peer-to-peer multi-path communication network. Since there is no central hub or routing nodes, the network is more resilient to device failures. Messages are retransmitted by devices which are designated as "relays", allowing messages to reach nodes that are not in direct radio range. A message can make a maximum of 127 hops, allowing us to cover quite a large physical area. Devices contain a message cache which is used to determine whether a particular message has been seen before. If it has, the message is discarded and not processed by the stack.

Some of our mesh nodes are likely to be low-power devices which wake up periodically to relay data. Bluetooth Mesh allows us to designate "friend" nodes which are not power constrained. These friend nodes store messages intended for the low-power node. Once the low-power node wakes up, it can request the cached information from its friend. This concept of "friendship" allows us to implement an efficient wakeup schedule to conserve battery life.

Mesh nodes send out regular heartbeat messages to let us know that they are alive. These heartbeat messages allow the network to learn about its topology and help devices avoid unnecessary message retransmissions. There is also a mandatory "health" model which allows devices to send out fault information, such as in low battery or overheating conditions.

Bluetooth SIG is targeting industrial applications so Bluetooth Mesh is designed with security in mind. Every packet is encrypted and authenticated, asymmetric cryptography can be utilized, and security keys get refreshed periodically.

It's possible to utilize multiple mesh networks in the same location. Each mesh network has an identifier which indicates which network the packet belongs to. Also, thanks to the built-in security, devices cannot decrypt or authenticate mesh packets from another mesh network. Each network remains isolated from the other.

Large-scale sensor networks, asset tracking, building automation, and commercial lighting solutions are expected to be the first use cases of the new mesh networking protocol. Multiple projects that I've worked on recently will benefit from switching to Bluetooth Mesh.

More on Bluetooth Mesh:


Bluetooth Mesh SDKs

In order to build a mesh network, we need a compatible software stack. Bluetooth mesh networks require a Bluetooth LE 4.x or 5.0 which supports GAP Broadcaster and Observer roles. These roles are used to advertise and scan for advertising packets. Luckily, both Nordic and Silicon Labs have made our lives easy and provide full-fledge SDKs to support Bluetooth Mesh development.

Nordic

Nordic supplies an nRF5 SDK for Mesh. The SDK is currently noted as "alpha" quality, but you can download the SDK and start prototyping immediately.

The Mesh SDK is compatible with both the nRF51 and nRF52 processor lines. The SDK comes with example applications and models for beaconing, lighting control, and provisioning devices (including provisioning through relay nodes). The SDK allows for node-to-node and node-to-group communications and supports configurable scanning and advertising interval. It's also worth noting Nordic's excellent OTA DFU support remains in place with the Bluetooth Mesh SDK.

More on the Nordic Mesh SDK:

Silicon Labs

Silicon Labs also supplies a Bluetooth Mesh SDK. The SDK is currently noted as "beta" quality. You must create an account and request access to the SDK before you are able to download it. Silicon Labs is lighter on the describing support currently provided in their SDK, but they claim to be compliant with the existing specification and support the LE 2M and LE Coded PHYs. My SDK access request was approved within 24 hours.

More on Silicon Labs Mesh SDK:


Can't See IC Part Numbers? Try this

I learned an awesome trick from EDN's recent article "Simple Trick Lets You See Your Parts". If you need to read the part number on an IC but can't make out the details, simply apply a clear piece of cellophane tape to the part. I've used this trick multiple times in the past week, and it's extremely helpful when I'm away from a microscope.

EDN provides a great warning that you should heed:

Be careful though, as tape can generate considerable ESD, so avoid touching the actual pins of the package.

ReadingICPartNumbers

Website Updates

I've made a few updates to the website:

  • Created a new Development Kits page. Take a look if you need inspiration for your next project or want to experiment with more complex systems.
  • Added clang and Modern C++ references to Around the Web
  • Added language recommendations to Getting Started. I also removed an outdated C++ Idioms reference and added a book recommendation for developing your software career.
  • Expanded the Glossary

These were the most popular articles over the past month:

  1. Ditch Those Built-in Arrays for C++ Containers
  2. Migrating from C to C++: Take Advantage of RAII/SBRM
  3. Using A C++ Object's Member Function with C-style Callbacks
  4. Ditch Your C-style Pointers for Smart Pointers
  5. Installing LLVM/Clang on OSX