Arduino Uno, I2C, Wire.endTransmission(); freeze

I’m using AD5258 digitalpot, but my arduino cannot control it, and my program always freeze at Wire.endTransmission();[Which means the program stuck there

#include <Wire.h>

int dt = 1000;
byte val = 0;
int led =13;
boolean ledOn=LOW;

void setup()


void loop()
    Serial.print(" sent - ");

    if(val == 64)
      val = 0;


My code is quite simple, I just want to use arduino to control digitalpot so as to supply a specific voltage. I need ur help~~ Thx a lot~

Here is my connection,thx for ur help urgent!!!


Cross-posting. Continue here :

Try the i2c scanner to see if the I2C-bus is working.

Check the I2C-bus (A4 and A5) for shortcuts.

Hello gybmage,

Could you also tell what WireEndTransmission error are you getting? I mean...

byte error = Wire.endTransmission();



Palliser, for the byte error = Wire.endTransmission(); , I got nothing, everytime when comes to Wire.endTransmission(); will just stuck there, also the Scanner return nothing.

Thx Peter , but the scanner cannot return anything, can u have a look at this picture?~ =( =( =(. The Serial Monitor would keep like this .

I'm first time using arduino, I guess is it because my connection? First time design my own circuit and do the project, really stuck here, I CHECKED all the datasheets alr still cannot find out can someone also help me to check the AD5258 datasheet?~~ pls =( =( I stuck two weeks alr~~~

Palliser, for the byte error = Wire.endTransmission(); , I got nothing, everytime when comes to Wire.endTransmission(); will just stuck there, also the Scanner return nothing.

I wanted you to print the error like…

byte error = Wire.endTransmission();

What do you get? 1,2,3 or 4?


The question is byte error = Wire.endTransmission(); , there is a Wire.endTransmission(), it never return anything and stuck there so anything below Wire.endTransmission(); cannot work

Something New(***): I tried a new AD5258 Digitalpot using I2C Scanner and it turned out that the address is 0x18, but after I upload my own program, I then tried to scan the address again, it keeps scanning~. So I want to ask is it because I broke the DIgitalpot IC????

Any professional ppl can have a look?~~ =( =( =(

Don’t panic, we do this step by step.

Thanks for the screendump of the i2c_scanner. That might happen if A4 is shortcut to A5, or if one of them is shortcut to GND or 5V.

First we test the hardware.
Can you disconnect any I2C device.
Measure A4 and A5, they should be 5V (because of the pullup resistors of 10k).
Test if they are shortcut to GND or 5V or to each other.
Run the i2c_scanner (without any I2C device), it doesn’t find something, but does the scanner run ?

If the scanner doesn’t run, there must be a problem in the hardware or the ATmega chip is broken.

Thx Peter I take out the device and test, they are not shortcut to +5V OR GND, and the scanner shows well. I think my circuit is not properly designed, forgive me my English not well, I went through the datasheets many times but still not quite understand some of the parts, is it because I missed some important part that I should’t set up like this???

Here’s the AD5258 Digital Potentiometer Datasheet, I really went through many times still cannot find where the problem is~~~

AD5258(Best Choice).pdf (528 KB)

And you are using only the pot, or a shield with the pot?

EDIT: You are using Arduino UNO, right?

Hi Luisilva, I'm suing the pot only . Yes, I'm using Arduino Uno

I think the problem is related with the hardware, but I don't understand why.

Looking inside the libraries, the execution can be froze in 2 places:

  while(TWI_READY != twi_state){
  while(wait && (TWI_MTX == twi_state)){

I don't see how any of these 2 can block the execution.

Can you change the resistor by 4k7 or something like this?

EDIT: Are you sure that you have SDA connected to A4 and SCL connected to A5, right?

Is this a correct summary of the situation?

You installed a new AD5258 in your breadboard and the I2C scanner found the device at 0x18.

You upload your sketch and when executed it gets stuck in the Wire.write---Wire.endTransmission portion of your code.

You scan again for the AD5258 and and the I2C scanner shows "Scanning.." like in the image in your post #7. QQ??20140723111829.png
but does not finish. It does not find the device or show no devices, but just stops and says Scanning.

Hi cattledog. Yes, and everything before Wire.endTransmission(); still can run, but only the program after it cannot run. I guess my circuit may broke the digitalpot chip. :astonished: