Arduino Leonardo I²C problem (AD5933)

Hey, So i am working in my Master projet of making a Bioimpedance sensor using the AD5933 chip. for That till now i used a Arduino Nano connected to the chip using I²C bus and the nthe serial monitor to read the data. So far the first program worked. I am also adding a multiplexer. this is the circuit :

http://www.analog.com/media/en/reference-design-documentation/reference-designs/CN0217.pdf

So far it worked and i had no prolems with it. The idea its to use as less space as possible, it should fit in a machine. For that i wanted to burn the arduino bootloader in a ATmega32u4 (Leonardo's microcontroller) because of the built in USB interface. So i manage to do that, so i have my own Arduino Leonardo clone. The problem is tha now the code doesnt work, or at least the serial monitor.

Once the sktch is uploaded i should go to the serial monitor and use it but i can't. THe problem seems to be the I²C or the AD5933 (i am using a library), because without them, the serial monitor works, but when i add the bus or the chip commands it doesnt work. I went back and use again the Nano and no problem. So its something about the Leonardo.

Someone has an idea?
Thanks

On the ATmega32U4, where did you connect the SDA/SCL signals from the AD5933 to?

Post the code your writing about! (don't forget to use code tags, the </> button in the editor)

Did you change the board settings to the Leonardo in the IDE?

Do you use the Arduino Leonardo or a custom ATmega32U4 board?

Hey, so for connections i have used the PD0 (Pin 18, SCL) and PD1 (Pin 19, SDA) from the microcontroller. I checked everything before connections if it was that, but i am sure i connected properly.

I dont think its the code, because without changes it works in a Arduino Nano. It has to be something about the Leonardo.

I did checked the settings and everything in the IDE, i can use the Leonardo normally, the serial monitor does work normally but not with I²C bus or the AD5933 library commands.

If you go to the link i provided in the original post you can see the board, i am just using a ATmega32u4 with the Arduino Leonardo bootloader installed, and then the minimum things to make it works, such as the powersupply, quartz crystal and a reset button. Basically its a Leonardo copy and should behave as one (Its my first time using a Leonardo, but i needed to use this chip because of the USB interface),

The exact same program worked for a Nano, and without changes it didnt work on the Leonardo, the problem i see is tha it cant use the I²C or in this case the Wire bus correctly.

The code is long to i will just upload the sketch completely

AD5933.ino (7.35 KB)

If you go to the link i provided in the original post you can see the board, i am just using a ATmega32u4 with the Arduino Leonardo bootloader installed, and then the minimum things to make it works, such as the powersupply, quartz crystal and a reset button. Basically its a Leonardo copy and should behave as one (Its my first time using a Leonardo, but i needed to use this chip because of the USB interface),

In the original post I see only a link to the circuit note of Analog Devices. I cannot see anything there that resembles a Leonardo or even an ATmega32U4 board.
A Leonardo has a bunch more components than you listed above (I made a derivation of it too, so I know it the hard way). Most of them are to save your PC from being damaged by the connected board. Did you omit them?

Do you have external pull-ups for the I2C signals?

The exact same program worked for a Nano, and without changes it didnt work on the Leonardo, the problem i see is tha it cant use the I²C or in this case the Wire bus correctly.

    pinMode(2, OUTPUT); // Enable
    pinMode(3, OUTPUT); // S2

PD0 connects to D3 and PD1 connects to D2, so you must have something done wrong. Post wiring diagrams for both setups (Nano and ATmega32U4, may be hand-drawn but complete)!

Sorry, i thought i put the other link. Here it is:

https://murchlabs.com/monday-experiment-bootloading-an-atmega32u4-with-arduino/

Basically its a really simple circuit with nothing but the minium to work.

Ihave used the pull-ups for the i2c. The circuit is the same as the on from the link but with the I2C connections.

also i used this for reference:

As you can see the PD0 connects to D3 which is the pin 18 from the microcontroller, the SCL. And the PD1 to D2, pin 19 of the microcontroller, the SDA. Beleive me i have testes if everything was correct but nothing. Tomorrow i will test again in the office, i can also draw the onnections and show here.

As you can see the PD0 connects to D3 which is the pin 18 from the microcontroller, the SCL. And the PD1 to D2, pin 19 of the microcontroller, the SDA. Beleive me i have testes if everything was correct but nothing. Tomorrow i will test again in the office, i can also draw the onnections and show here.

You didn't get my point. In the sketch you define D2 to be an "enable" output and D3 to be an S2 output but these two pins are the I2C bus so you cannot use them for both functions at the same time.

Okay, i didn't realise about it, but anyway that's not the problem. I have tried without it and still it doesnt work. Also i tried another code to test I2C and still nothing. It doesnt seem that is the Pin configuration. It doesnt work not even changing that part.

Thanks for taing interest, but i will just use the nano in the end. It does work with my code and the entire system, so it will be better, and apparently there is no problem with the space. It is going to be the same cod just changing some stuff, adding multipexer and making some pars automatic.

I like it too. I'm using arduino uno to communicate with AD 5933, which I can now run. Communicate with each other That is, the frequency and payroll control. But in the field of reading impedance does not work.

Hi,

What chip/electronics did you use for multiplex?

Working in similar project.