1

I have an Arduino Pro Micro(blue version) and I'm having trouble using the I2C. To test it, I use the code below and the result is an infinite square wave on SCL and SDA lines and I only get the number 1 on the terminal output. I have pullup resistors on both wires, 2k each. Since the board uses an ATMEGA32U4, I tried the same code on a bare MCU and the code works as expected. The difference between the two is the bootloader type. The bare PCB is flashed over USB, using the factory bootloader(ATMEGA32U4-AU, QFP44). By debugging the code, I found out that endTransmission does not return. Does anyone have an idea, why the I2C is not working as expected on the Pro Micro module?

Thanks!

#include <Wire.h>

void setup() {
  Serial.begin (115200);
  // Leonardo: wait for serial port to connect
  while (!Serial)
    {
    }
  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0; 
  Wire.begin();
}  // end of setup

void loop() {
  byte count = 0;
  for (byte i = 1; i < 120; i++)
  {
    Serial.println(i);
    Wire.beginTransmission (i);
    Wire.endTransmission ();
    delay(10);
  }
}
10
  • What do you mean by "infinite square wave"? Does that mean, that both SDA and SCL get continuously pulsed forever, when Wire.endTransmission() blocks?
    – chrisl
    Nov 26 '20 at 13:38
  • Yes, and it does not stop. The waveform looks good, signal level is VCC and GND for 1 and 0.
    – therman
    Nov 26 '20 at 14:12
  • 1
    Mhh, strange. Does this also happen, when nothing is connected to the bus?
    – chrisl
    Nov 26 '20 at 14:24
  • 1
    Yes, that's right.
    – therman
    Nov 26 '20 at 15:06
  • 1
    And nothing is printing on the Serial Monitor? then I guess your microcontroller is broken. Your sketch seems legit to me. And the lines should never just pulse continuously. A common problem is the bus getting stuck, because one line gets stuck at low, but I haven't seen your problem ever. Can you tell us the frequency of the pulses? Just to check
    – chrisl
    Nov 26 '20 at 15:38
2

Seems like the module has a defect, since the same code on another board produces the expected output on the I2C lines

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.