LTC2485 arduino library

I want to use LTC2485 with current meter as part of VA-logger.
Please help me to find library for this device or example sketch.

google gave me this code

update:
A quick look shows it is not a library and 7 yrs old code, but it could get you started.

datasheet

I CAN use Google and found this long time ago. That is why I created this topic. I'm looking for example code and library I can use in IDE. Files from "Linduino" I cannot connect to IDE.

@vitaliykrym

Sorry, you did not mention in your post what you did so far, so I assumed incorrectly that you had no information at all.

Searched a bit further and found no library not in the Arduino registry, not on Platformio.
On GitHub I found only partial pieces of code, but I assume you have seen those too.
So my conclusion is no (maintained) library for the LTC2485 exists.

The datasheet does not look too complicated, so writing / testing / registering etcetera an initial version could be done in 10 hours if no problems pop up. (estimate based on libraries written in the past).

2 Likes

@vitaliykrym

Created an initial version of an Arduino library for the LTC2485 as 24 bit for an ADC is interesting.

Currently the library has four examples.
The code is based upon the datasheet, and compiles for UNO, M4, ESP32 and RPIpico
The library is not tested with hardware, documentation is limited, no unit tests exists.

1 Like

Hello.
Thank you for library but non of examples are working.
Address 0x16. Ref 3.3V input 2.5V

LTC2485_connect:

Could not connect to device

2009	address: 22

4009	address: 22

6009	address: 22

8010	address: 22

After LTC.begin(); should be delay(200);

FILE: LTC2485_internal_temp_volt.ino

Could not connect to device

TEMP: 688.48

VOLT: 661.90

TEMP: 688.48

VOLT: 661.90

TEMP: 688.48

VOLT: 661.90

TEMP: 688.48

FILE: LTC2485_performance.ino

speed	micros

50000	1036

100000	552

150000	396

200000	332

250000	300

300000	268

350000	248

400000	244

450000	228

500000	220

550000	212

FILE: LTC2485_plot_microVolts.ino

Could not connect to device

microVolts

0.00

0.00

0.00

0.00

0.00

0.00

FILE: LTC2485_plotter.ino

Could not connect to device

TEMP 	 milliVolts

688.48 	 0.662

688.48 	 0.662

688.48 	 0.662

688.48 	 0.662

688.48 	 0.662

688.48 	 0.662

688.48 	 0.662

FILE: LTC2485_reject_50Hz.ino

Could not connect to device

ADC: 2147483647

ADC: 274631983

ADC: 276637956

ADC: 275681966

ADC: 273102616

ADC: 274233839

ADC: 273406856

ADC: 274928092

ADC: 274844750

ADC: 276156485

ADC: 274579567

ADC: 272766268

ADC: 274259707

| robtillaart
February 22 |

  • | - |

@vitaliykrym

Created an initial version of an Arduino library for the LTC2485 as 24 bit for an ADC is interesting.

Currently the library has four examples.
The code is based upon the datasheet, and compiles for UNO, M4, ESP32 and RPIpico
The library is not tested with hardware, documentation is limited, no unit tests exists.

github.com

GitHub - RobTillaart/LTC2485: Arduino library for LTC2485 I2C 24 bit ADC.

Arduino library for LTC2485 I2C 24 bit ADC.

OK, I do not have the hardware to test so I depend on you for that.

First thing to tackle is the connection.

Can you try this version of the connect sketch.
It has adjusted the address of the device.

//
//    FILE: LTC2485_connect.ino
//  AUTHOR: Rob Tillaart
// PURPOSE: detect device on I2C bus
//     URL: https://github.com/RobTillaart/LTC2485


#include "Wire.h"
#include "LTC2485.h"


//  adjust address if needed
//  0x14  CA1 = LOW  CA0 = HIGH
LTC2485 LTC(0x16);


void setup()
{
  while(!Serial);
  Serial.begin(115200);
  Serial.println(__FILE__);
  Serial.print("LTC2485_LIB_VERSION: ");
  Serial.println(LTC2485_LIB_VERSION);
  Serial.println();

  Wire.begin();
  Wire.setClock(100000);
  LTC.begin();
}


void loop()
{
  while (!LTC.isConnected())
  {
    Serial.println("Could not connect to device");
    delay(2000);
  }

  Serial.print(millis());
  Serial.print("\taddress: ");
  Serial.println(LTC.getAddress());

  delay(2000);
}


//  -- END OF FILE --

FYI, the library is updated to 0.1.1 this morning.
(no major changes)

After LTC.begin(); should be delay(200);

that would be a wait for the first conversion I assume?
Where in the datasheet is this delay mentioned?

I only see these

It is not mentioned but without it it shows "device not found" once.

I sent result before but here is hew one

C:\Users\maintbr\AppData\Local\Temp\.arduinoIDE-unsaved2025124-2380-1gksys6.zjtr\LTC2485_plotter\LTC2485_plotter.ino

LTC2485_LIB_VERSION: 0.1.1


Could not connect to device (this disapeares with delay(200);

2009	address: 22

4009	address: 22

6009	address: 22

8010	address: 22

10011	address: 22

12011	address: 22

14012	address: 22

16013	address: 22

18014	address: 22

20014	address: 22

22014	address: 22

| robtillaart
February 24 |

  • | - |

vitaliykrym:

Hello.
Thank you for library but non of examples are working.
Address 0x16. Ref 3.3V input 2.5V

OK, I do not have the hardware to test so I depend on you for that.

First thing to tackle is the connection.

vitaliykrym:

LTC2485_connect:

Could not connect to device

Can you try this version of the connect sketch.
It has adjusted the address of the device.

//
//    FILE: LTC2485_connect.ino
//  AUTHOR: Rob Tillaart
// PURPOSE: detect device on I2C bus
//     URL: https://github.com/RobTillaart/LTC2485

#include "Wire.h"
#include "LTC2485.h"

//  adjust address if needed
//  0x14  CA1 = LOW  CA0 = HIGH
LTC2485 LTC(0x16);

void setup()
{
  while(!Serial);
  Serial.begin(115200);
  Serial.println(__FILE__);
  Serial.print("LTC2485_LIB_VERSION: ");
  Serial.println(LTC2485_LIB_VERSION);
  Serial.println();

  Wire.begin();
  Wire.setClock(100000);
  LTC.begin();
}

void loop()
{
  while (!LTC.isConnected())
  {
    Serial.println("Could not connect to device");
    delay(2000);
  }

  Serial.print(millis());
  Serial.print("\taddress: ");
  Serial.println(LTC.getAddress());

  delay(2000);
}

//  -- END OF FILE --

OK, I can update the examples with the delay(200);
I assume it is for the first conversion as during conversion it might just not be able to answer I2C call.

Lets find out

Created a new develop branch.

This includes a new example LTC2485_getADC() which is the only one you need to test as it checks the core reading from the ADC.
I have modified the LTC2485::read() function to return the amount of bytes it got from the device.

uint32_t LTC2485::_read()
{
  uint32_t rv = 0;
  int n = _wire->requestFrom(_address, (uint8_t)4);
  if (n == 4)
  {
    _lastRead = millis();
    rv |= _wire->read();
    rv <<= 8;
    rv |= _wire->read();
    rv <<= 8;
    rv |= _wire->read();
    rv <<= 8;
    rv |= _wire->read();
    return rv;
  }
  return n;
}

So we can see if the device honors the request for 4 bytes.

I do not see new example.

May be it should be like this

rv |= _wire->read();
rv <<= 24;
rv |= _wire->read();
rv <<= 16;
rv |= _wire->read();
rv <<= 8;
rv |= _wire->read();

?

@vitaliykrym

this one should be in it.

//
//    FILE: LTC2485_getADC.ino
//  AUTHOR: Rob Tillaart
// PURPOSE: minimal test 
//     URL: https://github.com/RobTillaart/LTC2485


#include "Wire.h"
#include "LTC2485.h"


//  adjust address if needed
//  0x14  CA1 = LOW  CA0 = HIGH
LTC2485 LTC(0x16);


void setup()
{
  while(!Serial);
  Serial.begin(115200);
  Serial.println(__FILE__);
  Serial.print("LTC2485_LIB_VERSION: ");
  Serial.println(LTC2485_LIB_VERSION);
  Serial.println();

  Wire.begin();
  Wire.setClock(100000);
  LTC.begin();
  delay(200);
}


void loop()
{
  while (!LTC.isConnected())
  {
    Serial.print("Could not connect to device ");
    Serial.println(LTC.getAddress());
    delay(2000);
  }
  Serial.print(millis());
  Serial.print("\tADC: ");
  Serial.println(LTC.getADC());
  Serial.println();

  delay(2000);
}


//  -- END OF FILE --

no then the first 8 bytes would shift 24 + 16 + 8 = 48 places

Think you meant

rv = _wire->read() << 24;
rv |= _wire->read() << 16;
rv |= _wire->read() << 8;
rv |= _wire->read();

That would work too but need 48 bits to shift, where the library only uses 24.
For some processors this is less optimal.

C:\Users\maintbr\AppData\Local\Temp\.arduinoIDE-unsaved2025124-11820-6v2xjb.79hn\sketch_feb24a\sketch_feb24a.ino

LTC2485_LIB_VERSION: 0.1.1


206	ADC: 2147483647


2207	ADC: 2147483647


4208	ADC: 2147483647


6209	ADC: 2147483647

How it can give more then 2^24?
Looking at identical number I would say it does not read anything.

Have you downloaded the 0.1.2 develop branch?

Version 0.1.1 has no error handling, only a very crude flag. That is probably the cause.

And yes I agree it seems there is nothing read.

So I need some time to read the datasheet in more detail.