1

Firstly, let me say that I'm new to using I2C devices, especially with Arduino. I have an 8-bit DAC (LTC2631) that I'm trying to control with an Arduino Uno. I thought I would be able to use the standard Wire library protocol to talk to it, but I'm not getting any response. Here's what I've tried:

#include <Wire.h>

void setup() {

    Wire.begin();
}

void loop() {
    Wire.beginTransmission(0x11); //specify device's address

    Wire.write(150); //send a test value

    Wire.endTransmission();
}

Am I missing something obvious? Or are not all I2C devices compatible with Wire?

  • did you check pins with here > – Parham Alvani Jun 8 '17 at 23:40
  • 1
    Start with a i2c scanner. This one: playground.arduino.cc/Main/I2cScanner or the one on this page: gammon.com.au/i2c Get the pins and wiring correct so the i2c scanner detects the chip. Only if it is detected by the i2c scanner, then you can try to talk to the chip. – Jot Jun 9 '17 at 8:39
  • 1
    @Jot Thanks! That sketch was really helpful. I was admittedly a bit afraid that I had the address wrong, but it shows up exactly as I had thought. So now I just have to figure out what's wrong with how I'm trying to communicate with it. – janizer Jun 9 '17 at 16:08
  • 1
    When the i2c scanner detects the chip, then the I2C is working. Read the datasheet, you need to send three bytes (not just one). The first byte has the C1,C2,C3,C4 in the highest bits, the other two bytes have the data. – Jot Jun 10 '17 at 6:56
0

Software: Wire should be fine. Of course, you usually will want libraries for each device. This particular ADC is designed for automotive use and I could not find a specific library for it so you are correct that you will need to speak with it directly. Here is the DATASHEET

I2C Hardware: On the Arduino Uno, SDA is A4 and SCL is A5.

One thing you almost always have to do with I2C is to provide a 10K pull-up to +5 on each pin (SDA and SCL) - I use a small breadboard whenever I use I2C, so I have power, ground, A4 and A5 available for pullups and multiple devices.

The reason for this is that the I2C bus is active-low. It signals by pulling the pins low in sequence to communicate.

If you already had the DS3231 RTC module on the same bus, which apparently you do not or you would not be asking this question, then you do not need your own pull-ups because the RTC includes them internally.


It might be easier for you to use a different I2C ADC such as the ADS1115.

Here is a generic search that shows the module:

https://smile.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=i2c+adcenter image description here

Here is a generic search which shows the software side:

https://www.google.com/search?q=arduino+ads1115+ADC+library+download

  • When you say talk to it directly, do you mean send it the data in the format outlined on page 22 of the datasheet, byte by byte? – janizer Jun 9 '17 at 16:12
  • Yes. For instance, think about how you use the serial port. Serial.begin(); then Serial.println(x); The Serial library is handling all the byte-by-byte and bit-by-bit stuff. I searched a lot and couldn't find an Arduino library that would make it easier for your device like that. Back to the OP, though, I suspect your only problem was the lack of proper pull-ups on the A4 and A5 lines - 10K to +5 on each. Armed with the datasheet that explains how the thing communicates, byte-by-byte might not be so bad. If you really want to make this thing work. – SDsolar Jun 10 '17 at 6:50
  • I agree that the first step (after adding pull-ups), is to run the IP Scanner program and make sure it responds. When it does, then you can go from there, with confidence that you are using the correct address.. – SDsolar Jun 10 '17 at 6:52
  • 1
    Even with the pull-ups connected, I couldn't get a response from it. :( I think I'll just find a similar DAC that's documented with Wire. Thanks for the help though! – janizer Jun 13 '17 at 14:32
  • Darnit. Anyway, look at my answer where I recommend the one I would use. – SDsolar Jun 13 '17 at 22:29

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.