Using LSM6DSO sensor on NRF52832

Hello, 

I'm new to pretty much all of this, but I'll do my best to explain my issue. As the title says, I'm currently trying to get a LSM6DSO sensor to work with the NRF52832 board. I'm using the Nordic sample code for LSM6DSO and using VSCode to build it for the NRF52832. I was having issues with the devicetree not being able to find the sensor using DEVICE_DT_GET_ONE (this function initially returned a negative value), so I added an extra overlay file: 

arduino_i2c: &i2c0 {
    lsm6dso@6a {
        compatible = "st,lsm6dso";
        label = "LSM6DSO";
        reg = <0x6a>;
    };
};
This seemed to fix the issue. The only other thing I changed from the base project code was adding the lines
CONFIG_LOG=y
CONFIG_LOG_PRINTK=y
to my prj.conf file so that I could log any errors.
I've fully connected the sensor to the board and have verified the connections are correct using a colleagues code, so I don't think the connections are the issue. When I build and flash the code, this is the output I get:
As I said, I'm fairly new to how Nordic organizes code and devicetree, so I'm really just not sure what to do from here. Obviously, the code is running through its main function, but it gets an error when it tries to test the trigger mode. I believe the sample code is supposed to work with an ST board, so I think getting this code to work is just a matter of making small changes to the overlay files or the configuration files, although I could easily be wrong.
Any advice would be greatly appreciated, and let me know if I can provide any more information that might help. Thank you!
Parents
  • I was in your position about half an hour ago. I believe trigger mode is flagged as unsupported because you haven't specified the trigger pin in your overlay. The error message is resolved for me when I specify int-pin and irq-gpios (with int-pin being either 1 or 2, and selecting between the first and second listed IRQ GPIO):

    &spi1 {
    	status = "okay";
    	cs-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
    			   <&gpio1 11 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	lsm6dso@0 {
    		compatible = "st,lsm6dso";
    		reg = <0x0>;
    		spi-max-frequency = <8000000>;
            status = "okay";
    		irq-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>, <&gpio1 13 GPIO_ACTIVE_HIGH>;
            int-pin = <1>;
    	};
    };

Reply
  • I was in your position about half an hour ago. I believe trigger mode is flagged as unsupported because you haven't specified the trigger pin in your overlay. The error message is resolved for me when I specify int-pin and irq-gpios (with int-pin being either 1 or 2, and selecting between the first and second listed IRQ GPIO):

    &spi1 {
    	status = "okay";
    	cs-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
    			   <&gpio1 11 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	lsm6dso@0 {
    		compatible = "st,lsm6dso";
    		reg = <0x0>;
    		spi-max-frequency = <8000000>;
            status = "okay";
    		irq-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>, <&gpio1 13 GPIO_ACTIVE_HIGH>;
            int-pin = <1>;
    	};
    };

Children
  • Thank you for the response. So the changes I would need to make to my overlay file are to add something like 

            status = "okay";
    		irq-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>, <&gpio1 13 GPIO_ACTIVE_HIGH>;
            int-pin = <1>;

    to my overlay file? In your example, it looks like you're using spi whereas I'm using I2C. I also see that you specified pins 12 and 13 as the irq-gpios. For me, would those be the same pins as I'm using for the I2C connections (26 and 27)? Thanks!

  • I played around with a few combinations and am still getting the same error.

  • I'm not sure if specifying the int pin is necessary, it may already be done in the sample code. The GPIOs should be based on your specific setup. I'm running this on a custom PCB with an nRF52840 so my pinout is likely going to be different from yours, which is also why I used SPI rather than the I2C sample default. In the overlay file you can modify the pins to your liking (for the most part) since GPIOs on Nordic chips are muxed. That is, you can change both the I2C bus pins and the pins tied to your IMU. You want to pick different GPIOs for the interrupt pins than the ones you're using for the I2C bus. Pick ones that look unused and then wire the chosen GPIOs to the INT1 and INT2 pins on your LSM6DSO.

    To troubleshoot the error message, you can enable debugging in your prj.conf with CONFIG_LOG_DEFAULT_LEVEL, CONFIG_SPI_LOG_LEVEL, and CONFIG_SENSOR_LOG_LEVEL. Can you share your full prj.conf file?

    Some additional information that may be beneficial for you:

    • Zephyr has a guiconfig, which can also be accessed by pressing "nRF Kconfig GUI" in the Actions sidebar if you have Nordic's VSCode extension
    • Nordic offers a DeviceTree Visual Editor UI with the VSCode extension
    • Hovering over "st,lsm6dso" will take you to the "st,lsm6dso-12c.yaml" sensor bindings file, which then links you to the two includes "i2c-device.yaml" and "st,lsm6dso-common.yaml". These files should list all the configurations available for the I2C bus and for your specific peripheral if you don't want to use the GUI tools.
    • If you haven't already, I would start with CONFIG_LSM6DSO_TRIGGER_NONE instead of TRIGGER_GLOBAL_THREAD to disable trigger and enable polling. Polling mode is more straightforward and does not require the interrupt pin configuration, so you can confirm everything else works in your code.
    • Tucked away in /modules/hal/st/sensor/stmemsc/lsm6dso_STdC/driver you'll see LSM6DSO_ID defined as 0x68. I was using a variant that had a different chip ID, which caused the process to fail. That doesn't seem to be your issue if the error you're seeing is still trigger_set op not supported, but it's probably worth mentioning in case anyone else with the same problem sees this in the future.

    Full disclaimer I'm just some random guy so I would take this information with a grain of salt. Hopefully a Nordic dev is able to help you figure out the root cause if we aren't able to narrow down the problem before then.

  • Hey, thank you for this super detailed response! I won't be using trigger mode for my application, so I just disabled it in the .conf file as you suggested. As soon as I did that, I was able to get actual readings from the sensor. Appreciate it!

Related