Arduino Due connecting MLX sensor on pin SDA1 and SCL1 pin

Dear forum members,

I am trying to find a way to use a second I2C device on my Arduino Due using the SDA1 and SCL1 ports (NOT 20 and 21, the other 2). However, 20 and 21 do seem to work with the wire.h library but SDA1 and SCL1 are not working.
I used Arduino Due I2C scanner (link: Multi speed I2C scanner for Arduino Due · GitHub
which is perfectly detecting address when the mlx temperature sensor is connected at SDA(20) and SCL(21) pin but no address is found when mlx sensor is connected at SDA1 and SCL1 pin.
I read all the forum threads on this topic in which the solution was to change Wire.h to Wire1.h wherever needed, but this solution is not working for me.
I am using the code (Library for MLX90614 on Arduino DUE - Arduino Due - Arduino Forum)
where if I connect sensor at SDA(20) and SCL(21) pin and the code is for WIRE_INTERFACE it is reading the temperature but when the sensor is connected at SDA1 and SCL1 pin and changing the code to WIRE1_INTERFACE, is not reading any data.
I just want to read data from the sensor connected at SDA1 and SCL1 and communicate with Rpi connected at SDA(20) and SCL(21) pin.
Also please explain me the part (#if WIRE_INTERFACES_COUNT > 0
extern TwoWire Wire;
#endif
#if WIRE_INTERFACES_COUNT > 1
extern TwoWire Wire1;
#endif)
which is there in Wire.h library
Can you help me out?

Firstly, AFAIK, the Wire library can't be used with both I2C buses at the same time. For that you want to program your own code with TWI registers. Note that SDA/SCL are related to TWI1 whereas SDA1/SCL1 are related to TWI0.

Secondly, unlike SDA/SCL, SDA1/SCL1 have no pull-ups. Therefore 1K pull-ups should be added on these lines (connected to 3.3V).

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