-->
Page 1 of 2

multiple i2c devices with arduino

PostPosted: Thu Dec 06, 2018 5:25 am
by epy hobb
HI,

i am trying to interface SSD1306 and MLX90614 i2c devices with ESP8266 mcu. but both devices are not working together..
if i comment out code for display then it is working for mlx90614.
Here is part of my code..

Code: Select all#include <Wire.h>
#include <Adafruit_MLX90614.h>
#include "SSD1306Wire.h"


Adafruit_MLX90614 mlx = Adafruit_MLX90614();
//SSD1306Wire  display(0x3c, D3, D4);

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit MLX90614 test"); 
  mlx.begin(); 
  Wire.begin(D2,D1);

  /************************************/
//  display.init();
////  display.setI2cAutoInit(true);
//  display.flipScreenVertically();
//  display.setFont(ArialMT_Plain_16);
//  display.drawString(128, 33, "Right aligned (128,33)");
}

void loop() {
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
  Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");

  Serial.println();
  delay(500);
}

Re: multiple i2c devices with arduino

PostPosted: Thu Dec 06, 2018 10:21 am
by rudy
It seems to me that you are using different pins for each device. If that is the case, connect them in parallel. Both SDA and SCL pair to the same pins.


mlx.begin();
Wire.begin(D2,D1);

SSD1306Wire display(0x3c, D3, D4);

Re: multiple i2c devices with arduino

PostPosted: Thu Dec 06, 2018 12:13 pm
by epy hobb
rudy wrote:It seems to me that you are using different pins for each device. If that is the case, connect them in parallel. Both SDA and SCL pair to the same pins.


mlx.begin();
Wire.begin(D2,D1);

SSD1306Wire display(0x3c, D3, D4);

I tried that way as well. Then later i selected different pins..then also not working...

Re: multiple i2c devices with arduino

PostPosted: Thu Dec 06, 2018 6:27 pm
by AcmeUK
Have you got pull-up resistors on the SCL and SDA lines? 4K7 resistors are usually adequate.

Have you scanned the I2C bus to see what devices are found?

I2C devices have fixed or default addresses, is there an address clash?

Also from here :-http://www.esp8266.com/posting.php?mode=reply&f=32&t=18839
Did you read the datasheet of the MLX90614? The default operation mode of the chip is to put out a PWM signal on the SDA pin. If that is still enabled you cannot use the chip together with other devices on the same I2C bus.