This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Alert pin for nrf52832

Hi,

I am using my nrf52832 board with a MPC9808 sensor and I wanted to use the example code provided in zephyr/samples/sensor/mcp9808

Can you tell me with which pin of the board I need to connect the Alert pin of the sensor?

Because when using the rc = sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp); I always get an error code.

Thank you for your help!

Parents
  • Hi,

    You can add an overlay to zephyr\samples\sensor\mpu6050\boards, for example add nrf52dk_nrf52832.overlay for nrf52dk_52832 board as

     &i2c0 {
    	mcp9808@18 {
    		compatible = "microchip,mcp9808";
    		reg = <0x18>;
    		int-gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    		label = "MCP9808";
    	};
    };

    Here pin 11 is assigned to detect Alert pin interruption.

    After building, you can check pin assignments for mcp9808 from zephyr\samples\sensor\mcp9808\build\zephyr\include\generated\devicetree_legacy_unfixed.h. It look lik

    ...
    /* SDA pin */
    #define DT_NORDIC_NRF_TWI_40003000_SDA_PIN          26
    #define DT_INST_0_NORDIC_NRF_TWI_SDA_PIN            DT_NORDIC_NRF_TWI_40003000_SDA_PIN
    /* SCL pin */
    #define DT_NORDIC_NRF_TWI_40003000_SCL_PIN          27
    #define DT_INST_0_NORDIC_NRF_TWI_SCL_PIN            DT_NORDIC_NRF_TWI_40003000_SCL_PIN
    ...
    #define DT_NORDIC_NRF_TWI_40003000_MICROCHIP_MCP9808_18_INT_GPIOS_CONTROLLER "GPIO_0"
    #define DT_INST_0_MICROCHIP_MCP9808_INT_GPIOS_CONTROLLER DT_NORDIC_NRF_TWI_40003000_MICROCHIP_MCP9808_18_INT_GPIOS_CONTROLLER
    #define DT_NORDIC_NRF_TWI_40003000_MICROCHIP_MCP9808_18_INT_GPIOS_PIN 11
    ...

    Just try this configuration to see if the error still exists.

    Best regards,

    Charlie

Reply
  • Hi,

    You can add an overlay to zephyr\samples\sensor\mpu6050\boards, for example add nrf52dk_nrf52832.overlay for nrf52dk_52832 board as

     &i2c0 {
    	mcp9808@18 {
    		compatible = "microchip,mcp9808";
    		reg = <0x18>;
    		int-gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    		label = "MCP9808";
    	};
    };

    Here pin 11 is assigned to detect Alert pin interruption.

    After building, you can check pin assignments for mcp9808 from zephyr\samples\sensor\mcp9808\build\zephyr\include\generated\devicetree_legacy_unfixed.h. It look lik

    ...
    /* SDA pin */
    #define DT_NORDIC_NRF_TWI_40003000_SDA_PIN          26
    #define DT_INST_0_NORDIC_NRF_TWI_SDA_PIN            DT_NORDIC_NRF_TWI_40003000_SDA_PIN
    /* SCL pin */
    #define DT_NORDIC_NRF_TWI_40003000_SCL_PIN          27
    #define DT_INST_0_NORDIC_NRF_TWI_SCL_PIN            DT_NORDIC_NRF_TWI_40003000_SCL_PIN
    ...
    #define DT_NORDIC_NRF_TWI_40003000_MICROCHIP_MCP9808_18_INT_GPIOS_CONTROLLER "GPIO_0"
    #define DT_INST_0_MICROCHIP_MCP9808_INT_GPIOS_CONTROLLER DT_NORDIC_NRF_TWI_40003000_MICROCHIP_MCP9808_18_INT_GPIOS_CONTROLLER
    #define DT_NORDIC_NRF_TWI_40003000_MICROCHIP_MCP9808_18_INT_GPIOS_PIN 11
    ...

    Just try this configuration to see if the error still exists.

    Best regards,

    Charlie

Children
Related