<?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>nRF5340 Audio DK with BMP280 sensor</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105537/nrf5340-audio-dk-with-bmp280-sensor</link><description>Hello, 
 
 I am fairly new to the development with nRF and am having problems getting sensor data from a connected BMP280 to the nRF5340 audio dk. 
 The first thing I did was look at the sample for the BME280 (unfortunately there is no pre-made sample</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 May 2025 09:20:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105537/nrf5340-audio-dk-with-bmp280-sensor" /><item><title>RE: nRF5340 Audio DK with BMP280 sensor</title><link>https://devzone.nordicsemi.com/thread/535495?ContentTypeID=1</link><pubDate>Thu, 15 May 2025 09:20:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99c859d2-6822-4c4d-86cb-428bbc4cd480</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I would like to ask you to make a new ticket about your issue if you&amp;#39;d like to get support from Nordic engineers as well.&lt;/p&gt;
&lt;p&gt;It makes it much easier for us to work through different issues.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Michal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio DK with BMP280 sensor</title><link>https://devzone.nordicsemi.com/thread/535290?ContentTypeID=1</link><pubDate>Wed, 14 May 2025 09:30:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6b23461-6fa7-4748-b560-9b8a1b11ff50</guid><dc:creator>Suneelmb</dc:creator><description>&lt;p&gt;Hi Rajendra, this looks interesting. How we will get to know how many i2c bus we can enable if it is not mentioned in device tree. Can you suggest a better way for understanding and implementing this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio DK with BMP280 sensor</title><link>https://devzone.nordicsemi.com/thread/503329?ContentTypeID=1</link><pubDate>Sat, 21 Sep 2024 11:54:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:652305f1-018f-4ca7-b485-e54e9680e31c</guid><dc:creator>RajendraN</dc:creator><description>&lt;p&gt;I hope above problem was resolved.&lt;/p&gt;
&lt;p&gt;Warm regards&lt;br /&gt;Rajendra.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio DK with BMP280 sensor</title><link>https://devzone.nordicsemi.com/thread/456492?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2023 15:08:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:269eeae7-6a35-4db9-9a0b-551f46fbc387</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;There is a i2c2, but not all peripherals are pre-defined in the devicetree. If you add something like this to the devicetree, for example by using an overlay file, you should have access to i2c2:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pinctrl {

	i2c2_default: i2c2_default {
		group1 {
			psels = &amp;lt;NRF_PSEL(TWIM_SDA, 1, 2)&amp;gt;,
				&amp;lt;NRF_PSEL(TWIM_SCL, 1, 3)&amp;gt;;
		};
	};

	i2c2_sleep: i2c2_sleep {
		group1 {
			psels = &amp;lt;NRF_PSEL(TWIM_SDA, 1, 2)&amp;gt;,
				&amp;lt;NRF_PSEL(TWIM_SCL, 1, 3)&amp;gt;;
			low-power-enable;
		};
	};
};

&amp;amp;i2c2 {
	compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;i2c2_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;i2c2_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Make sure to change the pins to your desired pins, and add the device to the i2c2 node.&lt;/p&gt;
&lt;p&gt;Let me know what the log output is if you try this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio DK with BMP280 sensor</title><link>https://devzone.nordicsemi.com/thread/455565?ContentTypeID=1</link><pubDate>Tue, 14 Nov 2023 14:26:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6736c8f-f042-4d21-9873-e1e182d61775</guid><dc:creator>lukasprobst</dc:creator><description>&lt;p&gt;Thanks for your reply, Oivind! As far as I can tell from the Devicetree, there is only one I2C (i2c1) on the nRF5340 audio dk and no i2c2 available. I&amp;#39;ve also tried setting CONFIG_INA230=n in my prj.conf. Unfortunately, I&amp;#39;m still not able to get sensor data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio DK with BMP280 sensor</title><link>https://devzone.nordicsemi.com/thread/455327?ContentTypeID=1</link><pubDate>Mon, 13 Nov 2023 14:14:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05ad5eb2-9a3c-407a-922a-e3fdc0ba4b85</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;It seems that changing the pins for i2c1 may be interfering with the default setup for the board. Also P0.04 and P0.05 are routed to the hardware buttons.&lt;/p&gt;
&lt;p&gt;Could you try using pins that are not already in use, and perhaps enabling and using i2c2 instead of i2c1?&lt;/p&gt;
&lt;p&gt;Or perhaps setting CONFIG_INA230=n?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio DK with BMP280 sensor</title><link>https://devzone.nordicsemi.com/thread/455021?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2023 21:12:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:901832f9-54ae-4c7c-b336-118b88473641</guid><dc:creator>lukasprobst</dc:creator><description>&lt;p&gt;Thanks for your reply!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is the error message I am getting in Serial Terminal with my current code:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;*** Booting nRF Connect SDK v2.5.0-rc2 ***&lt;br /&gt;Found device &amp;quot;I2C_1&amp;quot;, getting sensor data&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.254,089] &amp;lt;err&amp;gt; os: ***** USAGE FAULT *****&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.254,089] &amp;lt;err&amp;gt; os: Attempt to execute undefined instruction&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.254,119] &amp;lt;err&amp;gt; os: r0/a1: 0x200022e8 r1/a2: 0x00000000 r2/a3: 0x00000004&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.254,119] &amp;lt;err&amp;gt; os: r3/a4: 0x00008cfb r12/ip: 0x0000000c r14/lr: 0x000082bb&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.254,119] &amp;lt;err&amp;gt; os: xpsr: 0x49000000&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.254,150] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x000082ac&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.254,180] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 36: Unknown error on CPU 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.254,211] &amp;lt;err&amp;gt; os: Current thread: 0x200007f8 (unknown)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:00.753,509] &amp;lt;err&amp;gt; i2c_nrfx_twim: Error on I2C line occurred for message 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:00.753,570] &amp;lt;err&amp;gt; INA230: Failed to write configuration register!&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:01.253,662] &amp;lt;err&amp;gt; i2c_nrfx_twim: Error on I2C line occurred for message 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:01.253,692] &amp;lt;err&amp;gt; INA230: Failed to write configuration register!&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:01.753,814] &amp;lt;err&amp;gt; i2c_nrfx_twim: Error on I2C line occurred for message 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:01.753,845] &amp;lt;err&amp;gt; INA230: Failed to write configuration register!&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.253,936] &amp;lt;err&amp;gt; i2c_nrfx_twim: Error on I2C line occurred for message 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;[00:00:02.253,997] &amp;lt;err&amp;gt; INA230: Failed to write configuration register!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;and this is my code in main.c:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/device.h&amp;gt;
#include &amp;lt;zephyr/devicetree.h&amp;gt;
#include &amp;lt;zephyr/drivers/sensor.h&amp;gt;
#include &amp;lt;zephyr/drivers/i2c.h&amp;gt;

#define I2C_NODE DT_NODELABEL(bmp280)

// TODO: This information typically goes into a separate header file
#define BMP280_I2C_ADDR 								0x76 // BMP280 I2C address, 0x77 if ADDR pin is high

#define BMP280_REG_CTRL_MEAS 							0xF4
#define BMP280_REG_CONFIG 								0xF5
#define BMP280_REG_PRESS_MSB 							0xF7
#define BMP280_REG_TEMP_MSB 							0xFA

static const struct i2c_dt_spec dev_i2c = I2C_DT_SPEC_GET(I2C_NODE);

void bmp280_init() {
    if (dev_i2c.bus == NULL) {
		/* No such node, or the node does not have status &amp;quot;okay&amp;quot;. */
		printk(&amp;quot;\nError: no device found.\n&amp;quot;);
		return;
    }

	if (!device_is_ready(dev_i2c.bus)) {
		printk(&amp;quot;I2C bus %s is not ready!\n\r&amp;quot;, dev_i2c.bus-&amp;gt;name);
		return;
	}

	printk(&amp;quot;Found device \&amp;quot;%s\&amp;quot;, getting sensor data\n&amp;quot;, dev_i2c.bus-&amp;gt;name);
}

void bmp280_read_calibration_data(uint16_t *calib_data) {
    uint8_t calib[24];

    if (i2c_burst_read(&amp;amp;dev_i2c, BMP280_I2C_ADDR, 0x88, calib, sizeof(calib)) &amp;lt; 0) {
        printk(&amp;quot;Failed to read calibration data\n&amp;quot;);
        return;
    }

    // Parse calibration data (16-bit values)
    for (int i = 0; i &amp;lt; 12; i++) {
        calib_data[i] = (calib[2 * i] &amp;lt;&amp;lt; 8) | calib[2 * i + 1];
    }
}

void bmp280_configure() {
    uint8_t ctrl_meas = 0x57; // Temperature oversampling x1, Pressure oversampling x16, Normal mode
    uint8_t config = 0x00;    // Filter off, 3-wire SPI disabled

    if (i2c_reg_write_byte(&amp;amp;dev_i2c, BMP280_I2C_ADDR, BMP280_REG_CTRL_MEAS, ctrl_meas) &amp;lt; 0) {
        printk(&amp;quot;Failed to configure BMP280 control measurement\n&amp;quot;);
        return;
    }

    if (i2c_reg_write_byte(&amp;amp;dev_i2c, BMP280_I2C_ADDR, BMP280_REG_CONFIG, config) &amp;lt; 0) {
        printk(&amp;quot;Failed to configure BMP280 config\n&amp;quot;);
        return;
    }
}

void bmp280_read_data(int16_t *temperature, uint32_t *pressure) {
    uint8_t data[6];

    if (i2c_burst_read(&amp;amp;dev_i2c, BMP280_I2C_ADDR, BMP280_REG_TEMP_MSB, data, sizeof(data)) &amp;lt; 0) {
        printk(&amp;quot;Failed to read BMP280 data\n&amp;quot;);
        return;
    }

    int32_t adc_temp = (data[3] &amp;lt;&amp;lt; 12) | (data[4] &amp;lt;&amp;lt; 4) | (data[5] &amp;gt;&amp;gt; 4);
    int32_t t_fine = 0; // I need to calculate t_fine using calibration data, right?

    *temperature = ((t_fine * 5 + 128) &amp;gt;&amp;gt; 8) / 100;
    *pressure = 0; // I need to calculate pressure using calibration data, right?
}

int main(void) {
    int16_t temperature;
    uint32_t pressure;
    uint16_t calib_data[12];

    bmp280_init();
    bmp280_read_calibration_data(calib_data);
    bmp280_configure();

    while (1) {
        bmp280_read_data(&amp;amp;temperature, &amp;amp;pressure);
        printk(&amp;quot;Temperature: %d&amp;#176;C, Pressure: %u Pa\n&amp;quot;, temperature, pressure);
        k_sleep(K_MSEC(1000)); // Sleep for 1 second
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;overlay file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c1 {
	status = &amp;quot;okay&amp;quot;;
	compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
	label = &amp;quot;I2C_1&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;i2c1_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;i2c1_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	clock-frequency = &amp;lt;100000&amp;gt;; 
	bmp280: bmp280@76 {
		compatible = &amp;quot;i2c-device&amp;quot;;
		reg = &amp;lt; 0x76 &amp;gt;;
		label = &amp;quot;BMP280&amp;quot;;
	};
};

&amp;amp;pinctrl {
	i2c1_default: i2c1_default{
		group1 {
			psels = &amp;lt;NRF_PSEL(TWIM_SDA, 0, 5)&amp;gt;,
				&amp;lt;NRF_PSEL(TWIM_SCL, 0, 4)&amp;gt;;
		};
	};

	i2c1_sleep: i2c1_sleep{
		group1 {
			psels = &amp;lt;NRF_PSEL(TWIM_SDA, 0, 5)&amp;gt;,
				&amp;lt;NRF_PSEL(TWIM_SCL, 0, 4)&amp;gt;;
			low-power-enable;
		};
	};

};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;Here is the datasheet for the BMP280:&amp;nbsp;&lt;a id="" href="https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf"&gt;https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;It seems like the SensorAPI might be useful to get it working, but I haven&amp;#39;t figured out how to embed and use it in nRF correctly.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;BMP280 seems to&amp;nbsp;be on the market for quite some time, but I couldn&amp;#39;t find any useful resources to get sensor data from it in nRF. Maybe I missed something?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;I&amp;#39;d appreciate any kind of help!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;Best regards,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#993300;"&gt;&lt;span style="color:#000000;"&gt;Lukas&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio DK with BMP280 sensor</title><link>https://devzone.nordicsemi.com/thread/454944?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2023 14:28:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9438041-2901-46cf-8d4a-7cfb1451bb79</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could I see what you have so far, so that I can see if it&amp;#39;s just something small that is missing?&lt;/p&gt;
&lt;p&gt;Have you made sure to use the correct address?&lt;/p&gt;
&lt;p&gt;A logic trace would also be nice if possible, to see if the correct data is being sent from the board.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>