<?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>BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52947/bme280-i2c-return-same-values-using-twim</link><description>Hello 
 I have nRF52832 custom board and have BME280 sensor connected to I2C/TWI 
 Whatever I do I get same reading (for 3 different sensors) 
 I&amp;#39;m constantly reading same values 
 
 
 and here is my I2C/TWI init 
 
 
 also I2C read and write methods</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Oct 2019 15:29:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52947/bme280-i2c-return-same-values-using-twim" /><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214916?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2019 15:29:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90242b82-26c5-4cdb-b23c-c81ce611c92e</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;I&amp;#39;m not familiar with that log structure, but it kinda looks like you&amp;#39;re writing 0xF4 to the register with address 0xEC, then reading from the register with address 0xED, with both operations being successful.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you looked at Bosch&amp;#39;s driver?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214872?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2019 13:33:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d990607b-dd0c-4795-9471-d87c34612514</guid><dc:creator>InvalidException</dc:creator><description>&lt;p&gt;That was not issue as someone was already on Bosch site talking about it, just moved it inside function to read so will not be global (so will not have issue with compiler and volatile)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Problem still persist, getting same values and log that I posted from logic analyzer is specific for line&amp;nbsp;&lt;/p&gt;
&lt;p&gt;71&amp;nbsp; Setup Write to [0xEC] + ACK&lt;br /&gt;72&amp;nbsp; 0xF4 + ACK&lt;br /&gt;73&amp;nbsp; Setup Read to [0xED] + ACK&lt;br /&gt;74&amp;nbsp; 0x00 + NAK&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So writing to &lt;strong&gt;F4&lt;/strong&gt; returns &lt;strong&gt;ACK &lt;/strong&gt;while reading data returns 0x00 and&amp;nbsp;&lt;strong&gt;NAK&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Will need to connect to Arduino and check if this is happening there also or something else is wrong &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214827?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2019 12:19:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ea155e0-e290-4966-bc74-7e3bd6894a0e</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;I don&amp;#39;t know the&amp;nbsp;&lt;span&gt;BME280, therefore, I don&amp;#39;t know what you&amp;#39;d expect from this log and what is actually captured by the logical analyzer.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;&lt;span&gt;The members that points to the addresses that the TWI peripheral uses for the transactions need to be declared as volatile.&amp;quot; Did this solve your original issue?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214715?ContentTypeID=1</link><pubDate>Sun, 13 Oct 2019 23:11:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c6a80c9-0ae9-43b9-afd3-483a615a5e13</guid><dc:creator>InvalidException</dc:creator><description>&lt;p&gt;After hooking I2C logic analyzer I got next results:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; Decoded Protocol Result
Setup Write to [0xEC] + ACK
0xD0 + ACK
Setup Read to [0xED] + ACK
0x60 + NAK
Setup Write to [0xEC] + ACK
0xB6 + ACK
Setup Write to [0xEC] + ACK
0x88 + ACK
Setup Read to [0xED] + ACK
0x4A + ACK
0x71 + ACK
0x25 + ACK
0x68 + ACK
0x32 + ACK
0x00 + ACK
0xE7 + ACK
0x89 + ACK
0xDA + ACK
0xD6 + ACK
0xD0 + ACK
0x0B + ACK
0x27 + ACK
0x19 + ACK
0xCA + ACK
0xFF + ACK
0xF9 + ACK
0xFF + ACK
0xAC + ACK
0x26 + ACK
0x0A + ACK
0xD8 + ACK
0xBD + ACK
0x10 + ACK
0x00 + ACK
0x4B + NAK
Setup Write to [0xEC] + ACK
0xE1 + ACK
Setup Read to [0xED] + ACK
0x60 + ACK
0x01 + ACK
0x00 + ACK
0x15 + ACK
0x28 + ACK
0x03 + ACK
0x1E + NAK
Setup Write to [0xEC] + ACK
0xF4 + ACK
Setup Read to [0xED] + ACK
0x00 + NAK
Setup Write to [0xEC] + ACK
0x01 + ACK
Setup Write to [0xEC] + ACK
0xF4 + ACK
Setup Read to [0xED] + ACK
0x00 + NAK
Setup Write to [0xEC] + ACK
0x00 + ACK
Setup Write to [0xEC] + ACK
0xF4 + ACK
Setup Read to [0xED] + ACK
0x00 + NAK
Setup Write to [0xEC] + ACK
0x54 + ACK
Setup Write to [0xEC] + ACK
0xF5 + ACK
Setup Read to [0xED] + ACK
0x00 + NAK
Setup Write to [0xEC] + ACK
0x30 + ACK
Setup Write to [0xEC] + ACK
0xF4 + ACK
Setup Read to [0xED] + ACK
0x00 + NAK
Setup Write to [0xEC] + ACK
0xF4 + ACK
Setup Read to [0xED] + ACK
0x00 + NAK
Setup Write to [0xEC] + ACK
0x01 + ACK
Setup Write to [0xEC] + ACK
0xF7 + ACK
Setup Read to [0xED] + ACK
0x80 + ACK
0x00 + ACK
0x00 + ACK
0x80 + ACK
0x00 + ACK
0x00 + ACK
0x80 + ACK
0x00 + NAK
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And weird one is at Write to register F4 [BME280_PWR_CTRL_ADDR] now starting to be even more confused &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214405?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2019 13:51:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:057d714c-55e2-433c-bca8-3a516985d527</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;The members that points to the addresses that the TWI peripheral uses for the transactions need to be declared as volatile.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214249?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2019 03:06:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbb4f3dc-4dd0-415c-a0b8-06def253cfee</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;volatile is not for a struct. &amp;nbsp;You are passing an address so volatile is not required neither. &amp;nbsp;Try this driver here. &amp;nbsp;It works with both SPI or I2C.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/IOsonata/IOsonata/blob/master/src/sensors/tph_bme280.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/src/sensors/tph_bme280.cpp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/src/i2c_nrf5x.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/src/i2c_nrf5x.cpp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/IOsonata/IOsonata/blob/master/exemples/sensor/env_tph_demo.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/exemples/sensor/env_tph_demo.cpp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214226?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2019 18:34:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:319722f5-aa9e-4ba7-be19-54d188603459</guid><dc:creator>InvalidException</dc:creator><description>&lt;p&gt;If I declare it as volatile I get error &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;error: passing argument 2 of &amp;#39;bme280_get_sensor_data&amp;#39; discards &amp;#39;volatile&amp;#39; qualifier from pointer target type [-Werror=discarded-qualifiers]
     rslt = bme280_get_sensor_data(BME280_ALL, &amp;amp;data, &amp;amp;bme280);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214181?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2019 13:24:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6dd1d56-ab12-4d5a-9f2b-f3736612496a</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Then I bet the compiler optimizes out the actual reading of this register as it does not know that the TWI peripheral actually writes to the &amp;#39;data&amp;#39; variable. Since this variable is never written to programmatically the compiler thinks the data it contains never actually changes and never bothers to actually read its value when&amp;nbsp;using it in the sdk logger.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Declare it as volatile and report what happens :)&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214014?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 21:36:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a96b83a-47a4-4a63-99e6-fc92be74e2a1</guid><dc:creator>Mojo</dc:creator><description>&lt;p&gt;use this library, it&amp;#39;s much better. Has port for nRF5x series.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/IOsonata/IOsonata"&gt;https://github.com/IOsonata/IOsonata&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/214010?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 20:55:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:743608e9-759b-4aac-bf79-b2b81782dfac</guid><dc:creator>InvalidException</dc:creator><description>&lt;p&gt;&amp;#39;data&amp;#39; is structure declared at top and it is not volatile&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;struct bme280_data data;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;type can be read from&amp;nbsp;&lt;a href="https://github.com/BoschSensortec/BME280_driver/blob/master/bme280_defs.h#L300" rel="noopener noreferrer" target="_blank"&gt;bme280_defs.h#L300&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Will try tonight/tomorrow to read directly from registers (instead of using Bosch library)&amp;nbsp;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BME280[I2C] return same values using TWIM</title><link>https://devzone.nordicsemi.com/thread/213860?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 10:43:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e6918fe-a750-40ce-a267-9060b1f5b56b</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Is the variable &amp;#39;data&amp;#39; declared as volatile?&lt;br /&gt;&lt;br /&gt;What is the value of data if you inspect it with a debugger?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>