No output when i combined two sensors into single program with thingy-53

Hello

I am developing a single program for two sensors, one is "BME680", and other is "BH1749"  with thingy-53. But i could not see the output although i have no errors.

&i2c1 {
	compatible = "nordic,nrf-twim";
	status = "okay";
	clock-frequency = <I2C_BITRATE_STANDARD>;

	pinctrl-0 = <&i2c1_default>;
	pinctrl-1 = <&i2c1_sleep>;
	pinctrl-names = "default", "sleep";
	bme680: bme680@76 {
		compatible = "bosch,bme680";
		reg = <0x76>;
		label = "BME680";
	};
  	bh1749: bh1749@38 {
		compatible = "rohm,bh1749";
        label = "BH1749";
		reg = <0x38>;
		int-gpios = <&gpio1 5 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
	};
};

this is overlay file

/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr/zephyr.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/drivers/i2c.h>

#define BH1749_SYSTEM_CONTROL                           0x40
#define BH1749_MODE_CONTROL1                            0x41
#define BH1749_MODE_CONTROL2                            0x42
#define BH1749_RED_DATA_LSB                             0x50
#define BH1749_IR_DATA_LSB                             	0x58

#define BH1749_MODE_CONTROL2_RGB_EN_ENABLE              BIT(4)
#define BH1749_MODE_CONTROL1_DEFAULTS                   0x2A

#define BH_NODE DT_NODELABEL(bh1749)
static const struct i2c_dt_spec bh_i2c = I2C_DT_SPEC_GET(BH_NODE);

uint8_t init_bh1749(void)
{
	int ret;

	if (!device_is_ready(bh_i2c.bus)) {
		printk("I2C bus %s is not ready!\n\r",bh_i2c.bus->name);
		return 0;
	}
	printk("device is %p, name is %s\n", bh_i2c.bus, bh_i2c.bus->name); 

	char buff1[] = {BH1749_MODE_CONTROL1,BH1749_MODE_CONTROL1_DEFAULTS};
	ret = i2c_write_dt(&bh_i2c,buff1,sizeof(buff1));
	if(ret != 0){
		printk("1- Failed to write to I2C device address 0x%c at Reg. 0x%c\n",bh_i2c.addr,BH1749_MODE_CONTROL1);
	}
	
	char buff2[] = {BH1749_MODE_CONTROL2,BH1749_MODE_CONTROL2_RGB_EN_ENABLE};
	ret = i2c_write_dt(&bh_i2c,buff2,sizeof(buff2));
	if(ret != 0){
		printk("2- Failed to write to I2C device address 0x%c at Reg. 0x%c\n",bh_i2c.addr,BH1749_MODE_CONTROL2);
	}
	return 1;
}

void main(void)
{
	int ret;
	uint8_t bh_value[10]= {0};
	printk("BH1749 Example Thingy:53! %s\n", CONFIG_BOARD);
	init_bh1749();
	printk("BME68x Example Thingy:53! %s\n", CONFIG_BOARD);

	const struct device *bme = DEVICE_DT_GET_ONE(bosch_bme680);
	struct sensor_value temp, press, humidity, gas_res;


	if (!device_is_ready(bme)) {
		printk("sensor: device not ready.\n");
		return;
	}
	printk("Device %p name is %s\n", bme, bme->name);

	while (1) {
		k_sleep(K_MSEC(1000));
		// ret = i2c_burst_read_dt(&bh_i2c, BH1749_RED_DATA_LSB,bh_value,sizeof(bh_value));
		// if(ret != 0){
		// 	printk("3-Failed to read to I2C device address 0x%c at Reg. 0x%c\n",bh_i2c.addr,BH1749_RED_DATA_LSB);
		// }
		// else{
		// 	printk("Red Value:\t %d | ", bh_value[0] | bh_value[1] << 8);
		// 	printk("Green Value:\t %d | ", bh_value[2] | bh_value[3] << 8);
		// 	printk("Blue Value:\t %d | ", bh_value[4] | bh_value[5] << 8);
		// 	printk("IR Value:\t %d\n", bh_value[8] | bh_value[9] << 8);
		// }
		sensor_sample_fetch(bme);
		sensor_channel_get(bme, SENSOR_CHAN_AMBIENT_TEMP, &temp);
		sensor_channel_get(bme, SENSOR_CHAN_PRESS, &press);
		sensor_channel_get(bme, SENSOR_CHAN_HUMIDITY, &humidity);
		sensor_channel_get(bme, SENSOR_CHAN_GAS_RES, &gas_res);

		printk("T: %d.%06d | P: %d.%06d | H: %d.%06d | G: %d.%06d\n",
				temp.val1, temp.val2, press.val1, press.val2,
				humidity.val1, humidity.val2, gas_res.val1,
				gas_res.val2);
	}
}

this is main.c. Need help please.

Regards

Parents Reply Children
No Data
Related