I am trying to use an i2c multiplexer from Adafruit
There is no library for this device, as all communication is handled through the Wire.h library.
I am going to leave a lot of irrelevant code out and keep the code up to the point of hang.
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_FXOS8700.h"
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_FXOS8700.h>
#define TCAADDR 0x70
void tcaselect(uint8_t i) {
if (i > 7) return;
Serial.println("Beginning Transmission");
Wire.beginTransmission(TCAADDR);
Serial.println("Writing...");
Wire.write(1 << i);
Serial.println("Ending Transmission");
Wire.endTransmission();
Serial.println("Ended...");
}
/* Assign a unique ID to this sensor at the same time */
Adafruit_FXOS8700 accelmag = Adafruit_FXOS8700(0x8700A, 0x8700B);
void setup(void)
{
Serial.begin(9600);
/* Wait for the Serial Monitor */
while (!Serial) {
delay(1);
}
Serial.println("FXOS8700 Test"); Serial.println("");
tcaselect(0);
Serial.println("Checking Accelmag");
/* Initialise the sensor */
if(!accelmag.begin(ACCEL_RANGE_4G))
{
/* There was a problem detecting the FXOS8700 ... check your connections */
Serial.println("Ooops, no FXOS8700 detected ... Check your wiring!");
while(1);
}
}
The serial monitor prints the following:
FXOS8700 Test
Beginning Transmission
Writing…
Ending Transmission
You can see that it hangs after calling the Wire.endTransmission() function when it actually sends out the data.
If I am doing something wrong or using a deprecated function let me know.
Thanks,
Brandon