ESP32 Sparkfun two i2c

Reflej0
Posts: 2
Joined: Sat Apr 27, 2019 1:52 am

ESP32 Sparkfun two i2c

Postby Reflej0 » Sat Apr 27, 2019 2:12 am

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 !

Reflej0
Posts: 2
Joined: Sat Apr 27, 2019 1:52 am

Re: ESP32 Sparkfun two i2c

Postby Reflej0 » Sat Apr 27, 2019 3:24 am

For the moment, connect both sensors to the same pins SDA and SCL, and both are working.

Who is online

Users browsing this forum: No registered users and 54 guests