<?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>Setting up devicetree for I2C device that has address changed</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112611/setting-up-devicetree-for-i2c-device-that-has-address-changed</link><description>I&amp;#39;m currently working on a project that uses the MLX90640 IR sensor. By default, this device has an I2C address of 0x33, but it can be set up with one of 127 different I2C addresses. 
 This is how I have the device tree set up: 
 
 What I&amp;#39;m trying to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Jul 2024 12:42:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112611/setting-up-devicetree-for-i2c-device-that-has-address-changed" /><item><title>RE: Setting up devicetree for I2C device that has address changed</title><link>https://devzone.nordicsemi.com/thread/491840?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2024 12:42:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c820486-cb4b-436e-9b4b-5001c7e882bd</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Mike,&lt;/p&gt;
&lt;p&gt;I think the best approach would be to use&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.3.0/page/zephyr/hardware/peripherals/i2c.html#c.i2c_transfer"&gt;i2c_transfer&lt;/a&gt;() instead of i2c_transfer_dt(), since the former takes the address as an argument instead of using the address that is specified in the devicetree node.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting up devicetree for I2C device that has address changed</title><link>https://devzone.nordicsemi.com/thread/491706?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2024 23:40:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ab0fe6f-7c06-4f6a-811a-0948fb2073d1</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Jared,&lt;/p&gt;
&lt;p&gt;Sorry - I probably should have provided more detail.&lt;/p&gt;
&lt;p&gt;I am trying to write some firmware that enables me to change the I2C address on a batch of these MLX90640 sensors, doing this one sensor at a time.&amp;nbsp; I have about 20 in my application, and I need them all to be unique so I can access the info of each of them over the same I2C bus.&lt;/p&gt;
&lt;p&gt;So, sequence is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I connect one sensor up to my DK&lt;/li&gt;
&lt;li&gt;Check that I can access it via is default address (0x33)&lt;/li&gt;
&lt;li&gt;Take the updated address as input via UART&lt;/li&gt;
&lt;li&gt;Reconfigure the sensor to that new I2C address&lt;/li&gt;
&lt;li&gt;Then check that I can access it via the new address.&lt;/li&gt;
&lt;li&gt;I then remove that sensor from the I2C bus, and connect up the next sensor&lt;/li&gt;
&lt;li&gt;Then repeat steps 1-6 with the next sensor&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So, I don&amp;#39;t want to have to rebuild everything between steps 4-5 and 5-6.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve not actually tried this approach as yet (still waiting for the sensors to arrive), but as I understand it, this code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static const struct i2c_dt_spec mlx90640_i2c = I2C_DT_SPEC_GET(I2C0_NODE);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Will simply populate the values of the i2c_dt_spec structure with the device and addr info from the device tree.&amp;nbsp; So, in theory, when I get to step 5, I just need up update the value of&amp;nbsp;mlx90640_i2c.addr with the new address (e.g. 0x40) and I should then be able to read/write to it.&lt;/p&gt;
&lt;p&gt;Does that sound like it will work?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting up devicetree for I2C device that has address changed</title><link>https://devzone.nordicsemi.com/thread/491615?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2024 13:08:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c0bc888-1a33-4cd9-9e60-10840aef9ea4</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure I understand the question. The device node label will be updated once you rebuild your project.&lt;/p&gt;
&lt;p&gt;Are you getting any build errors?&lt;/p&gt;
&lt;p&gt;Please elaborate on the question.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>