<?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>Asset Tracker V2 - BH1749 enable</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80785/asset-tracker-v2---bh1749-enable</link><description>Hello, 
 I am working with the Thingy91 and I&amp;#39;m trying to enable BH1749 sensor on the Asset Tracker V2 application. I have done the following : 
 1. In thingy91_nrf9160ns.overlay : added the bh1749 in &amp;amp;i2c node and aliases for red, green, blue, ir data</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 22 Mar 2023 08:06:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80785/asset-tracker-v2---bh1749-enable" /><item><title>RE: Asset Tracker V2 - BH1749 enable</title><link>https://devzone.nordicsemi.com/thread/416711?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2023 08:06:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c7aff53-9dec-4706-b7ac-07311c26832f</guid><dc:creator>Ales Pour</dc:creator><description>&lt;p&gt;Do you please have a working solution? I&amp;#39;m also trying to&amp;nbsp;make&amp;nbsp;Asset Tracker v2&amp;nbsp; send light sensor data, but all I&amp;#39;m getting from the sensor are zeros for all color channels. No errors (device is ready, sample fetch - OK, channel get - OK), I just get 0s.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Asset Tracker V2 - BH1749 enable</title><link>https://devzone.nordicsemi.com/thread/335589?ContentTypeID=1</link><pubDate>Sun, 24 Oct 2021 15:50:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58282fe1-1d8c-4592-8ff9-e3d64de3b0fc</guid><dc:creator>Luca Z</dc:creator><description>&lt;p&gt;Hi Jon,&lt;/p&gt;
&lt;p&gt;Indeed it compiles when replacing DEVICE_DEFINE by DEVICE_DT_INST_DEFINE. Any idea why ?&lt;/p&gt;
&lt;p&gt;I can now get data from the sensor after some rework of my ext_sensors_color_x_get() functions. &lt;br /&gt;So that other people don&amp;#39;t lose time on this : calling sensor_sample_fetch_chan() will clear VALID bit in MODE_CONTROL2 register of the sensor. If same function is called again for another data, an error will be raised : &amp;quot;No valid data to fetch&amp;quot;.&lt;/p&gt;
&lt;p&gt;The right way to do it is to call once sensor_sample_fetch_chan() and then sensor_channel_get() for each data with the correct channel passed to the function. An example can be found in Asset Tracker application.&lt;/p&gt;
&lt;p&gt;Luca&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Asset Tracker V2 - BH1749 enable</title><link>https://devzone.nordicsemi.com/thread/335374?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 21:32:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c66565c-499d-43fc-811e-f1d8623da073</guid><dc:creator>Jon Helge</dc:creator><description>&lt;p class="p1"&gt;&lt;span class="s1"&gt;I managed to get it to compile, but I have now idea if it actually works. I saw that the bme680 driver was using DEVICE_DT_INST_DEFINE instead of DEVICE_DEFINE that was used by bh1749. Modifiying the bh1749 driver to do it similar like the BME680 did the trick.&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;b&gt;diff --git a/drivers/sensor/bh1749/bh1749.c b/drivers/sensor/bh1749/bh1749.c&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;b&gt;index 86f12dfc0..703ae84dd 100644&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;b&gt;--- a/drivers/sensor/bh1749/bh1749.c&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;b&gt;+++ b/drivers/sensor/bh1749/bh1749.c&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s2"&gt;@@ -306,6 +306,5 @@&lt;/span&gt;&lt;span class="s1"&gt; static const struct sensor_driver_api bh1749_driver_api = {&lt;/span&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s1"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;static struct bh1749_data bh1749_data;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s1"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s1"&gt;-DEVICE_DEFINE(bh1749, DT_INST_LABEL(0),&lt;/span&gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s1"&gt;- &lt;span class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;bh1749_init, NULL, &amp;amp;bh1749_data, NULL,&lt;/span&gt;&lt;/p&gt;
&lt;p class="p4"&gt;&lt;span class="s1"&gt;+DEVICE_DT_INST_DEFINE(0,bh1749_init, NULL, &amp;amp;bh1749_data, NULL,&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &amp;amp;bh1749_driver_api);&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Asset Tracker V2 - BH1749 enable</title><link>https://devzone.nordicsemi.com/thread/335369?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 20:41:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:626747c1-75f2-4dae-bdb1-23532a3d8d9b</guid><dc:creator>Luca Z</dc:creator><description>&lt;p&gt;Hi Jon,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;I double checked and indeed the changes I described in my first message do not cause a build error. The alias is correctly binded to the structure. But the structure is not used in your case...&lt;/p&gt;
&lt;p&gt;The 2 following changes cause the undefined reference error during build stage :&lt;/p&gt;
&lt;p&gt;In ext_sensors_init() :&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	if(!device_is_ready(red_sensor.dev)){
		LOG_ERR(&amp;quot;Color sensor - red channel - is not ready&amp;quot;);
		evt.type = EXT_SENSOR_EVT_COLOR_RED_ERROR;
		evt_handler(&amp;amp;evt);
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And adding this function :&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int ext_sensors_color_red_get(uint16_t *ext_red)
{
	int err;
	struct sensor_value data = {0};
	struct ext_sensor_evt evt = {0};

	err = sensor_sample_fetch_chan(red_sensor.dev, SENSOR_CHAN_ALL);
	if (err) {
		LOG_ERR(&amp;quot;Failed to fetch data from %s, error: %d&amp;quot;,
			red_sensor.dev-&amp;gt;name, err);
		evt.type = EXT_SENSOR_EVT_COLOR_RED_ERROR;
		evt_handler(&amp;amp;evt);
		return -ENODATA;
	}

	err = sensor_channel_get(red_sensor.dev, red_sensor.channel, &amp;amp;data);
	if (err) {
		LOG_ERR(&amp;quot;Failed to fetch data from %s, error: %d&amp;quot;,
			red_sensor.dev-&amp;gt;name, err);
		evt.type = EXT_SENSOR_EVT_COLOR_RED_ERROR;
		evt_handler(&amp;amp;evt);
		return -ENODATA;
	}

	k_spinlock_key_t key = k_spin_lock(&amp;amp;(red_sensor.lock));
	*ext_red = sensor_value_to_double(&amp;amp;data);
	k_spin_unlock(&amp;amp;(red_sensor.lock), key);

	return 0;
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Could you please try with the 2 above changes ?&lt;/p&gt;
&lt;p&gt;And by the way I am using the SDK&amp;#39;s tag version v1.6.1 and VS Code extension for nRF Connect SDK as development environment.&lt;/p&gt;
&lt;p&gt;Thanks a lot,&lt;/p&gt;
&lt;p&gt;Luca&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Asset Tracker V2 - BH1749 enable</title><link>https://devzone.nordicsemi.com/thread/335359?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 17:21:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a5c56bb-1b84-466e-8bfc-647c752652bf</guid><dc:creator>Jon Helge</dc:creator><description>&lt;p&gt;Strange. I just did the same on NCS master. It compiles and I get a warnings like&amp;nbsp;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;b&gt;/Users/jhn/work/repos/ncs/nrf/applications/asset_tracker_v2/src/ext_sensors/ext_sensors.c:65:26:&lt;/b&gt; &lt;/span&gt;&lt;span class="s2"&gt;&lt;b&gt;warning: &lt;/b&gt;&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;b&gt;green_sensor&lt;/b&gt;&amp;#39; defined but not used [&lt;/span&gt;&lt;span class="s2"&gt;&lt;b&gt;-Wunused-variable&lt;/b&gt;&lt;/span&gt;&lt;span class="s1"&gt;]&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;span class="Apple-converted-space"&gt;since I am not using it for anything. Linker reports no errors. You have not done anything else to your configs?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>