RAK3172 Breakout w/ I2C on STM32CubeIDE

I would like to use I2C burst read/write with the I2C2_SDA and I2C2_SCL pin s(RAK3172 breakout module) on STM32CubeIDE after getting the example project (LoRaWAN_End_Node) setup here: RAK3172 Module Low Level Development Reference | RAKwireless Documentation Center.

I am having trouble importing the correct libraries. I cannot find any instructions on how to accomplish I2C with this library in the docs. I mainly use MPLAB with PIC microcontrollers and Arduino wrappers for STM32 chips, so I do not really understand how to manually import libraries with the STM32CubeIDE. Any help and details would be greatly appreciated for the RAK3172 breakout module.

What I tried so far
I tried modifying the .ioc file to enable I2C, but this forces me to download version 1.1. It also has setup pin PA12 for I2C2_SCL and PA15 for I2C2_SDA, but I think looking at the schematic it should be PA11 for SDA. I tried modifying the version of the firmware package for 1.0, but other compilations issues came up when trying to recreate the code. I tried copying the Middleware examples for I2C, but the IDE didn’t pick up the I2C_HandleTypeDef, which I don’t think would be configured correctly because the microcontrollers is different than the original one this firmware was originally based on.

Thank you all in advanced for any help given.

Hi @applecrusher ,

I have limited experience with STM32CubeIDE but can you try to implement your I2C burst routine first on the default LoRaWAN_End_Node before doing any RF modifications based in our guide?

You are correct the I2C2_SDA should be PA_11.

Either PA11 or PA15 can be I2C2_SDA depending on which one pin you configure for Alternate Function 4, ST gives you a choice of what better fits your board / what you want to use the other pins for.

Setting both that way is not recommended :wink:

1 Like

I tried that. The problem is that the code generation in the default project is fixed to update to V1.1.0 even though it is the 1.0.0 project. And it tells me the LoRaWAN peripherals are wrong. If I force to use ProjectManager.FirmwarePackage=STM32Cube FW_WL V1.0.0 in the .ioc text, it gives me other issues compilations issues when regenerating the code. I tried downloading version V1.1.0 and can do exactly what you described, but the guide says that only 1.0.0 works. This is my dilemma with this now. I haven’t looked into LoRaWAN on 1.1.0, is there a reason why it is not recommended?

Hi @applecrusher ,

There is nothing really wrong with middleware V1.1.0. It such that the FW we developed is based on V1.0.0 and during that time, V1.1.0 is not yet available.

You can try this implementation in V1.1.0 which is a contribution of one of the RAK3172 users Oliv' / RAK3172 ST stack template · GitLab.

That sounds good. I had success compiling with the I2C library with the LoRaWAN libraries using this repo, and will report my progress in the coming days. I now seem to have issues using STM32Programmer with both ST-LINK and UART on the two breakout devices I got from you. I will bring that up in more detail on a different topic.