OneWire Library current consumtion

Hi,

I'm using the 1-Wire library from Zephyr (https://docs.zephyrproject.org/latest/hardware/peripherals/w1.html) to access a DS18B20 temperature sensor. According to the description I have to use the UART interface to communicate with the sensor.

The code, sensor and the communication works fine, my problem is the current consumption of +800µA. I'm sure the reason of the higher current is the device tree, not the sensor, cause without attaching the sensor, the current stays high. I think the UART interface is always on, because if I'm not reading the sensor I have the high current too.

Do you have any solution or hint what I can change or try?
I appreciate all your help. My settings are NRF52840, NCS2.6.1

Thanks an Best Regard,

Manuel

My UART in my base.dts

&uart0 {
	compatible = "nordic,nrf-uarte";
	current-speed = <115200>;
	status = "okay";
	pinctrl-0 = <&uart0_default>;
	pinctrl-1 = <&uart0_sleep>;
	pinctrl-names = "default", "sleep";
};

I've created an overlay with the following settings:

&uart0 {
	w1_0: w1-zephyr-serial-0 {
		compatible = "zephyr,w1-serial";
		#address-cells = <1>;
		#size-cells = <0>;
		status = "okay";

		ds18b20 {
			compatible = "maxim,ds18b20";
			family-code = <0x28>;
			resolution = <12>;
			status = "okay";
		};
	};
};

My pin control for the UART looks like this:

&pinctrl {
	uart0_default: uart0_default {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 6)>,
				<NRF_PSEL(UART_RX, 0, 8)>;
		};
	};

	uart0_sleep: uart0_sleep {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 6)>,
				<NRF_PSEL(UART_RX, 0, 8)>;
			low-power-enable;
		};
	};
};

Parents
  • Have you enabled CONFIG_PM=y and CONFIG_PM_DEVICE=y in your prj.conf ?

    UART driver and nrfx in that sdk version implements the power management API, so if your system is going to sleep and the power managment is enabled, then the UART power consumption should go down.

  • Hi Shusheel,

    thank you for that great hint. I have tried that and enabled both. That still alone wasn't the solution, current was still high, but I've also suspended UART via pm_device_action_run() after the measurement. With that it works!

    static const struct device *dev_uart = DEVICE_DT_GET(DT_NODELABEL(uart0));
    .........
    pm_device_action_run(dev_uart, PM_DEVICE_ACTION_RESUME);
    // read temperature of onewire sensor
    pm_device_action_run(dev_uart, PM_DEVICE_ACTION_SUSPEND);

Reply
  • Hi Shusheel,

    thank you for that great hint. I have tried that and enabled both. That still alone wasn't the solution, current was still high, but I've also suspended UART via pm_device_action_run() after the measurement. With that it works!

    static const struct device *dev_uart = DEVICE_DT_GET(DT_NODELABEL(uart0));
    .........
    pm_device_action_run(dev_uart, PM_DEVICE_ACTION_RESUME);
    // read temperature of onewire sensor
    pm_device_action_run(dev_uart, PM_DEVICE_ACTION_SUSPEND);

Children
No Data
Related