ESP32 Sparkfun two i2c
Posted: 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:
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:
Thank you !
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);
}
I was thinking of two possible solutions:
- Make the connection of the ADXL345 by SPI.
- Buy an ADXL335 that is analog and handle it by analog reading.
Thank you !