cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure I2C connection in BLE Mesh

EBozb
Associate II

I want to create a mesh in which every node (BlueNRG 2) share some sensor measurements to each other. The measurements should be transmitted over an I2C connection from a sensor module. My Problem is now that I can't configure a working I2C connection because the device can't be found at the sensor module. I'm just copying the I2C slave polling project for this purpose. The I2C slave polling project works fine when I exceute it allone without the mesh stuff in TrueStudio. But when I compile it in Keil with the mesh project (version 1.007) the problem appears again.

13 REPLIES 13
alok
Senior

Just to be sure, BlueNRG-2 is I2C master for a sensor.. Is it correct ?

We already have an example for it, if you enable sensor model in "mesh_cfg_usr.h" by un-commenting the following:

#define ENABLE_SENSOR_MODEL_SERVER

You can also look for the function LPS25HB_GetTemperature, which implements reading the LPS25HB Sensor reading via I2C

EBozb
Associate II

Hi @alok​ ,

thank you for your response. But I want to configure the BlueNRG-2 as a slave node, because I need a bidirectional link and there is no possibility to implement the mentioned sensor module (,which gets the sensor data from a board with all sensors via canopen) as a slave. I am using Smbus in python for coding the i2c api in the sensor module. My problem is that, with Keil the i2c device adress from the BlueNRG can't be found in the sensor module. However the same code with TrueStudio does work. Any guesses why this can happen ? And are there already implemented functions to send data from the BlueNRG-2 as a slave via i2c ?

Winfred LU
ST Employee

For the sample codes of BlueNRG-2 being an I2C slave device,

Please refer to BlueNRG-2 SW DK

https://www.st.com/content/st_com/en/products/embedded-software/evaluation-tool-software/stsw-bluenrg1-dk.html

in the folder

C:\Users\<user ID>\ST\BlueNRG-1_2 DK 3.1.0\Project\BlueNRG1_Periph_Examples\I2C\Slave_Polling

Sample projects are available for IAR EWARM, Keil MDK-ARM, and Attolic TrueStudio.

alok
Senior

@ertugrul.bozbiyik1.5627569113028164E12 (Amprio GmbH)

I am not still sure if I understood well your implementation. In my opinion, the BlueNRG-2 shall be I2C master. Your Sensor module is intelligent ? It has a MCU on board ?

What concerns the differences of behavior using different compilers, this can happen. please try different optimization levels of compilers. Or, you can try to review the I2C bus communication to check for physical level I2C bus communication to check the possible issue.

EBozb
Associate II

@alok​ 

The sensor module is something like the raspberry pi (the name is BeagleBone Blue) with a MCU yes. It must be the master in my case. So how to modify level of optimization in TrueStudio or Keil ? And is it possible to send data to the master as a slave in the BlueNRG-2 SW DK proposed firmware ?

EBozb
Associate II

@alok​ 

I have now figured out how to change the optimization level but it still doesn't work. Please have a look in BlueNRG-2 SW DK at the Slave_Polling project. The binary which is build with TrueStudio or Keil differs from that one in the software tool BlueNRG-2 Navigator (where you can flash from the GUI). I've already checked all optimizations levels.

Modify optimization level in Keil MDK:

menu | project | options | C/C++ | Language | Optimization

The binary is different than prebuild one because the prebuild bianry was built with IAR EWARM. But even if you use the same IDE, chances are it will still be different due to the toolchain version or project configurations.

It is possible to send data to an I2C master as a slave.

Please note that an I2C slave does not send data to the I2C master actively.

Instead it waits until the master issue a read, it acknowledges master's polling its address, then sends the data in the given period.

Please reference the Slave_Polling project , main.c for the part "Read-from-slave request received ", line 132 -156, and customize according your master.

alok
Senior

"The sensor module is something like the raspberry pi (the name is BeagleBone Blue) with a MCU yes. " -> Thanks for clarifying. The word "Sensor Module" was confusing.

Do you have probe on the I2C bus to check what is going on in the communication ?

Can you try with 2x BlueNRG-2 boards to check master-slave communication between them to check that the software example is working fine ?

Possible for you to review if another communication interface like UART or SPI can be tried between BeagleBone and BlueNRG-2 ?

EBozb
Associate II

@alok​ @Winfred LU​ ​ I have already examined the i2c bus communication. It turned out that the fifo buffer (I2C_FillTxFIFO in line 143 and 152) is not written to.  I've already checked before if there is a hardware problem but the communication works with the prebuilt binary. So it can't be a hardware error.

@Winfred LU​ "It is possible to send data to an I2C master as a slave." -> Ok thanks, this is good to know.

@alok​ "Can you try with 2x BlueNRG-2 boards to check master-slave communication between them to check that the software example is working fine ?" -> I've already checked this before. The problem is similar. For the prebuilt binaries from the BlueNRG-2 Navigator tool it works fine. But when I flash a binary, which is compiled with Keil or TrueStudio it still doesn't work as it should be. When I press a button for letting the LED toggle, it works the first time and then remains in this state. So I can't toggle anymore other LED's.

@alok​ "Possible for you to review if another communication interface like UART or SPI can be tried between BeagleBone and BlueNRG-2 ?"-> Unfortunately, this is not possible, because this is fixed by the company.

Please can you try to compile the slave polling example yourself with TrueStudio or Keil compiler and look if it's working fine for you? Maybe you can reproduce the error.