Hello everybody. Does anyone have a working code to communicate BME280 with the nRF52 chip? Maybe in the form of a library?
Hello everybody. Does anyone have a working code to communicate BME280 with the nRF52 chip? Maybe in the form of a library?
Hello,
What SDK are you working with? Our nRF Connect SDK uses Zephyr OS which includes several samples for the nRF52 series, one being the BME280 Humidity and Pressure Sensor sample.
Kind regards,
Øyvind
It would be nice to see the code compatible with nRF5_SDK
It would be nice to see the code compatible with nRF5_SDK
I'm afraid I can't find any code examples for BME280 in the nRF5 SDK.
You can use our TWI examples from the Hardware Peripheral Examples in the nRF5 SDK, i.e. TWI Scanner Example or TWI Sensor Example. The latter is based on the LM75 sensor.
Kind regards,
Øyvind
Please tell me the code of the functions for reading and writing I2C in these tables. Using the functions nrf_drv_twi_tx and nrf_drv_twi_tx
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);