RAK811 I2C not always working
I using the Ping-Pong example as a base project in CoIde and trying to interface a BME280 sensor to the RAK811.
I have the I2C interface of the BME280 attached to PB_8 and PB_9 with the appropriate pull ups.
The I2C interface works correctly when using the standard RAK811 AT Command image and the at+rd_iic command.
However when I initialise the I2C interface via the SDK and try to read the data, it does not always work.
I have found that I need to reset the RAK811 module until it connects at a lower baud rate than the one programmed in the MCU initialisation. For example, if I set the initial UART1 baud rate to 115200, then if I press reset enough times until it connects at 57600, the I2C interface starts functioning correctly.
When I look at the I2C lines on the oscilloscope when it is not functioning correctly, after the initial I2C start signal, the SCL line starts sending clock signals continuously without any further activity on the SDA line.
To read the I2C, I am calling I2cInit(), I2cRead() and I2cDeinit()
It seems that something is only initialising correctly randomly, as i if I have missed a step.
Any ideas? Is there sample code on how the at+rc_iic command is implemented?
You could use Platformio and Ebiroll's repo to program rak-811 tracker board along side with stm32flasher as SWD debugger, the i2c protocol is working fine. Plus the repo has a BME280 library Apis for ease of access.
**Note include the library header <OBME280.h> in the main.c and call i2c_bme280_begin(); after MCUInit() before peripheral_init() in the int main() function before the main loop