Can't read I2C registers

Hello, I am having trouble reading registers of an I2C accelerometer (MMA8452Q).
It’s connected to default I2C pins on the cubecell board and I2C scan sketch discovers it. However, when trying to read specific registers, I always get the same values (which seems to be some garbage data)

for example, I tried to read register 0x0D (WHO_AM_I) which should be factory hard coded to 0x02
but I get 0.

Here is the sketch:
> #include <Wire.h>
>
> void setup() {
> Serial.begin(9600);
> delay(500);
> Wire.begin();
> Wire.beginTransmission(0x1D);
> Wire.write(0x0D)
> Wire.endTransmission(false);
> Wire.requestFrom((uint16_t)0x1D, (byte)1);
> while (Wire.available())
> {
> Serial.print(“I AM: 0x”);
> Serial.println(Wire.read(), HEX);
> }
> }
> void loop() {
> }

Additional data:
no matter what device address or register number I try to read, I get the same 8 bits. If sensor is disconnected, I get nothing(as expected)…
The sensor works perfectly well with arduino nano every(using level shifting).

Hi will need to know what board / capsule you are using. Are you using vext to supply the sensor power? And controlling it correctly.you can see this in the example script.
Simon

I am using the cubecell dev board (htcc-ab01).
Iv’e tried Vext, tried the 3.3 header, tried a different power supply - all to no avail…
when running this same code with arduino nano I get the expected values.
Iv’e also noticed that the current draw of the sensor is different with each board: with cubecell it’s 1uA - way below spec(~160uA).

The code for nano may can’t working in CubeCell directly. Because CubeCell and Arduino nano use a different MCU.

BTW. what library did you use?

just the wire library

Did you refer to this example?

https://github.com/HelTecAutomation/ASR650x-Arduino/blob/master/libraries/Basics/examples/i2c_scan/i2c_scan.ino

Yes, I have.
As stated in the O.P, this example scan sketch did discover the sensor.
also, I have based my code on that example

The example can discover the sensor, it means the I2C bus is running well.

I think you need double check the sensor initial part.

I know Im not owed anything by you, but I get the feeling you never read the code. It is a vary simple code I wrote in order to debug after the sensor library(by Sparkfun) failed to work with this board.

As far as I know, giving an address and then reading it’s content is the most basic thing you can do with I2C.
this code uses only the Wire.h library, that suppose to work with this board.
I can’t find any syntax error.

guess I’ll have to wait for my scope to arrive in order to get to the bottom of this…

do you have to initialize the sensor or wake up from sleep before you can read data?
i dont have this sensor and dont know it.

What is done in the library you reference to init the sensor?

i ahve read that this sensor needs to be activated to send data.
A little googling gave me this interesting github repository:

this is sparkfun’s library.
-It didn’t work with cubecell dev board.
-It masks the use of Wire library, but don’t do anything complicated
-the “sensor initialization” that it contains does what Im trying to do: reads the “WHO AM I” register to make sure this is the said sensor. that’s the first thing it does. the library fails there, my code fails there.

edit: this is a predecessor to the sparkfun library. it does not compile, even when adding I2C.h library(which is about 9 years outdated).

I’ve finally got an oscilloscope.
It appears that SCL and SDL V_H is only ~2.7V, even though the 3V3 pin(which I use to power the sensor) is measured to be 3.31V. when not transmitting, the lines are at 3.3, pulled using 10k resistors.

Also, CubeCell’s SCL frequency was about 83kHz.

first pic is arduino nano every, srcond is cubecell board (ab01)