This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Powering sensor through GPIO

Hello all, 

In order to optimize my power design, I want to power my sensors though GPIO pin on nrf52832 and toggle the pin when I need to use them.

I have two sensors on one twim bus. I configured a GPIO in the following way:

		gpio_init();
	
		nrf_drv_gpiote_out_config_t config = NRFX_GPIOTE_CONFIG_OUT_SIMPLE(0);
		err = nrf_drv_gpiote_out_init(10, &config);
		APP_ERROR_CHECK(err);


A timer is fired every 10 seconds and in the handler I want to set the pin, to read from thr first sensor an clear the pin:

        nrf_gpio_pin_set(10);
	
		*temp = hts221_read_temperature();
		*hum = hts221_read_humidity();
	
	//	while(!m_xfer_done);
	
		nrf_gpio_pin_clear(10);

The case is that when I measure voltage on pin 10, the pin is never cleared. When I disconnect the sensors, the pin is cleared immediately. When I connect the sensors to any other pin, for example pin 9, this pin is set high automatically, even it is not configured. 

What is the proper way to control a GPIO?

Related