<?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>I2C samples for nRF9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86388/i2c-samples-for-nrf9160</link><description>Hi, 
 I had previously asked about SPI interfacing of the RFID card reader and I was successful in creating a custom application using connect SDK 1.5.1. 
 But according to our latest upgrade, we plan to use RFID card readers using I2C communication.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 05 Apr 2022 08:37:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86388/i2c-samples-for-nrf9160" /><item><title>RE: I2C samples for nRF9160</title><link>https://devzone.nordicsemi.com/thread/361758?ContentTypeID=1</link><pubDate>Tue, 05 Apr 2022 08:37:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c7d6084-677e-4b3a-aa65-83f3ee1141b2</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which header and include files are missing?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have added additional source files or include directories to the project you typically need to update the CMakeLists.txt file to include these additional files (unless it is a standard library, then you just need to enable it in the project configuration).&amp;nbsp;&lt;/p&gt;
[quote user="finnyphilipbiju"]Can open this sample which Jupyter had shared, directly as an existing application or create a new application?[/quote]
&lt;p&gt;You can use the &amp;quot;Add an existing application&amp;quot; option in VSCode, yes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C samples for nRF9160</title><link>https://devzone.nordicsemi.com/thread/361363?ContentTypeID=1</link><pubDate>Sun, 03 Apr 2022 08:24:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f19fa7f4-34bd-43af-b82d-363e50716b56</guid><dc:creator>Finny Philip Biju</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the reply. But I need to read the tag ID using the mfrc522 RFID scanner. I tried modifying the main code. But I am getting error messages and it says the header and includes files are missing. should I need to place the includes directory separately? Can open this sample which Jupyter had shared, directly as an existing application or create a new application?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C samples for nRF9160</title><link>https://devzone.nordicsemi.com/thread/360943?ContentTypeID=1</link><pubDate>Thu, 31 Mar 2022 08:16:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d244805-371b-4972-819d-6baf6b65af22</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can use the sample shared by Jupyter, I believe it is the same one shared by one of my colleagues &lt;a href="https://github.com/sigurdnev/sdk-nrf/tree/main/samples/nrf9160/i2c_scanner"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Setting up I2C is actually quite simple in the nRF Connect SDK, and can be summarized like this:&lt;/p&gt;
&lt;p&gt;1) Set up the config (in prj.conf):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;CONFIG_I2C=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;2) Add the right include folder&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;drivers/i2c.h&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;3) Get a binding to your device&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define MY_I2C &amp;quot;I2C_1&amp;quot;
const struct device * i2c_dev;

// Get the device binding to the I2C peripheral
i2c_dev = device_get_binding(MY_I2C);
if (i2c_dev == NULL) {
	printk(&amp;quot;Unable to bind %s!\n&amp;quot;, MY_I2C);
	return;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;4) Use the driver&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Scan the I2C bus for any connected slaves, and print out the address if found
for(uint8_t i2c_addr = 1; i2c_addr &amp;lt;= 127; i2c_addr++){
	uint8_t i2c_cmd = 1;
	int error = i2c_write(i2c_dev, &amp;amp;i2c_cmd, 1, i2c_addr);
	if(error == 0){
		printk(&amp;quot;I2C slave found on address %x\n&amp;quot;, i2c_addr);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C samples for nRF9160</title><link>https://devzone.nordicsemi.com/thread/360686?ContentTypeID=1</link><pubDate>Wed, 30 Mar 2022 08:34:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78002154-c156-46e1-aac3-5d04f125ffc9</guid><dc:creator>Jupyter1336</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1715.i2c_5F00_scanner.zip"&gt;devzone.nordicsemi.com/.../1715.i2c_5F00_scanner.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I hope the devs stop being stubborn and start making active working examples(FOR EVERY NEW VERSION). This is mine for 1.5.0 should work&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>