MODBUS and serial disable

We use custom board with NRF52840 and a MODBUS CO2 sensor. We are struggling with power consumption when the serial is enabled. The goal is to take measurements and then put the board to sleep, after a certain time, wake board up and take new measurements. Currently, the idle power consumption is about 1.2 mA. When I disabled the serial in the config file, we got the power consumption down to 300 µA. However, MODBUS requires the serial. Is it possible to disable the serial before putting the board to sleep and reinitialize it after waking up so that MODBUS continues to work?

  • Hi

    Which SDK are you using? 

    In Zephyr you can not easliy disable a device so I would suggest using Device Power Management  and PM_DEVICE_ACTION_SUSPEND 

    A idle current of 300µA sounds a bit high, I would suspect that you have some floating pins or maybe the HF crystal in used. 

    Regards

    Runar

  • NCS 2.6.0 and if I try to suspend and wake UART, then after wake-up I get:  MODBUS error -116 -- then only reset makes MODBUS working again.

    How to check what is using HFCLK? We are using BLE for communication, but that is also suspended when board goes to sleep.

  • I have to check a bit, it's modbus RTU you are using right? 

    Regards

    Runar

  • Yes .. I toke MODBUS RTU Client Sample as base for my code. I tried modbus_disable before sleep and reinit after wake, but it does still not communicate anymore (the error -116 should be timeout).

    I have right now only one DK board and I can't try the MODBUS RTU Server and Client sample with UART sleep -- I think there would be the same problem.

  • I'm just playing a bit around with the Modbus RTU client and server sample using two DKs. I don't have access to my PPK today but I see no issue when I add the following

    pm_device_action_run(uart,PM_DEVICE_ACTION_SUSPEND);
    
    k_msleep(sleep);
    
    pm_device_action_run(uart,PM_DEVICE_ACTION_RESUME);

    Log

    Client side
    [00:00:15.360,961] <inf> mbc_sample: Coils state 0x07
    [00:00:20.388,000] <inf> mbc_sample: Coils state 0x00
    server side
    [00:00:18.276,062] <inf> mbs_sample: Coil write, addr 2, 1
    [00:00:23.289,672] <inf> mbs_sample: Coil read, addr 0, 1
    [00:00:23.289,672] <inf> mbs_sample: Coil read, addr 1, 1
    [00:00:23.289,703] <inf> mbs_sample: Coil read, addr 2, 1
    [00:00:23.303,222] <inf> mbs_sample: Coil write, addr 0, 0
    [00:00:23.303,222] <inf> mbs_sample: Coil write, addr 1, 0
    [00:00:23.303,222] <inf> mbs_sample: Coil write, addr 2, 0
    [00:00:28.316,864] <inf> mbs_sample: Coil read, addr 0, 0
    [00:00:28.316,864] <inf> mbs_sample: Coil read, addr 1, 0
    [00:00:28.316,894] <inf> mbs_sample: Coil read, addr 2, 0
    [00:00:28.329,193] <inf> mbs_sample: Coil write, addr 0,

Related