Read accelerometer from API

The firmware guide walks through how to read the position (presumably relative to a spatial arrangement of DW1000 chips all distance-ranging or otherwise self-locating relative to one another, I’m just assuming). Oddly, I just get 4 0s back for x,y,z, and qf, no meaningful data. Perhaps someone has some thoughts on that, although it isn’t my primary question here.

In shell mode, I can run “av” to get back accelerometer values and these seem to actually contain meaningful data, as they indicate the orientation of the device as I rotate it around in the air calling av over and over again.

But I can’t find an API call for the motion sensor. I looked through dwm.h and through the API guide and I can’t find any way to read the accelerometer from C code, as demonstrated for position in the FW guide. The position example from the firmware guide is fairly straightforward (except for the confusion that that it just returns solid 0s), but I can’t find anything for the accelerometer.

What am I missing?

Thanks.

1 Like

Hi kwiley,

Have you had a look at the dwm1001-api-guide document ?

The accelerometer is connected to the two wire interface (I2C), so you need to use the api dwm_i2c_read.

I would try something like :

Example: uint8_t data[2]; const uint8_t addr = 0x33; // some address of the slave device dwm_i2c_read(addr, data, 2);

Let me know how it goes,
Thnaks
Yves

Hi Yves,

In the user code of the DWM1001, I would like to read some registers from another sensor connected to the I2C bus.

If I use the function:

“dwm_i2c_read(uint8_t addr, uint8_t* p_data, uint8_t len)”

addr: is the device address (0x33 for the inboard accelerometer)
p_data: pointer to the received data buffer
len: number of bytes

BUT, I do not know how to specify which register address I want to read!

Any help on this is wellcome.

Best regards

Epenciso

Hi yves,

Any comment on this?
Is there a way to read registers from another sensor connected to the I2C bus?
I do not see any parameter for the register address in the function ‘dwm_i2c_read(device address, *data, len)’?

Thank you and best regards

Epenciso

Hi epenciso,

I guess the register address should be within the data. What is the sensor you’re trying to read from ?

Thanks
Regards
Yves

Two sensors: Bosch BME280 and TDK MPU-6050.

Thank you.

Also, is there any sample code to configure, in the user code area, the Nordic pins for analog mode, and read some analog values?

Best regards

We don’t have such an example at the moment. Please have a look at the nordic examples from their SDK as a starting point.

Yves

Hi @epenciso

Did you get read other sensors connected to the I2C bus?

Ricardo

Hi Yves

Where can I find the accelerometer’s Register Map?

Yves,

A doubt about the code:

In the sample project dwm_simple the code snippet is:

	/* Test the accelerometer */
	i2cbyte = 0x0f;
	rv = dwm_i2c_write(0x33 >> 1, &i2cbyte, 1, true);

Why the right shift in address?

Thanks

code snippet from sample-project dwm-api-test.c:

> #define LIS2DX_SLAVE_ADDR       0x19   /* I2C slave address */
> #define LIS2DX_WHO_AM_I         0x0F   /* Who I am ID */
> #define LIS2DX_WHO_AM_I_VAL     0x33   /* ID value */

0x33 >> 1 = 0x19

so it seems to be a kind of humor…
greetings horst

1 Like

Hi,

it’s 7-bit addressing of I2C, see e.g. https://www.totalphase.com/support/articles/200349176-7-bit-8-bit-and-10-bit-I2C-Slave-Addressing

The accelerometer DS is here: https://www.st.com/resource/en/datasheet/lis2dh12.pdf

Cheers,
TDK

1 Like