Page 1 of 1

ESP32 Sparkfun two i2c

Posted: Sat Apr 27, 2019 2:12 am
by Reflej0
Hello, I am new to this field and I acquired an Sp32fun from ESP32.
Among the devices I bought was a Nokia 5110 (already configured), a rain sensor (already configured), and TCS34725 and an ADXL345 (which I could test separately).
It turns out that the TCS34725 and the ADXL345 have the SDA and SCL pins that indicate the i2c connection.
I was investigating but I can not connect the two i2c devices. I loved the simplicity of this example to control the ADXL345:

Code: Select all

#include <SPI.h>
#include <Wire.h>
#include <SparkFun_ADXL345.h> 
 
ADXL345 adxl = ADXL345();
 
void setup() 
{
   Serial.begin(9600);             
   Serial.println("Iniciar");
   Serial.println();
 
   adxl.powerOn();            
   adxl.setRangeSetting(16);       //Definir el rango, valores 2, 4, 8 o 16
}
 
void loop() 
{
   //leer los valores e imprimirlos
   int x, y, z;
   adxl.readAccel(&x, &y, &z);  
   Serial.print(x);
   Serial.print(", ");
   Serial.print(y);
   Serial.print(", ");
   Serial.println(z); 
}
But I do not get by means of Arduino IDE in some way to configure both devices in simultaneous by i2c.
I was thinking of two possible solutions:
  1. Make the connection of the ADXL345 by SPI.
  • Buy an ADXL335 that is analog and handle it by analog reading.
I wanted to know if it is a simple job to configure two i2c devices.
Thank you !

Re: ESP32 Sparkfun two i2c

Posted: Sat Apr 27, 2019 3:24 am
by Reflej0
For the moment, connect both sensors to the same pins SDA and SCL, and both are working.