I2C HMC5983 communication issue

Hi,
I have a really weird problem, when I run the exmple wire (I2C) scanner from Arduino, I get:

I2C Scanner
Scanning...
I2C device found at address 0x1E !
done

However when I try directly to the 0x1E I get the following error code 2:

received NACK on transmit of address.

Below is my code that i did only modify the example code:

#include <Wire.h>

void setup() {
  Wire.begin();

  Serial.begin(9600);
  while (!Serial); // Leonardo: wait for Serial Monitor
  Serial.println("\nI2C Scanner");
}

void loop() {


  Serial.println("Scanning...");

  byte address = 0x1E;

  Wire.beginTransmission(address);
  byte error = Wire.endTransmission();

  if (error == 0) {
    Serial.print("I2C device found at address 0x1E");
  } else if (error == 1) {
      Serial.print("data too long to fit in transmit buffer.");
  }
  else if (error == 2) {
      Serial.print("received NACK on transmit of address.");
  }
  else if (error == 3) {
      Serial.print("received NACK on transmit of data.");
  }
  else if (error == 4) {
      Serial.print("Unknown error at address 0x");
  }

  delay(5000); // Wait 5 seconds for next scan
}

Welcome to the forum.

Your test sketch is good.
It might be hardware related. Perhaps your I2C bus is barely working. I can think of many ways that causes this. Can you tell more ? For example which Arduino board and which device they are ? Can you give a link to where you bought that device ?

[UPDATE]
I see now that you have "HMC5983" in the title. That is a 3.3V chip. If you connect that to a 5V Arduino board then there might be a voltage level problem on the I2C bus.

1 Like

Hi Koepel, thank you for your answer, I have tested with Uno and Nano, but both the same issue, the board is GY-282, and I have even power it with 3.3V.
Unless it is the chip tolerance to 5V i2C bus, I would say that is a hardware related issue, since I can see in the internet that people could use the board with Arduino.
Regards.

Post an annotated schematic showing all of the connections as you have wired it. Also links to "Technical information" on the hardware devices. Sales links such as azon are generally useless.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.