This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sample code for an ADXL accelerometer (e.g 355, 357 or 375) working with nRF9160DK via SPI

Hi, as the title reads I would be very happy if anyone has successfully integrated one of these (or a similar) sensor with the nRF9160DK. I have integrated all three on a RPI4 but that is childsplay compared to doing it with the nRF9160. Any help would be very much appreciated.

Thank you!

Parents
  • Hi Øyvind! I did however I ran into errors, I thought that because of the board selection for the example that it did not work on nRf9160DK without some tweaking that might be beyond me. I ran into this error:

    "No adi, adxl372 compatible node found in the device tree".


    I looked at the settings of the proj and found this under the spi3 in the device tree:



    Now, I assume the idea is of me connecting my sensor according to the pin numbers in the list, which I did, I am however not certain that that would be enough for it to be found in the device tree.

    Any tips or tricks or knowledge gap fills would be much welcome, thank you!

    Warm regards

  • Hello, 

    Yes, you will need to tweak the sample to fit with your device. A comparison of the different sensors is needed to ensure that all settings align with the drivers found in zephyr\drivers\sensor\adxl372. 

    Also, in the ADXL372 sample, you will need to add an overlay that configures the pins that your device is connected to. Have a look at zephyr\samples\sensor\adxl372\boards\nrf52dk_nrf52832.overlay. 

    For example, the Thingy:91 devicetree configuration (nrf\boards\arm\thingy91_nrf9160\thingy91_nrf9160_common.dts) configures the spi3 and ADXL372 in the following way:

    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	sck-pin = <3>;
    	mosi-pin = <4>;
    	miso-pin = <5>;
    	cs-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>, <&gpio0 7 GPIO_ACTIVE_LOW>;
    
    	adxl362@0 {
    		compatible = "adi,adxl362";
    		label = "ADXL362";
    		spi-max-frequency = <8000000>;
    		reg = <0>;
    		int1-gpios = <&gpio0 9 0>;
    	};
    
    	adxl372@1 {
    		compatible = "adi,adxl372";
    		label = "ADXL372";
    		spi-max-frequency = <8000000>;
    		reg = <1>;
    		int1-gpios = <&gpio0 6 0>;
    	};
    };

    In your case you can configure similar in nrf9160dk_nrf9160_ns.overlay based on the pins you have connected the device to. Note that the nRF9160 DK uses a board controller which switches pins as needed, you should connect your sensor to pins that are not connected to the board controller. Please see the Working with nRF9160DK documentation, and the nRF9160DK User Guide

Reply
  • Hello, 

    Yes, you will need to tweak the sample to fit with your device. A comparison of the different sensors is needed to ensure that all settings align with the drivers found in zephyr\drivers\sensor\adxl372. 

    Also, in the ADXL372 sample, you will need to add an overlay that configures the pins that your device is connected to. Have a look at zephyr\samples\sensor\adxl372\boards\nrf52dk_nrf52832.overlay. 

    For example, the Thingy:91 devicetree configuration (nrf\boards\arm\thingy91_nrf9160\thingy91_nrf9160_common.dts) configures the spi3 and ADXL372 in the following way:

    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	sck-pin = <3>;
    	mosi-pin = <4>;
    	miso-pin = <5>;
    	cs-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>, <&gpio0 7 GPIO_ACTIVE_LOW>;
    
    	adxl362@0 {
    		compatible = "adi,adxl362";
    		label = "ADXL362";
    		spi-max-frequency = <8000000>;
    		reg = <0>;
    		int1-gpios = <&gpio0 9 0>;
    	};
    
    	adxl372@1 {
    		compatible = "adi,adxl372";
    		label = "ADXL372";
    		spi-max-frequency = <8000000>;
    		reg = <1>;
    		int1-gpios = <&gpio0 6 0>;
    	};
    };

    In your case you can configure similar in nrf9160dk_nrf9160_ns.overlay based on the pins you have connected the device to. Note that the nRF9160 DK uses a board controller which switches pins as needed, you should connect your sensor to pins that are not connected to the board controller. Please see the Working with nRF9160DK documentation, and the nRF9160DK User Guide

Children
Related