A Z-Wave Developer’s Journey | Part 7

Optimizing Z-Wave IoT Devices to Achieve 10+ Year Battery Life

Z-Wave sensors can run for 10 years on a CR2032 coin cell

This is an abbreviated version of the full blog on the Z-Wave Alliance website.

Introduction

Wireless IoT devices are typically powered with batteries. Thus, a key design criterion is: how long will the batteries last? Z-Wave developers must balance battery lifetime, battery type and functionality. Simple Z-Wave sensors can run on a single coin cell for as many as ten years. Door locks need four AA batteries to mechanically throw the locking bolt, but the electronics contribute significantly to battery life. Most devices need at least a two-year battery life otherwise customers feel they are constantly changing batteries resulting in a one-star review.

There are three components of battery life calculation:

  1. Average current while sleeping
  2. Average current while awake
  3. Awake duration

Battery lifetime calculation: Blifetime = Bcapacity/((Iawake * Tawake * Nwakeups) + Isleep)

For example: A device with 3 AAA batteries has a capacity of 1000mAhr, an average awake current (Iawake) of 12mA for 0.2 seconds (Tawake) with 6 wakeups per hour (Nwakeups) and an average sleep current (Isleep) of 0.030mA, you get 1000/(12*(0.2/3600)*6+0.03=29,000 hours or 3.3 years. Thus, the key for long battery life is to minimize the average sleep current and limit the number of times the device wakes up. Obviously matching the size of battery to the task at hand is crucial. Too small of a battery and the user is annoyed with replacing it too often, too large of a battery increases the physical size of the product and the cost.

Troubleshooting

The classic problem when debugging a battery powered device is isolating a high current draw. When debugging a new design, the typical problem is that the board is drawing hundreds of microamps (or even many milliamps!) when it should be under a few tens of microamps. The obvious first thing to check is if the CPU is sleeping. Load the firmware into a devkit so it is the only device drawing power. This isolates all the other sensors or circuits on the board so at least you know the CPU is asleep. Here’s a brief checklist for high current debug:

  1. Is the CPU in Sleep mode?
  2. Is the high-speed oscillator off?
  3. Are GPIOs floating? Unused inputs might oscillate which can draw a lot of power
  4. Are GPIOs fighting pullups/pulldowns? Try disabling pullups/pulldowns in the debugger
  5. Are other circuits drawing power?
    1. Cut power traces, lift power pins, lift circuit pins, remove circuits from the board
  6. Debug GPIOs causing phantom power draw?
    1. Disconnect ALL debug connections – SWD/JTAG and even ground

The big problem comes when customers start returning the product because of short battery life. You may have optimized the battery life in the lab, but did you test it in the real world? One thermostat I worked on would constantly send a humidity report because the humidity reading would bounce back and forth by one percent with each reading. Never saw this in the lab but it became quite common in the field. This was easily solved by adding hysteresis to the readings and requiring the humidity to change in one direction by more than three percent before sending a report. Fortunately, we were able to OTA the firmware and solve the problem before it became widespread.

A serious problem with early FLiRS (now called LSEN) door locks didn’t become a problem until many locks on many Z-Wave networks were installed in a single building. The original WakeUp beam only had the NodeID of the door lock to wake up. The problem was that with many Z-Wave networks in close proximity, every door lock having NodeID 02 (which was the case on all of the networks in the building) when the controller woke up their door lock, all the door locks on all the adjacent networks would wake up because they were all NodeID 02. Battery life in many cases was only a few months due to the gateway polling each door lock every night which meant every door lock woke up hundreds of times every night. This was solved years ago by adding a hash of the HomeID to the WakeUp beam which pretty much assures only the desired node will wake up.

A particularly difficult battery life problem happened with a door/window sensor that in rare cases would remain awake. We had to set up a dozen units and watch the power on them all individually and when one stayed awake for more than 60 seconds then we captured data and stopped the test so we could debug the problem. Turned out the stack was overflowing, causing impossible conditions as I mentioned in Part 5 of the Developers Journey. Often the device continued to function, but it just didn’t sleep causing the battery to die in a few days. Turned out the cause was a complex interaction of interrupts and the Z-Wave mesh rerouting at the same time which is why we didn’t see it in lab testing. Masking all interrupts while servicing the sensor and some careful adjustments to the stack sizes solved the problem which was OTAed to all units in the field.

Remember that each radio transmission uses a significant amount of power. Keep all communication to a minimum especially when powered with coin cells. Ensure that all possible values of configuration parameters can’t accidentally cause rapid transmissions.

Tools For Measuring Power Consumption

Every Z-Wave firmware developer needs access to power measurement tools. These tools can range from Silicon Labs AEM which is part of the development kit to expensive laboratory tools. Measuring the current draw versus time and a few GPIOs is critical for rapidly optimizing battery life. Bill Hewlett, co-founder of Hewlett Packard, has a popular quote: “You cannot manage what you cannot measure… and what gets measured gets done.” The list below provides some tools I’ve used for optimizing battery life – let me know what you’ve had success with!

5-1/2 digit Digital Multi-Meter (DMM) or Bench Power Supply

DMMs with at least 5-1/2 digits have enough dynamic range to measure milliamps to nanoamps. Modern DMMs come with USB and can be remotely controlled and record waveforms for voltage and current but typically lack additional channels for GPIOs or UARTs. DMMs are super accurate for very low currents which is why I typically use one to precisely measure deep sleep current. A good DMM costs $250+ but there are multi-channel power supplies that have similar capabilities for about the same cost. I often use a cheap DRoK power supply with an OLED display to know when the device is sleeping or not, when I don’t need nanoAmp accuracy.

TinyCurrent

TinyCurrent is a budget tool for measuring current but has some limitations.

The TinyCurrent is a cute and cheap device to convert current into voltage which you then connect to your scope. This is a simple opamp across three switch selectable shunt resistors to select the range. The switch is the main limitation of this device as the dynamic range isn’t enough to cover the milliamp awake mode to the sub microamp sleep mode transition. Since it’s a simple analog conversion of current to voltage, it is easy to connect to a scope along with several GPIOs. Measuring the deep sleep current must be done with a DMM or other device but this works fine to quickly see when the device is in deep sleep or active modes.

Nordic PPK

Power Profiler 2 is a capable current measurement tool

The Nordic Power Profiler Kit II (PPK2) is a cost efficient and capable power measurement tool. The nRF Connect windows app displays the current graphically along with up to 8 digital GPIOs. PPK2 measures between 200nA and 1A at 100ksps. The PPK can supply up to 1A of 3.3VDC but I found the supply isn’t clean enough to measure small currents accurately. Instead, I use a battery (usually 3 AAA in series) and pass that through the PPK to get a clean power supply. As a side benefit of using real batteries, the voltage sags during high current draw since the power source is an actual battery. The high dynamic range is achieved by switching between 3 shunt resistors which take several samples to switch. Unfortunately, this is often exactly the behavior that is of interest. Overall, this is a capable tool for an affordable price.

Silicon Labs AEM

Silicon Labs Advanced Energy Monitor (AEM) is the primary power measurement tool for Z-Wave developers. A WSTK (BRD4002) developer’s kit is required to run the AEM which you can now purchase by itself instead of part of a more expensive kit. The AEM supplies 1.8-3.6v up to 500mA with a 100kHz sample rate and a resolution just under 1uA. There are four digital logic inputs as well as the VCOM UART. The Energy Profiler is a tool within Simplicity Studio that provides a graphical interface for the AEM. The energy profiler tool suffers from stability problems but is capable if you are working with Silicon Labs Z-Wave chips.

JouleScope

Joulescope JS220 measuring the current of Z-Wave devices during transmission and while sleeping

Joulescope is currently the industry standard for IoT development. While pricey, it is the perfect tool for the job. Full disclosure: Joulescope provided me with a JS220 for a previous project which I now use for every project. Wide voltage range of +/- 15V, 3A to 0.5nA resolution, 300kHz bandwidth and a reliable multiplatform software application make the Joulescope indispensable. The JS220 has 4 digital inputs and 2 outputs which help correlate current draw with the firmware being executed. The newer JS320 version is now available with even more dynamic range. The screenshot shows the dynamic range from microamps to over 400 milliamps and two digital logic signals indicating the state of the CPU.

Oscilloscope Current Probe

Traditionally, an oscilloscope current probe was used for measuring current and simultaneously sampling several analog or digital channels. The problem with most of these probes is they were designed for high current (60A or more) and relatively low bandwidth and are very expensive, costing around a thousand dollars just for the probe without the scope. They do not have the dynamic range to go from nanoamps to milliamps and generally don’t have the resolution below milliamps. Maybe there’s one in a drawer somewhere you can use but I wouldn’t buy one of these for debugging IoT devices.

Next Steps

Part 8 of the Z-Wave Developer’s Journey discusses sub-GHz antennas which can make or break a Z-Wave product. The distance a Z-Wave product can be from the hub is determined by the efficiency of the antenna. I’ll discuss a few key factors in low-cost antenna design from my experience of having deployed many different types of antennas. As we continue along the Z-Wave Developer’s Journey, I welcome your comments and questions.  Please feel free to reach out to me directly via email.

Seven Habits of Highly Effective Z-Wave Networks for Consumers

You have a Smart Home using Z-Wave as a wireless technology for all these Internet of Things (IoT) devices to communicate with each other. But maybe things are not working quite as well as you expect. You press a button on your phone and 1… 2… 3… and then finally a light comes on or maybe it doesn’t come on at all! Another common problem is when a battery powered sensor was updating the temperature last week and this week it just doesn’t seem to be sending updates anymore or at best sporadically. As a Z-Wave expert I’ve built and rebuilt hundreds of Z-Wave networks and have come up with a few habits to make Z-Wave networks more reliable.

1. Minimize Polling

This is probably THE number one mistake new users of Z-Wave make. They figure Z-Wave is a high speed network so they can just poll a light switch every 3 seconds and then react to any change in the switch. Z-Wave and most other wireless networks work best when the network is highly available. If the network is busy, every device that needs to send a message has to wait its turn and then compete (and often collide) with all that polling traffic. Collisions slow everything down just like rubber-necking on the highway.

Polling used to be the only way to get around a patent that fortunately expired in February 2016. The patent forced many light switch manufacturers to not send a message when you flipped the switch. Several manufacturers found ways to get around this or they licensed the patent. But now that the patent has expired, you can get light switches that do send a report immediately when their state has changed.

So the primary way to minimize polling is to replace the few devices in your Smart Home that trigger an event  (or SmartApp or Magic or whatever your hub calls it) with one that will instantly send an update. If you have some older switches but they’re not that important to instantly know their state has changed, you can still poll them but no more than once every few minutes. Remember that if you have 60 Z-Wave devices and you poll each one once/min then you are polling once/second and the network is hammered! So only poll a couple of nodes!

2. Have enough devices to create a mesh

I can’t tell you how many people I’ve worked with that had a door lock and a hub and nothing else, maybe a battery powered thermostat. And they wondered why the connection to the lock was unreliable when the hub was at the far end of the building! Z-Wave relies on Always-On (110VAC powered) nodes to build a “mesh” network. The mesh is the key to Z-Wave reliability. Every Always-On node acts as a repeater in the mesh and is able to forward a message from one node to another in the mesh. But only the Always-On nodes can forward a message. Battery powered devices like door locks and battery powered thermostats cannot forward messages. Only the Always-On nodes can.

Solution: If some devices are not reliable, add more Always-On devices. Add a Z-Wave repeater or any device like a lamp dimmer. Even if you don’t use the lamp dimmer it will act as a repeater and improve the network. I have a few lamp switches I use for my Christmas lights which I leave plugged in year round because they help the Z-Wave network since these nodes are at the periphery of my home.

Distance between nodes is not always the criteria for adding more nodes in a network. The Z-Wave radio signals may bounce off metal objects like mirrors or appliances and cause two nodes that are only a few feet apart be completely unable to talk to each other due to reflections of the radio signals. Adding more nodes in the mesh provide alternate routes to nodes that otherwise might be in a dead zone due to these reflections cancelling out the radio signals.

3. Place the hub in a central location

Putting the hub in a corner of the basement might be convenient, but its a terrible idea for Z-Wave. The hub is the most important node in the network and should have the best location possible. While Z-Wave is a mesh network and can route or hop thru other nodes in the mesh, each hop is a significant delay and chokes up the network with more traffic. Ideally the hub should reach 90% of the nodes in your Smart Home without relying on routing. If the hub has Wifi then putting it in a central location is easy, you just need a wall outlet to plug it in. I have my hub hung off the back of a TV cabinet in roughly the middle of the first floor of my home.

4. Heal the Network

Once a Z-Wave network is built, it has to be “healed” so every node can use all the other nodes in the network to route messages. This healing process can take many minutes to even hours depending on the size of the network. When you first build a Z-Wave network, the first node added only knows that the hub is in the network. When you add a second node, the hub knows that both the nodes are in the network but the first node you added has no idea that node 2 is there – unless you heal the network. So any time you add a node, you need to heal at least a few nodes in the network if not the entire network. Be cautious with the healing process – it uses 100% of the Z-Wave bandwidth during the process and every node will wake up every FliR node (door locks) at least once which will drain the batteries of the FLiR node. Generally only heal when nodes have been added or removed or if there seems to be a problem in the network.

Z-Wave is able to self-heal automatically. Z-Wave nodes will try various routes to get their message thru if at first it doesn’t succeed.  The node will remember the Last Working Route and try that one first for the next message. But if the nodes have no idea there are other nodes in the network they have no way of knowing what routes to try so at least one full heal of the network is required.

HomeSeer

homeseerhealHomeSeer has several platforms so the precise method might be slightly different than shown here. From the web interface home page select the menu Plug-Ins->Z-Wave->Controller Management then select the Action “Fully Optimize a Network”. The network wide heal will take some time depending on the size of the network.

SmartThings

SmartThings Expert Z-Wave Eric Ryherd DrZwaveSmartThings  user interface is thru their app which makes finding the network heal a bit of a challenge. Start from the dashboard and click on the three lines in the upper left corner. Your Hub should be the first choice in the menu that slides out, click on your hub. A new menu comes up, click on the last choice “Z-Wave Utilities”. The last choice on the next menu that slides in is “Repair Z-Wave Network” so click on it and then click on “Start Z-Wave Network Repair”. The repair will take from minutes to over an hour depending on the size of your network.

Vera

verahealVera has several versions of their UI but each of them has a similar menu structure so these instructions should work on any version. The Vera version shown here is UI7. Use a PC to log into GetVera.com and select your hub. From the Dashboard, select Settings->Z-Wave Settings and then click on the advanced tab. At the bottom of the advanced tab is the GO button to run the “Update Node Neighbors”. Depending on the size of the Z-Wave network this process will take several minutes to over an hour.

5. If a device doesn’t pair, first exclude it, then include it

You’ve taken the brand new Z-Wave IoT widget out of the box and you’ve tried to pair it (the Z-Wave term is “inclusion”) but it just won’t include! Arrrghhh! The first thing to try is to exclude the node first and then try including it. Any hub can “reset” or exclude a Z-Wave device even if that device was previously connected to another network. Some manufacturers occasionally fail to exclude the device during testing so the device may already be connected to their test network. Z-Wave Expert IoT WirelessOr you may have inadvertently included the device but the inclusion process failed somehow and the hub is confused. Excluding the node should reset it to the factory fresh state. Newer Z-Wave Plus devices (which have this logo on them) are required to have a way to reset them to factory defaults using just the device itself. Every device is different so you’ll have to refer to the device manual to perform a factory reset but if all else fails this should make the device ready to pair. Naturally having the hub physically close to the device being paired will also help though most devices can be paired from a distance.

Secure devices like door locks are particularly challenging to pair. First the secure device has to join the Z-Wave network, then the AES-128 encryption keys have to be exchanged and if that process fails (which it does on occasion), then you have to exclude and try the inclusion process all over again. Secure devices definitely want to be within a few feet of the hub during inclusion to ensure reliable and speedy Z-Wave communication.

6. Battery life and how to maximize it

When a battery powered Z-Wave device wakes up and turns on its radio, it uses 10,000 times more battery power than when it’s asleep. So the entire trick to making batteries last is to minimize the amount of time the device is awake. Some devices naturally have other battery draining activities mostly involving motors to throw a deadbolt or raise a window shade. Obviously any motor will use a lot more battery power than the Z-Wave radio but the radio will play a significant role in battery life.

When a battery powered device is added to a Z-Wave network the hub should do two things:

  1. Assign the Association Group 1 NodeID to the hub
    1. Association Group 1 is the “LifeLine” in Z-Wave and devices use this lifeline to send all sensor data and alerts to this node
    2. All hubs are required to assign Group 1 but double check this assignment
  2. Set the Wake Up Interval to no more than once per hour and ideally only a few times per day
    1. Every hub assigns the WakeUpInterval differently and largely handles it behind the scenes so this may be difficult to verify or change
    2. If the device is waking up every few minutes and sends a sensor reading then its battery life isn’t going to be more than a few weeks
    3. The battery level of the device is usually reported at the WakeUpInterval  rate

Many sensors have other Association Groups or Configuration Parameters that will let you specify the frequency of sensor readings. Realize that the more often the sensors report in, the shorter the battery life.

7.  Dead nodes in your controller

One of the big problems in Z-Wave network maintenance is eliminating “dead” nodes. When a device fails or for whatever reason is no longer in use, then it needs to be removed from the controller. If it remains in the controller then the controller will try to route thru this dead node on occasion resulting in delays in delivering messages. Eventually the self-healing aspects of Z-Wave will make this less likely but various devices will on occasion attempt to route thru it. Since the node is dead, that wastes valuable Z-Wave bandwidth and potentially battery power of sleeping devices. Occasionally running a Heal on the network will remove the node from the routing tables but it will remain in the controllers routing tables. It is best to completely remove this dead node. Each hub has a different method for removing dead nodes and usually requires going into an advanced Z-Wave menu.

Following these guidelines will help your Z-Wave experience be more robust. If you have more questions please feel feel to reach out via email to drzwave at expresscontrols.com.