In my previous post Low Power IoT Design Challenge - WLAN Low Power , I had taken some current measurements of my project running prior to any attempts at power reduction. I had also tried the WLAN Low Power example that uses the Low Power Assistant (LPA) library. That example uses a custom design.modus file to configure the board (MCU and WiFi modules) for low power.
If you examine the project directory structure, you can see the standard design.modus file is included with the BSP under the libs directory. The custom design.modus file is under the COMPONENT_CUSTOM_DESIGN_MODUS directory.
To use the custom design.modus file just requires changes to the COMPONENTS section of the Makefile. Add CUSTOM_DESIGN_MODUS to the COMPONENTS list and BSP_DESIGN_MODUS to the DISABLE_COMPONENTS list.
I thought that I could just copy the COMPONENT_CUSTOM_DESIGN_MODUS directory from the WLAN Low Power example to my project and update the Makefile and add the lpa library. Well, it almost worked. The project built without a problem (I also needed to add WCM to the COMPONENTS list). The program started and WiFi connected, but MQTT was broken - or more specifically Subscribe was not working, but Publish was. The WLAN Low Power example was not using MQTT, so there was something missing in the custom configuration.
Luckily, Infineon has a very good Application Note AN227910 about configuring this WiFi/BT module and PSoC6 MCU for low power https://www.cypress.com/documentation/application-notes/an227910-low-power-system-design-airoc-cyw43012-wi-fi-bluetooth .
In that App Note there is also a recommended configuration for an AWS MQTT example. So, I'm going to use that as a starting point.
Rather than using the CUSTOM_DESIGN, I'm just going to use the Device Configurator from the Quick Panel to modify the base BSP configuration.
For the MCU:
LP vs ULP for System Active Power because of the 50MHz frequency requirement for WiFi.
Buck vs LDO regulator
System Deep Sleep vs Active or CPU Sleep
Configure the Interrupt Pin P4[1] so that the WiFi module can wake the MCU up from sleep
On the WiFi module:
Enable Host Wake Configuration
Configure the Host Device Interrupt Pin
Configure ARP Offload
Enable MQTT Filters (only wake on MQTT activity)
Add Minimal Set of Keep Filters
This configuration allows MQTT to work properly in my application. The differences that I noted between this configuration and the WLAN Low Power are:
MCU Active mode was ULP instead of LP
ARP Offload was not enabled
MQTT Filters were not enabled
Add Minimal Set of Keep Filters was not enabled
Power Reduction with New Low Power Configuration
Old configuration
New Configuration
Over the same 2 minute startup window the average current dropped from 1.67 mA to 436 uA. You can see that current during the MQTT intervals appears to have dropped substantially (the lack of white space). For good measure, I also disabled the onboard LED so you don't see that current in the Person Detected interval.
Here is a zoomed in view of the first MQTT interval:
Old configuration
New Configuration
It's not totally clear from the pictures, but because there is so much activity in the 800 ms MQTT interval the average current only drops from 14 mA in the old configuration to 6.5 mA in the new configuration. Need to think about what all that activity is.
In summary, almost a 4X reduction in power on average overall using the new configuration. As I learn more and understand what all this activity correlates to, I'm sure that I can do substantially better in power reduction.
I'm impressed with the flexibility in the board and module designs and the ease of configurability with the toolset. I just need to get smarter ...