SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
#198331
hi

I cannot get to work more than one MMA8452Q accelerometer (I actually actually need 6 to 8) using a qwiic mux shield on a Arduino ONE.

I only get one to work when using the example provided by the documentation. This is only when connected to the standard arduino pins (not working connected to the shield pins)
https://github.com/sparkfun/MMA8452_Acc ... _Basic.ino

I cannot understand however how do I manage to get information from different accelerometers at the same time. Is there any documentation or example I can have a look at? I can see that this might be a start point but I dont understand very well (I am an artist and I am better at programming that electronics and hardware sorry...)
https://learn.sparkfun.com/tutorials/mm ... ess_jumper

many thanks in advance
#198336
I just found the way couple of hours after asking the question


#include <Wire.h>
#include <SparkFun_MMA8452Q.h> //From: https://github.com/sparkfun/SparkFun_MM ... no_Library

MMA8452Q accel;

void setup() {
Serial.begin(9600);
Wire.begin();

enableMuxPort(5); //Tell mux to connect to port X
accel.init(); //Init the sensor connected to this port
disableMuxPort(5);
}

void loop() {
// put your main code here, to run repeatedly:
enableMuxPort(5);
if (accel.available())
{
accel.read();

Serial.print("Accel ");
Serial.print(5);
Serial.print(": ");
Serial.print(accel.cx, 2);
Serial.print(" ");
Serial.print(accel.cy, 2);
Serial.print(" ");
Serial.print(accel.cz, 2);
Serial.print(" ");

Serial.println(); // Print new line every time.
}

disableMuxPort(5); //Tell mux to disconnect from this port


delay(1); //Wait for next reading
}