Operation of ZMOD4410 Sensor From LP mode to ULP mode at Run Time

Hello Everyone!!!!

I want to know the procedure how I can change the operation of ZMOD sensor from LP mode to ULP mode at run time?

By default my application starts in LP mode, which works I am getting data from ZMOD sensor my application have the feature so that user I can change the mode of operation of sensor

whether he/she wants to run the sensor to operate in LP mode or ULP mode.

I have included both LP and ULP mode precompiled libraries in my project

So far to accomplished this task what I did that when a command is received from user for ULP mode:

void ZMOD4410_ULPMODE(void)
{
    nrf_gpio_pin_clear(TOGGLE_PIN);
    nrf_delay_ms(10);
    nrf_gpio_pin_set(TOGGLE_PIN);
    dev.i2c_addr = ZMOD4410_I2C_ADDR;
    dev.pid = ZMOD4410_PID;
    dev.init_conf = &zmod_sensor_type[INIT];
    dev.meas_conf = &zmod_sensor_type[MEASUREMENT];
    dev.prod_data = prod_data;
    api_ret = zmod4xxx_read_sensor_info(&dev);
    if (api_ret)
    {
      __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Communication with ZMOD Sensor failed\n");
      error_handle_zmod();
    }
    
    /* Preperation of sensor */
    api_ret = zmod4xxx_prepare_sensor(&dev);
    if (api_ret)
    {
      __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Failed to Prepare ZMOD Senosr\n");
      error_handle_zmod();
    }
    /* One time initialization of the algorithm */
    lib_ret = init_iaq_2nd_gen_ulp(&algo_handle_ULP);
    if (lib_ret)
    {
      __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Hardware Initialization Failed\n");
      error_handle_zmod();
    }
}

and for LP mode:

void ZMOD4410_LPMODE(void)
{
    nrf_gpio_pin_clear(TOGGLE_PIN);
    nrf_delay_ms(10);
    nrf_gpio_pin_set(TOGGLE_PIN);
    dev.i2c_addr = ZMOD4410_I2C_ADDR;
    dev.pid = ZMOD4410_PID;
    dev.init_conf = &zmod_sensor_type[INIT];
    dev.meas_conf = &zmod_sensor_type[MEASUREMENT];
    dev.prod_data = prod_data;
    api_ret = zmod4xxx_read_sensor_info(&dev);
    if (api_ret)
    {
      __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Communication with ZMOD Sensor failed\n");
      error_handle_zmod();
    }
    
    /* Preperation of sensor */
    api_ret = zmod4xxx_prepare_sensor(&dev);
    if (api_ret)
    {
      __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Failed to Prepare ZMOD Senosr\n");
      error_handle_zmod();
    }
    /* One time initialization of the algorithm */
    lib_ret = init_iaq_2nd_gen(&algo_handle);
    if (api_ret)
    {
      __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Failed to Initiaze Alogorithm LP Mode\n");
      error_handle_zmod();
    }
}

NOTE: TOGGLE_PIN is for PowerON Reset for the sensor.
    while(1)
    {
      switch(device_state)
      {
        case CONTINUOUS_STATE:
        case ONE_MINUTE_STATE:
        if ( Triger_sensor_reading == true )
        {
          ZMOD_SENSOR_OPERATION_LP();
          Triger_sensor_reading = false;
        }
        break;
        
        case FIVE_MINUTE_STATE:
        if (Triger_sensor_reading == true )
        {
          getTempANDhumi();
          ZMOD_SENSOR_OPERATION_ULP();
          Triger_sensor_reading = false;
        }
        break;

        default:
        break;
      }
    }

As you can see Triger_sensor_reading flag is for when to trigger sensor measurement.
The problem I am facing is that when changing from LP to ULP mode, when the algorithm calculates values after each measurement the values continually rising.
What could be the possible reason for this ?
THANKS

  • Hi Muhammad during run time, it is not recommended to switch between the modes. They are designed to operate continuously. BR JE_REN

  • Okay I understand!!!
    Our application have multiple devices which will be sending data to the main device and the main device
    will then processed ZMOD sensors data.
    So at start we want high data rate when we are installing the devices the reason for doing this is that we want to make sure every device sending data
    correctly
    Once we verify everything works fine, then we want to change the operation of sensor from Continuous
    mode to ULP mode.
    Also the reason for doing this is that It will be hard for us to flash the firmware to each device again for ULP mode.
    In short at start we need high sample rate from sensors after verification we want low sample rate from sensors so to avoid this overhead of flashing to two firmwares.
    Therefore we want to change the mode from continuous to ULP mode during runtime. Occasionally, we might need to go back to continuous mode so we want the ability to change modes during runtime.