<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Power I2C Device through GPIO</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87617/power-i2c-device-through-gpio</link><description>Hi, 
 I have builded a circuit with a nRF52DK and a mpu9250 IMU. If I power the Sensor with VDD the Zephyr driver and all of the Software performs well and the values from the IMU are displayed correctly in my console. Now I have Problems with powering</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 21 Oct 2022 10:23:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87617/power-i2c-device-through-gpio" /><item><title>RE: Power I2C Device through GPIO</title><link>https://devzone.nordicsemi.com/thread/391835?ContentTypeID=1</link><pubDate>Fri, 21 Oct 2022 10:23:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3dfc294-f09b-43bf-a67e-6d7383b591c7</guid><dc:creator>JonasGel</dc:creator><description>&lt;p&gt;Many Viewer on this Ticket, so this is my solution:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Enable regulator in prj.conf&amp;nbsp;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_REGULATOR=y&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;edits in Devicetree:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	imu_pwr: imu-pwr-ctrl {
			compatible = &amp;quot;regulator-fixed&amp;quot;;
			label = &amp;quot;imu-pwr-ctrl&amp;quot;;
			regulator-name = &amp;quot;imu-pwr-ctrl&amp;quot;;
			enable-gpios = &amp;lt;&amp;amp;gpio0 16 GPIO_ACTIVE_HIGH&amp;gt;;
			regulator-boot-on;
		};&lt;/pre&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;vin-supply in Devicetree:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;lsm6dso@6a {
            compatible = &amp;quot;st,lsm6dso&amp;quot;;
            reg = &amp;lt;0x6a &amp;gt;;
            label = &amp;quot;LSM6DSO&amp;quot;;
			vin-supply = &amp;lt; &amp;amp;imu_pwr &amp;gt;;
        };    &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;with this edits, the devices are being powered and successfully initialized during the boot process.&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power I2C Device through GPIO</title><link>https://devzone.nordicsemi.com/thread/377649?ContentTypeID=1</link><pubDate>Tue, 19 Jul 2022 13:25:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd333642-3867-4e25-8ed4-0efbc0f157f4</guid><dc:creator>JonasGel</dc:creator><description>&lt;p&gt;Hi Einar,&amp;nbsp;&lt;br /&gt;yes my problem is/ was utilizing the drivers. I have it working now using:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;vin-supply = &amp;lt; &amp;amp;imu-power-ctrl&amp;gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;or&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;supply-gpios&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &amp;lt; &lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;gpio0 &lt;/span&gt;&lt;span&gt;20&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;GPIO_ACTIVE_HIGH&lt;/span&gt;&lt;span&gt; &amp;gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Is there a good Tutorial on how to write a propper devicetree implementation?&amp;nbsp;&lt;br /&gt;and is it possible in the devicetree setting a delay between powering the sensor and read the sensor via i2c?&lt;br /&gt;Best regards, Jonas&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power I2C Device through GPIO</title><link>https://devzone.nordicsemi.com/thread/367109?ContentTypeID=1</link><pubDate>Tue, 10 May 2022 09:07:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bafebed-5ba5-40ec-8d4d-2161d97ac866</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Ok, so your issue isn&amp;#39;t actually powering the sensor through gpio, but rather utilizing the driver?&lt;/p&gt;
&lt;p&gt;Can you elaborate on how you&amp;#39;re using this driver and the behavior you&amp;#39;re seeing?&lt;/p&gt;
&lt;p&gt;How does your setup compare to what is discussed in&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/64653/thingy52-zephyr-rtos-and-sensor-mpu6060-sample-not-working"&gt;this case&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;-Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power I2C Device through GPIO</title><link>https://devzone.nordicsemi.com/thread/367007?ContentTypeID=1</link><pubDate>Mon, 09 May 2022 15:36:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bc8f6a2-e914-4997-bbd6-59efd05eba79</guid><dc:creator>JonasGel</dc:creator><description>&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Bildschirmfoto-2022_2D00_05_2D00_09-um-17.09.43.png" /&gt;&lt;br /&gt;I would like to first set&amp;nbsp;GPIO 13 to high (power source) and after that (with 10ms delay) enable GPIO pin 9 &amp;amp; 11 (numbers are from a connector ) and in my breadboard example P0.23 as powering GPIO and P0.26 + P0.27 as I2c Bus.&amp;nbsp;&lt;br /&gt;In the meantime i&amp;#39;ve tested to write it with the zephyr driver (&amp;nbsp;&lt;span&gt;#include&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;lt;drivers/i2c.h&amp;gt;&amp;nbsp;&lt;/span&gt;) without the Zephyr MPU9250 driver and I can read the sensor data while powering it from a GPIO.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This works (without driver - only hardcoded adresses)&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	const struct device *gpio_dev1;
	gpio_dev1 = device_get_binding(GPIO_DEV_NAME1);

	if (!gpio_dev1) {
		printk(&amp;quot;Cannot find %s!\n&amp;quot;, GPIO_DEV_NAME1);
		//return;
	}

	ret = gpio_pin_configure(gpio_dev1, VDD_PIN1, GPIO_OUTPUT_ACTIVE);	
	if (ret &amp;lt; 0) {
		//return;
	}

	//nrfx_gpiote_out_set(VDD_PIN1);
	gpio_pin_set(gpio_dev1, VDD_PIN1, 1);

	printk(&amp;quot; Voltage on\n&amp;quot;);
	k_sleep(K_MSEC(MEASURE_INTERVAL*1000));

	/******************************************************************
	* i2c get binding
	*/
	const struct device *dev_i2c = device_get_binding(&amp;quot;i2c0&amp;quot;);
	if (dev_i2c == NULL) {
		printk(&amp;quot;I2C Device not bounded\n&amp;quot;);
	}

	/******************************************************************
	* i2c read funktion
	*/
	//err = i2c_read(dev_i2c, &amp;amp;i2c_gelesen,2, 0x76);

	err= i2c_burst_read(dev_i2c,0x68,0x43,sensorData,6);
	if (err != 0) {
			printk(&amp;quot;Fehler beim Auslesen\n&amp;quot;);
	}

	printk(&amp;quot;Sensor Data: %u %u %u %u %u %u \n&amp;quot;,sensorData[0],sensorData[1],sensorData[2],sensorData[3],sensorData[4],sensorData[5]);
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;My goal is, to do this with the zephyr included mpu9250 driver. (Any communication with i2c should be done after setting the gpio power).&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I think it could be erroring because i have the devices in the board overlay? maybe it does configure these at startup and cant find them because they aren&amp;#39;t powered?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;amp;i2c0 {

	scl-pin = &amp;lt;25&amp;gt;;
	sda-pin = &amp;lt;24&amp;gt;;
	status = &amp;quot;okay&amp;quot;;
	/* 
	mpu9250@68 {
		compatible = &amp;quot;invensense,mpu9250&amp;quot;;
		gyro-sr-div = &amp;lt;0&amp;gt;;	//gyrscope sample rate divider
		gyro-dlpf = &amp;lt;10&amp;gt;;	//digital low pass filter frequency
		gyro-fs = &amp;lt;2000&amp;gt;;	//full scale of gyroscope. (Unit - DPS).
		accel-fs = &amp;lt;8&amp;gt;;		//full scale of accelerometer
		accel-dlpf = &amp;quot;10.2&amp;quot;;
		reg = &amp;lt;0x68&amp;gt;;
		label = &amp;quot;MPU9250&amp;quot;;
		status = &amp;quot;ok&amp;quot;;
	
	};&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power I2C Device through GPIO</title><link>https://devzone.nordicsemi.com/thread/367002?ContentTypeID=1</link><pubDate>Mon, 09 May 2022 15:01:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23571e17-4d44-48db-9f4c-4e534cdca441</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hi again&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not entirely sure what you mean here. How would you get around the initial power spike when booting your sensor by disabling the i2c bus? Am I missing something?&lt;/p&gt;
&lt;p&gt;Have you tried measuring how much current your sensor module draws on boot? Would be interesting to know for debugging.&lt;/p&gt;
&lt;p&gt;-Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power I2C Device through GPIO</title><link>https://devzone.nordicsemi.com/thread/366853?ContentTypeID=1</link><pubDate>Mon, 09 May 2022 08:34:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3b5e8ea-b6f1-4c78-a901-59297f0aa7dc</guid><dc:creator>JonasGel</dc:creator><description>&lt;p&gt;Good Morning, and thanks for your Reply. The GPIO as Power source design is predetermined from a peripheral Sensor and power-source board, so unfortunately i cant change this. I think it&amp;#39;s more a config Problem. I tested it also with an TE MS5607 Pressure Sensor with only 1,3mA Current Consumption (below max 4mA in Standard GPIO mode). And this i2c sensor circuit works fine with a TI CC2640.&amp;nbsp;&lt;br /&gt;to handle this initial power spike i used this 2 second sleep until i bind the i2c Sensor. But i think the error is triggered earlyer beacause of now power on the bus in the starting time(?) Therefore i want to disable the bus at start and enable it after the Sensor and bus have enough Power.&amp;nbsp; So maybe is there an example code for powering some sensor with a zephyr driver through&amp;nbsp;GPIO (and enable/ disable it at runtime for Power efficiency)?&amp;nbsp;&lt;br /&gt;Best Regards,&lt;br /&gt; Jonas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power I2C Device through GPIO</title><link>https://devzone.nordicsemi.com/thread/366754?ContentTypeID=1</link><pubDate>Fri, 06 May 2022 14:08:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d26d5c97-e893-4fa7-94e8-9f1dd1a9c939</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hello&lt;/p&gt;
&lt;p&gt;The behavior you&amp;#39;re seeing is likely the GPIO struggling to supply the initial power spike required when the sensor is turned on. The GPIO should be able to power the sensor during normal operation, but the current required at boot could be problematic. It might help to configure the GPIO pin as GPIO_OPEN_SOURCE, maybe.&lt;/p&gt;
&lt;p&gt;Can you elaborate on the issue you have with the TWI bus?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>