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

Does anyone have a working code to communicate BME280 with the nRF52 chip?

Hello everybody. Does anyone have a working code to communicate BME280 with the nRF52 chip? Maybe in the form of a library?

Parents Reply Children
  • The TWI driver descriptions can be found in our documentation .

    TWI Master (your device is master)

    TWI Slave (your device is slave)

    Both nrf_drv_twi_tx and nrf_drv_twi_tx are found in integration\nrfx\legacy\nrf_drv_twi.h

    /**
     * @brief Function for sending data to a TWI slave.
     *
     * The transmission will be stopped when an error occurs. If a transfer is ongoing,
     * the function returns the error code @ref NRF_ERROR_BUSY.
     *
     * @param[in] p_instance Pointer to the driver instance structure.
     * @param[in] address    Address of a specific slave device (only 7 LSB).
     * @param[in] p_data     Pointer to a transmit buffer.
     * @param[in] length     Number of bytes to send.
     * @param[in] no_stop    If set, the stop condition is not generated on the bus
     *                       after the transfer has completed successfully (allowing
     *                       for a repeated start in the next transfer).
     *
     * @retval NRF_SUCCESS                  If the procedure was successful.
     * @retval NRF_ERROR_BUSY               If the driver is not ready for a new transfer.
     * @retval NRF_ERROR_INTERNAL           If an error was detected by hardware.
     * @retval NRF_ERROR_INVALID_ADDR       If the EasyDMA is used and memory adress in not in RAM.
     * @retval NRF_ERROR_DRV_TWI_ERR_ANACK  If NACK received after sending the address in polling mode.
     * @retval NRF_ERROR_DRV_TWI_ERR_DNACK  If NACK received after sending a data byte in polling mode.
     */
    __STATIC_INLINE
    ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance,
                              uint8_t               address,
                              uint8_t const *       p_data,
                              uint8_t               length,
                              bool                  no_stop);
    
    /**
     * @brief Function for reading data from a TWI slave.
     *
     * The transmission will be stopped when an error occurs. If a transfer is ongoing,
     * the function returns the error code @ref NRF_ERROR_BUSY.
     *
     * @param[in] p_instance Pointer to the driver instance structure.
     * @param[in] address    Address of a specific slave device (only 7 LSB).
     * @param[in] p_data     Pointer to a receive buffer.
     * @param[in] length     Number of bytes to be received.
     *
     * @retval NRF_SUCCESS                    If the procedure was successful.
     * @retval NRF_ERROR_BUSY                 If the driver is not ready for a new transfer.
     * @retval NRF_ERROR_INTERNAL             If an error was detected by hardware.
     * @retval NRF_ERROR_DRV_TWI_ERR_OVERRUN  If the unread data was replaced by new data
     * @retval NRF_ERROR_DRV_TWI_ERR_ANACK    If NACK received after sending the address in polling mode.
     * @retval NRF_ERROR_DRV_TWI_ERR_DNACK    If NACK received after sending a data byte in polling mode.
     */
    __STATIC_INLINE
    ret_code_t nrf_drv_twi_rx(nrf_drv_twi_t const * p_instance,
                              uint8_t               address,
                              uint8_t *             p_data,
                              uint8_t               length);

Related