Ldc1612 I2C communication with UNO

Howdy,

I am trying to read values of induction sensor LDC1612 which uses I2C communication on Arduino UNO.

The sensor address/id is 0x2A and below is a code I tried writing and failed terribly at.
Any help/advice/guidance/suggestion is highly appreciated.


#include <Wire.h>

void setup() {
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
}

void loop() {
  Wire.requestFrom(0X2A, 6);    // request 6 bytes from peripheral 0x2A

  while (Wire.available()) { // peripheral may send less than requested
    int c = Wire.read(); // receive a byte value (i am not sure if value is int or other)
    Serial.println(c);         // print the value
  }

  delay(500);
}

I know this should be a simple code to just read the values from the sensor (I want to observe the change in magnetic field and quantify it as any object enters the proximity radius of this system) but it is my first time using I2C and I am finding it very difficult to understand the concepts. I referred to the LDC library already but that code is throwing error.

PLEASE HELP ME OUT WITH THIS

The first thing to do is to run a I2C Scanner sketch. Does it find the 0x2A ?
If the chip cannot be found, you have to fix the I2C bus first.

The next thing is to read a ID from the chip. It has a manufacturer ID and a device ID.
Try to read those. You can use the "readRegister()" function from that library.

Then you could try to fix that library or find a other library.

Can you write what the result of a test is ? We like to know everything and all the specific details. If there is an error, you can copy the compiler output and put it in a code-field to show it to us.

Yes, 0x2A is found out by running the scanner example of I2C.

Here is the device and manufacturing id


more details can also be seen in the pdf which I have already attached above, if needed.

The code above doesn't show any changes in the reading and just prints 255 or 0. There is only one library re-linking it here which I could find for LDC1612, I will be truly grateful if you could help me with more.

I meant that you have to write a sketch that reads those IDs. If you can read those numbers then you know that you can communicate with chip. The function "readRegister()" from that library shows how to read two bytes from a register of the chip.

Show a full sketch that reads those numbers :sunglasses:

You may try the following sketch: (This program prints data bytes that are coming from the sensor.) Check Section-8.4 of data sheets if you need to configure the sensor and add necessary codes with the sketch.

#include <Wire.h>

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
  Wire.beginTransmission(0x2A);
  byte busStatus = Wire.endTransmission();
  if (busStatus != 0)
  {
    Serial.print("Device/Sensor is not found!");
    while(1);  //wait for ever
  }
  Serial.print("Device/Sensor is found.");
}

void loop()
{
  byte m = Wire.requestFrom(0x2A, 6);    // request 6 bytes from peripheral 0x2A
  for (int i = 0; i < m; i++)
  {
    byte y = Wire.read();
    Serial.println(y, HEX);
  }
  delay(1000);  //test interval
}
1 Like

Hey GolamMostafa,

Thanks a lot! I finally have some values on screen. Attaching a screenshot below. Do you know why I have values like that(all "FF" or "0")? I was expecting them to be numbers that display strength of magnetic field or change of voltage or something of that type.


Thanks a lot again!

I think you need to configure the sensor.

1 Like

Thank you so much for guiding me here, I'll get started with learning about sensor configuration :+1:

1 Like

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