Hi everyone,
I would like to build my projects entire on PCBs. And so to challenge myself, and to learn from, I designed a small PCB, an accelerometer that on runs on I2C, using the QMA6981 by QST. the schematic I build for the PCB looks like this:

which I made by consulting the datasheet at page 9.
and the PCB:
I then tried hooking it up to my Arduino Nano Every to test it out, in the following way, with a logic level converter
Which I then tried running with the following code:
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
// step 1: instruct sensor to read echoes
Wire.beginTransmission(0x12); // transmit to device #12
Serial.println("sending active to device");
Wire.write(byte(0x11)); // to active mode -> 0x11
Wire.endTransmission(); // stop transmitting
delay(200);
}
int reading = 0;
void loop() {
while(Wire.available()) {
reading = Wire.read(); // receive
Serial.println(reading); // print the reading
}
delay(250);
}
To get the device to start transmitting in the setup (page 12 of datasheet), and then read out and print what it sends back to the MPU.
But nothing is being printed when uploading this script. (apart from "sending active to device")
I think it is most likely something in my code which is wrong, because when I run the following "I2C scanner" script I found:
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}
void loop() {
int nDevices = 0;
Serial.println("Scanning...");
for (byte address = 1; address < 127; ++address) {
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
byte error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.print(address, HEX);
Serial.println(" !");
++nDevices;
} else if (error == 4) {
Serial.print("Unknown error at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.println(address, HEX);
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
} else {
Serial.println("done\n");
}
delay(5000); // Wait 5 seconds for next scan
}
It displays that an I2C device is found at adress 0x12. So I suspect there is an error in my program, and not in the way the device is connected.
I have been reading up on the I2C protocol and how to use it for some time now, but cannot find anything that helps me further right now. Do some of you know what the problem may be? Or do you have some source of information that might point me in the right direction?
Thanks in advance.

