Nucleo-64 STM32L476RG I2C not working

All about boards manufactured by ST
Post Reply
nbourre
Posts: 2
Joined: Fri Oct 22, 2021 7:13 pm

Nucleo-64 STM32L476RG I2C not working

Post by nbourre »

Hi guys,

I have a Nucleo-64 STM32L476RG and I did a simple program using the Cube[MX|IDE] to communicate with an I2C device and it works on pins A4 and A5.

On the other side using the Arduino IDE, I can't figure out what I'm doing wrong. The I2C scanner is not working in my case.

I'm surely missing something out.

Can someone guide me?

thank you
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Nucleo-64 STM32L476RG I2C not working

Post by fpiSTM »

Scanner example uses the default pins which are:
#define PB9 14
#define PB8 15
Which are D14 ans D15 not A4 and A5.
See the wiki to known how to change default Wire instance pins.
And of course you need pull up on each I2C lines.
nbourre
Posts: 2
Joined: Fri Oct 22, 2021 7:13 pm

Re: Nucleo-64 STM32L476RG I2C not working

Post by nbourre »

Thanks!

I managed to make it work using the following code before the begin():

Code: Select all

// ...
  Wire.setSDA(A4);
  Wire.setSCL(A5);
  
  if (!wire.begin()) {
// ... 
It works until, it starts to give plenty of 0s as values. I guess this is due to the lack of pullups.
Post Reply

Return to “STM boards (Discovery, Eval, Nucleo, ...)”