<?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>TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70402/twi-scanner-i2c-address-is-1-bit-wrong</link><description>I&amp;#39;m using &amp;lt;TWI Scanner&amp;gt; example on nRF52 DK to find my sensor&amp;#39;s address. 
 According to the sensor datasheet, the sensor&amp;#39;s address is 0x21. However, &amp;lt; TWI Scanner &amp;gt; finds the address at 0x20. 
 Any idea, please?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Nov 2021 14:35:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70402/twi-scanner-i2c-address-is-1-bit-wrong" /><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/338219?ContentTypeID=1</link><pubDate>Tue, 09 Nov 2021 14:35:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bc32e70-b85e-4c25-8e5a-3e2a5051d1bf</guid><dc:creator>Sunilksi</dc:creator><description>&lt;p&gt;Hello All, I am also facing the same issue so is it possible to provide the code snippet ?&lt;/p&gt;
&lt;p&gt;Your early help will be greatly appreciated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/295473?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2021 04:06:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95af7323-f9b9-4e72-bdc7-48d841f385ce</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;&lt;strong&gt;Problem Solved!&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The code doesn&amp;#39;t work due to the slave device and time delay issue. The sensor I&amp;#39;m using requires:&lt;/p&gt;
&lt;p&gt;1) reset--&amp;gt;send continuous mode command--&amp;gt;read data (I didn&amp;#39;t add reset command before)&lt;/p&gt;
&lt;p&gt;2) meanwhile, for each&amp;nbsp;read/write command, we must add a time delay (e.g. 5 ms) after the command&lt;/p&gt;
&lt;p&gt;Thanks to everyone who helped me before! Cheers&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/291004?ContentTypeID=1</link><pubDate>Mon, 25 Jan 2021 11:27:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84fae385-f767-42e3-8870-97cc26bca8eb</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="StevenW807"]Since I&amp;#39;m new to nRF52, does that mean it&amp;#39;s impossible to get SDP31 measurements via nRF52 over TWI, pls?[/quote]
&lt;p&gt;No, it does not mean that. Almost any I2C device should be compatible with the nRF52, it is just that you need to write the driver for it yourself. That should be built on top of the TWI driver or some of the TWI libraries in the nRF5 SDK. It is generally the case that you have to do this yourself.&lt;/p&gt;
[quote user="StevenW807"]What modifications should I make to let nRF52 get SDP31 measurements over TWI, pls?&amp;nbsp;[/quote]
&lt;p&gt;I have no experience with tee SDP31. But if you have a driver for the nRF51 which is fairly recent, then porting this to a new nRF5 SDK supporting the nRF52 should be quite simple. We still need to figure out the problem of basic I2C/TWI communication first, though. As mentioned I have ordered the devices and will have a look at that once I get it (it should be right around the corner now).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/290844?ContentTypeID=1</link><pubDate>Sat, 23 Jan 2021 07:09:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0515f0b-37d5-490c-a369-05e81d4a4ba3</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;Hi, Einar. From &lt;a href="https://github.com/Sensirion/info"&gt;Sensirion company official GitHub&lt;/a&gt;, it seems like they only support nRF51.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I asked them that SDP3x will support nRF52 or not. And the reply email from Sensirion company says:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;No, we don&amp;rsquo;t support your specific microcontroller. I&amp;rsquo;m sorry but we don&amp;rsquo;t have the resources to customize drivers to every possible platform. We can only provide examples for some of the most common platforms.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Since I&amp;#39;m new to nRF52, does that mean it&amp;#39;s impossible to get SDP31 measurements via nRF52 over TWI, pls? &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What modifications should I make to let nRF52 get SDP31 measurements over TWI, pls?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/290425?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2021 09:47:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49324cb6-13dd-4a03-ae6a-043c66bfc301</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;Many appreciations, Einar!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/290407?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2021 08:04:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93cd3ea1-6cd4-4216-9856-a78f91e7ed94</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am not able to answer these questions at the moment, unfortunately. However I have ordered a &lt;span&gt;SDP3x EK (EK-P4) so that I can test on my side. I t might take a couple of days before I get it, though. I will let you know when I have been able to test on my side.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/290378?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2021 02:15:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b3335ea-2717-439a-a85d-6829815c8768</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;According to the datasheet of my sensor, its I2C address should be 0x22.&amp;nbsp;I only have 1 slave device.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What I found is if I define the correct TWI address in &amp;lt;TWI sensor&amp;gt; code and run it, then &amp;lt;TWI scanner&amp;gt; could find 2 addresses.&amp;nbsp;&lt;br /&gt;&lt;strong&gt;&amp;lt;info&amp;gt; app: TWI enabled&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;lt;info&amp;gt; app: TWI device detected at address 0x20.&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;lt;info&amp;gt; app: TWI device detected at address 0x22.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;However, if I clean the solution, then run the &amp;lt;TWI scanner&amp;gt; again, it can only detect 0x20 address (no idea why I have this address).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Note: my sensor requires a command (0x3608) to enter the continuous data reading mode. This command is unspecified in &amp;lt;TWI scanner&amp;gt; example. It&amp;#39;s specified in &amp;lt;TWI sensor&amp;gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Question:&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;1) Why I have a &amp;quot;ghost&amp;quot; address 0x20?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2) Why I must run &amp;lt;TWI sensor&amp;gt; first, then run &amp;lt;TWI scanner&amp;gt;, then I can see 2 addresses (1 address is correct)?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/290372?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2021 00:26:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96f28bf1-9ec2-4cd0-9d17-d282473406d1</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;Update.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now the PuTTY shows&amp;nbsp;an unknown address.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;lt;info&amp;gt; app: TWI device detected at address 0x20.&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;lt;info&amp;gt; app: TWI device detected at address 0x22.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;However, I only have 1 salve device, which is 0x22.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any idea why there is 0x20, please?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/290336?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2021 16:05:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cadbd09-a0b9-45dd-ac9f-2da0df0fed82</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for the plots and info. This is a bit of a mystery, to be honest. I will look more into it tomorrow and get back to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/290090?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2021 01:01:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c66642a-9dce-486c-b833-ed5d7c4cecf6</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;Update.&lt;/p&gt;
&lt;p&gt;In sdk config, I changed SCL and SDA pins as pin 3 and 4. These 2 pins work well in &amp;lt;twi_master_with_twis_slave&amp;gt; example. Then, I used &amp;lt;TWI scanner&amp;gt; to scan my sensor address.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It shows &amp;quot;No device was found&amp;quot;.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/290086?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2021 23:33:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb9d5d88-1847-4e98-9f15-488131543118</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;Hi Einar, thank you very much for ur help.&lt;/p&gt;
&lt;p&gt;For Arduino UNO, I used I2C to scan my sensor. Here are the plots of SDA (blue) and SCL (red).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Image 1:&lt;/strong&gt; you could see the Arduino scans 127 I2C addresses.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Image 2:&lt;/strong&gt; you could see for the 34th address (0x22), Arduino detects the sensor, which is correct.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Image 3:&lt;/strong&gt; more detailed 34th address SDA and SCL signals.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It looks correct on Arduino.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/0624.png" alt=" " /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1205.png" alt=" " /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/6813.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Here is what I did on nRF52 DK:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. Use&amp;nbsp;one 4.7k ohm pull-up resistors for SDA and SCL respectively&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. Connect nRF52 detect pin to GND.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;3. compile and run &amp;lt;TWI scanner&amp;gt; code.&lt;/p&gt;
&lt;p&gt;I found that my nRF52 scans the other devices (e.g. Arduino UNO) show the I2C address is 0x20 as well. It seems like the nRF52 returned I2C address doesn&amp;#39;t change.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since Arduino UNO can detect the sensor at the correct address, I suspect that it&amp;#39;s the issue of nRF52.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks, Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/289961?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2021 10:11:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac83106a-86c4-481a-89c5-5b672db06827</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see. Can you also make plots of the exact same read operation as you do from the nRF? I would like to see a comparison in order to understand more. Unfortunately I do not have the&amp;nbsp;SDP31 so I am not able to test with that on my side.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/289883?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2021 22:26:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5a8b9af-9b1b-447d-bd3b-ea14ac21695e</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;I used this &lt;a href="https://github.com/rac2030/Arduino-Sensirion-SDP3x-driver"&gt;Arduino code&lt;/a&gt; from Github. Please remember to uncomment the code at line 13, which is used to customize the I2C address. If I change line 13 as I2C address 0x21, my sensor works well. For all other I2C addresses, my sensor has no data output.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/289696?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2021 11:25:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9cf6568-09d7-4721-96f0-30a33272b807</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This is puzzling... Can you upload a corresponding plot from when using the Android device so that I can compare with the nRF5 device? Also, if you can upload the full code for Android as well that would be good. Are you using the same configuration in other regards, same frequency?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/289601?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2021 02:25:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff8f1a5d-035f-4c32-832d-cf64884c0dac</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;Today, I tried to use Arduino UNO to connect with my &lt;a href="https://www.mouser.com/datasheet/2/682/Sensirion_Differential_Pressure_Sensors_SDP3x_Digi-1511485.pdf"&gt;sensor &lt;/a&gt;via I2C. Arduino UNO correctly shows that my address is 0x21. If I change the resistor value at ADDR, the address will be changed to 0x21 or 0x22 or 0x23 successfully (&lt;a href="https://www.mouser.com/datasheet/2/682/Sensirion_Differential_Pressure_Sensors_SDP3x_Digi-1511485.pdf"&gt;see datasheet page 4, section 3.3&lt;/a&gt;).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However,&amp;nbsp;Nordic nRF52 DK (nRF52832) shows my address is still 0x20 no matter which resistor value I use at the ADDR port.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So I guess it&amp;#39;s something wrong in code or nRF52 DK.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/289519?ContentTypeID=1</link><pubDate>Fri, 15 Jan 2021 19:45:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82afe9a7-4e18-401a-bdcc-c5b4582edf0a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Decoding this by hand I see that the first 8 bits are&amp;nbsp;01000001. The last (LSB) is &amp;#39;1&amp;#39; indicating read, and the rest of th 7 bits are 0100000 = 0x20, as you write. I agree that it does not match with the sensor datasheet, but what you get in your code is correct with regard to what we see from the plots. So 0x20 is definitely correct here.&lt;/p&gt;
&lt;p&gt;I suggest you contact the sensor manufacturer if you need to dig deeper into this, as it is difficult for anyone else to know why the sensor answer to another address than what is documented. Could it for instance be that a different revision of the sensor which uses a different address?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/289316?ContentTypeID=1</link><pubDate>Fri, 15 Jan 2021 01:09:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:817790f9-e169-4d4c-b913-98d441fdc3e4</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;Update.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since my sensor&amp;#39;s &lt;a href="https://www.mouser.com/datasheet/2/682/Sensirion_Differential_Pressure_Sensors_SDP3x_Digi-1511485.pdf"&gt;datasheet&lt;/a&gt;&amp;nbsp;page 4 section 3.3 says that if I use a 1.2k resistor, the I2C address will change to 0x22.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then I tried a 1.4k resistor, but the address is still 0x20.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So I suspect it&amp;#39;s the software issue. My full code is here.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
/** @file
 * @defgroup tw_scanner main.c
 * @{
 * @ingroup nrf_twi_example
 * @brief TWI Sensor Example main file.
 *
 * This file contains the source code for a sample application using TWI.
 *
 */

#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_drv_twi.h&amp;quot;



#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

/* TWI instance ID. */
#if TWI0_ENABLED
#define TWI_INSTANCE_ID     0
#elif TWI1_ENABLED
#define TWI_INSTANCE_ID     1
#endif

 /* Number of possible TWI addresses. */
 #define TWI_ADDRESSES      127

/* TWI instance. */
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);


/**
 * @brief TWI initialization.
 */
void twi_init (void)
{
    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_config = {
       .scl                = ARDUINO_SCL_PIN,
       .sda                = ARDUINO_SDA_PIN,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_config, NULL, NULL);
    APP_ERROR_CHECK(err_code);

    nrf_drv_twi_enable(&amp;amp;m_twi);
}


/**
 * @brief Function for main application entry.
 */
int main(void)
{
    ret_code_t err_code;
    uint8_t address;
    uint8_t sample_data;
    bool detected_device = false;

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO(&amp;quot;TWI scanner started.&amp;quot;);
    NRF_LOG_FLUSH();
    twi_init();

    for (address = 1; address &amp;lt;= TWI_ADDRESSES; address++)
    {
        // NRF_LOG_INFO(&amp;quot;Hi %d&amp;quot;,address);
        err_code = nrf_drv_twi_rx(&amp;amp;m_twi, address, &amp;amp;sample_data, sizeof(sample_data));
        if (err_code == NRF_SUCCESS)
        {
            detected_device = true;
            NRF_LOG_INFO(&amp;quot;TWI device detected at address 0x%x.&amp;quot;, address);
        }
        NRF_LOG_FLUSH();
    }

    if (!detected_device)
    {
        NRF_LOG_INFO(&amp;quot;No device was found.&amp;quot;);
        NRF_LOG_FLUSH();
    }

    while (true)
    {
        /* Empty loop. */
    }
}

/** @} */
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/289311?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2021 23:18:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09ce1176-20d1-411c-a379-0cc118e24b21</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/32-33.PNG" alt=" " /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/ack32.PNG" alt=" " /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;for (address = 32; address &amp;lt; 34; address++)
    {
        NRF_LOG_INFO(&amp;quot;Hi %d&amp;quot;,address);
        err_code = nrf_drv_twi_rx(&amp;amp;m_twi, address, &amp;amp;sample_data, sizeof(sample_data));
        if (err_code == NRF_SUCCESS)
        {
            detected_device = true;
            NRF_LOG_INFO(&amp;quot;TWI device detected at address 0x%x.&amp;quot;, address);
        }
        NRF_LOG_FLUSH();
    }
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;From the code and graph, you could see that ACK is LOW for address 32 (find the device at 0x20), ACK is HIGH for address 33 (no device at 0x21).&lt;/p&gt;
&lt;p&gt;However, my sensor datasheet says that if I connect the sensors&amp;#39; ADDR pin to GND, the address should be 0x21. Very strange issue!&lt;/p&gt;
&lt;p&gt;Any one help pls?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/289113?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2021 09:57:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfeacfe2-7d53-4bc6-b844-af008b08357e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Looking at the 9th clock pulse it looks like the SDA stays high, so there is no ACK here. Also, the data bits does not match address 0x20 (look like 0x03). Are you sure this is from the correct loop iteration? Can you modify your code to try to talk to only a single address at a time, so that you know that you are checking the correct one?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/289052?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2021 02:42:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ee2e909-10e5-4abd-b60b-ae5a8488ceb1</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;Here are the signals I got from SCL (red) and SDA(blue) for &amp;lt;TWI scanner demo&amp;gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/i2c-address.PNG" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;meanwhile, here is my code &amp;lt;TWI scanner&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_drv_twi.h&amp;quot;



#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

/* TWI instance ID. */
#if TWI0_ENABLED
#define TWI_INSTANCE_ID     0
#elif TWI1_ENABLED
#define TWI_INSTANCE_ID     1
#endif

 /* Number of possible TWI addresses. */
 #define TWI_ADDRESSES      127

/* TWI instance. */
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);


/**
 * @brief TWI initialization.
 */
void twi_init (void)
{
    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_config = {
       .scl                = ARDUINO_SCL_PIN,
       .sda                = ARDUINO_SDA_PIN,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_config, NULL, NULL);
    APP_ERROR_CHECK(err_code);

    nrf_drv_twi_enable(&amp;amp;m_twi);
    NRF_LOG_INFO(&amp;quot;TWI enabled&amp;quot;);
}


/**
 * @brief Function for main application entry.
 */
int main(void)
{
    ret_code_t err_code;
    uint8_t address;
    uint8_t sample_data;
    bool detected_device = false;

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO(&amp;quot;TWI scanner started.&amp;quot;);
    NRF_LOG_FLUSH();
    twi_init();

    /* Configure board. */
    bsp_board_init(BSP_INIT_LEDS);

    for (address = 1; address &amp;lt;= TWI_ADDRESSES; address++)
    {
        err_code = nrf_drv_twi_rx(&amp;amp;m_twi, address, &amp;amp;sample_data, sizeof(sample_data));
        // NRF_LOG_INFO(&amp;quot;%d&amp;quot;,(uint32_t)err_code);
        
        if (err_code == NRF_SUCCESS)
        {
            detected_device = true;
            NRF_LOG_INFO(&amp;quot;TWI device detected at address 0x%x.&amp;quot;, address);
        }
        NRF_LOG_FLUSH();
    }

    if (!detected_device)
    {
        NRF_LOG_INFO(&amp;quot;No device was found.&amp;quot;);
        NRF_LOG_FLUSH();
    }

    while (true)
    {
        /* Empty loop. */
    }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/288951?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2021 14:03:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76b99873-1791-4be1-962f-e2184c453b7a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Then I am out of ideas. The whole TWI Scanner example is essentially just this for loop:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    for (address = 1; address &amp;lt;= TWI_ADDRESSES; address++)
    {
        err_code = nrf_drv_twi_rx(&amp;amp;m_twi, address, &amp;amp;sample_data, sizeof(sample_data));
        if (err_code == NRF_SUCCESS)
        {
            detected_device = true;
            NRF_LOG_INFO(&amp;quot;TWI device detected at address 0x%x.&amp;quot;, address);
        }
        NRF_LOG_FLUSH();
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As you can see, it prints the address (loop iteration #) of any device it is able to read from. It should not fail... If this is still a problem, perhaps you can use a logic analyzer to see how this looks on the TWI bus?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/288887?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2021 11:00:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15258fa0-18e8-44c1-a9cb-d0debb9a8538</guid><dc:creator>StevenW807</dc:creator><description>&lt;p&gt;I&amp;#39;m using SDP31 pressure sensor. Its &lt;a href="https://www.mouser.com/datasheet/2/682/Sensirion_Differential_Pressure_Sensors_SDP3x_Digi-1511485.pdf"&gt;datasheet &lt;/a&gt;is here.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;According to page 4, section 3.3, my ADDR connects to GND. So its I2C address should be 0x21. But &amp;lt;TWI scanner&amp;gt; demo shows that the address is 0x20.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks, Einar!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Scanner I2C address is 1 bit wrong</title><link>https://devzone.nordicsemi.com/thread/288843?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2021 08:55:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb7b528e-1bcd-4ea4-b9f4-fd09d3bf3e73</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Some I2C slaves lets you select one of a few addresses by hooking some pin(s) to VDD or ground, so that could be the case. Which sensor are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>