This is a project I have worked on as part of my master’s degree. It is an extension to a project focused on designing a low-cost, reliable, and low-power intelligent vehicle counter and classification sensor (iVCCS) system in which the sensor exploits the physical phenomenon of magnetic field disturbance caused by ferrite materials in the body of a vehicle. The sensor relies on a triaxial magnetometer to measure magnetic field before measurements are transmitted to processing platform. Previous work (i.e., first generation iVCCS [iVCCS 1stG]), proved the design concept with high accuracy and reliability. A second generation iVCCS (iVCCS 2ndG) was designed around a more powerful, 32-bit microcontroller equipped with an on-die digital signal processing (DSP) core. Special attention to power consumption led to the development of the new iVCCS 2ndG platform.

In this project I developed several algorithms to optimize power consumption of iVCCS based on an event-driven methodology wherein a control block orchestrates the work of various components and subsystems. Data buffering and triggered vehicle detection techniques were developed to reduce duty cycle of corresponding components (e.g., microSD card, magnetometer, and processor execution). A sleep mode is also incorporated and activated by an artificial intelligence-enabled, reinforcement learning algorithm that utilizes the field environment to select proper processor mode (e.g., run or sleep) relative to traffic flow conditions. Sensor life was extended from 48 hours to more than 200 days when leveraging 2300 mAh battery along with algorithms and techniques introduced in this thesis.

System Overview

iVCCS 2ndG is a fully autonomous and low-power sensor. The updated iVCCS is carefully crafted in a compact design (45×30×6 mm) and combines high performance, energy-efficient components equipped with a power management subsystem for minimizing consumption while maintaining accurate vehicle count, logging, and speed estimation. figure 1 shows the system board and its primary components. A battery gauge monitors battery capacity and nano-power load switches placed at the power lines of certain energy-hungry sensor components (e.g., RF wireless module, GPS receiver, SD card and others) are reported to the microcontroller unit (MCU).

The sensor is built around an ultra-low-power platform from STMicroelectronics with an ARM CORTEX-M0+ 32-bit RISC core STM32L071. Kionix KMX62 is a six degrees-of-freedom magnetometer/accelerometer inertial sensor system that senses changes in the magnetic flux of the earth’s surface when vehicles enter the vicinity. KMX62 is a reliable and power-efficient sensor, consuming 395 μA at high-resolution mode and 1 μA in standby mode. Magnetometer full-scale range is ±1200 μT, and digital bit depth is 16 bits, resulting in a magnetic sensitivity of ±0.0366 µT, which was ±0.1 µT in iVCCS 1stG.

The system integrates a microSD card slot used for raw data acquisition (e.g., vehicle magnetic signature and accelerometer data) and timestamps of vehicle arrival and departure, as well as status messages. The microSD card is connected to the microcontroller through serial peripheral interface (SPI). An on-board 64 Mb serial NOR Flash memory serves as a secondary storage medium. Macronix’s MX25R64 is an ultra-low-power CMOS flash memory with minimum of 100,000 erase/program cycles and 20-year data retention; it features a typical standby current of 5 µA, a maximum 4 mA read current, and 6 mA write current.

Figure 1. Overview of the iVCCS components.

System Algorithms

Here, techniques were developed to further optimize sensor operations utilizing interrupts instead of a polling methodology for reducing duty cycle.

Data Buffering Technique

microSD cards are energy inefficient and counter intuitive to the low power paradigm due to the fact that they simply dump data and messages directly to the card. According to SanDisk microSD card specifications, Read and Write procedures can take up to 100 mA in current consumption. Notably, it is impractical to turn the card on and off for each detected vehicle due to the time delay required for initializing the card each time it is powered on. Specifications also refer to an automatic sleep feature wherein the cards enter sleep mode when commands have not been received within 5 ms. Although cards consume 350 µA in this mode, this amount is inefficient. On-board ultra-low-power flash memory is used to buffer data before shifting it to the microSD card, primarily because it excels in energy efficiency and read/write performance when compared with SD cards. As such, this type of memory is suitable for instantaneous data logging.

Triggered Vehicle Detection

Typically, and in accordance with the configured data rate, the magnetometer regularly interrupts the microcontroller when a new sample is acquired in the buffer (i.e., Data Ready Interrupt [DRI]). Desired behavior interrupts MCU only when a vehicle is approaching and triggers the detection algorithm. In addition to DRI, KMX62 magnetometer has two other interrupts, Magnetometer Motion Interrupt (MMI), and Buffer Full Interrupt (BFI). MMI is issued when the difference between two consecutive samples on one axis reaches a programmed threshold in a specific direction (e.g., increasing or decreasing) and remains above that threshold for a specified number of samples (i.e., time). KMX62 also has a buffer capable of holding 64 samples of components x, y, and z.

Figure 2. KMX62 MMI and BFI interrupts operation.

Buffer functions in triggered mode. Given that a physical interrupt is caused by a digital engine (e.g., magnetometer or accelerometer), a trigger event is asserted and SMP_TH number of samples prior to the event are retained. Sample collection continues until the buffer is full. Data is reported in chronological order. figure 2 illustrates this mechanism. MMI is configured to trigger the buffer, and a BFI is routed to the MCU through one of the GPIOs. SMP_TH is set to 63, which causes KMX62 to immediately interrupt the MCU after the first sample received at the event of an MMI interrupt when a vehicle approaches.

Communication Scheme

The primary role of the RF front-end in this system is to report data (i.e., count and timestamps) to an access point (AP). This function is completed once each day, typically at midnight. However, the system is also capable of interacting with user requests. Notably, the ZigBee module is one of the most power-consuming units on board, and constantly turning it on will quickly deplete the battery. MCU is not required to use RF interface, except for initial status reporting after sensor is initialized and data reporting at midnight. To accommodate user/AP requests, MCU must activate the ZigBee module for one minute, during which time it sends a status message reporting battery charge level and number of vehicles counted. Given that a command is received within this minute, the timer is reset, allowing for additional commands. If none are received, RF module is shut down.

System Level Power Consumption Analysis

The system’s power consumption is empirically analyzed by dividing the sensor’s one-hour cycle into states, and then measuring the amount of current drained in each state. Figure 3 depicts sensor current consumption for various states.

Figure 3. Current consumption at various states.

Average current for one hour is found to be 4.48 mA, resulting in 411 hours of operation on a 2300 mAh battery with up to an 80% derating factor.

Reinforcement Learning for iVCCS

Although power consumption was targeted for enhancement by incorporating the ARM Cortex-M0 microprocessor sleep mode, doing so caused misdetections and/or double counting for vehicles traveling with less than a 2-second following distance. This is attributed to a long wakeup time from sleep mode once a passing vehicle was detected. Nevertheless, in a low-traffic situation where vehicle following distance was more than 5 seconds, sleep mode is expected to perform flawlessly and to conserve power. A dynamic power management scheme is planned to manage this process.

The proposed system is modeled as a Markov Decision Process with four-state space: High-Power High-Traffic (HPHT), High-Power Low-Traffic (HP-LT), Low-Power High Traffic (LP-HT), and Low-Power Low-Traffic (LP-LT). Figure 4 shows the system state transition diagram. Solid arrows represent agent transitions. Dashed arrows represent environment transitions. The agent (i.e., iVCCS) is not penalized for environment transitions.

Figure 4. State transition diagram.

The agent can perform two actions, namely switching to high-power mode or to low-power mode. Given that the agent takes action, a corresponding reward is given and a new experience (e.g., tuple of state, action, reward <s, a, r>) is formed.

The system’s power consumption was analyzed with the RL algorithm employed, and the average current for one hour was found to be 3.71 mA. Given a 2300 mAh battery, battery life is extended to 496 hours.

Further Details

For more information on the project, readers are encouraged to refer to [1], [2].


  1. Ultra-Low Power IoT Traffic Monitoring System Muhammad, Siraj, Refai, Hazem, and Blakeslee, Matthew In 2018 IEEE 88th Vehicular Technology Conference (VTC 2018-Fall) 2018 [Abstract] [HTML] [PDF]
  2. Intelligent Power Aware Algorithms for Traffic Sensors Muhammad, Siraj 2018 [Abstract] [HTML] [PDF]