Dear arb,
Thank you for your reply. In the interim, I just found this code at https://forum.dexterindustries.com/t/solved-python-library-for-6-axis-accelerometer-and-compass/1043/3 by ben_bd. It is not necessarily the ultimate code, but to get me started.
I may have solved my problem. It’s nerdy, and I understood its purpose by going deeper down the code instead of relying on the Adafruit (higher level code).
When you read the datasheet for the LSM303DHLC, you find that there is the address for the module, using the i2cdetect or by using the list of addresses pdf document produced by Adafruit i2c-addresses.pdf (384.3 KB) from https://learn.adafruit.com/i2c-addresses/overview where the link to the document is https://cdn-learn.adafruit.com/downloads/pdf/i2c-addresses.pdf.
Start again. You have the address of the device. Then the device has specific registers that can be set, that is the 2nd parameter. Then the register is stored with a particular value.
For example during the initialization of the module you come across this:
bus.write_byte_data(LSM303D_ADDR, CTRL_REG1, 0x57)
# where LSM303D_ADDR = 0x1E, CTRL_REG1 = 0x20, and 0x57
# refer to p25 data sheet. 0x57 = 01010111, where 0101 = 100Hz operation table 18, table 19
# 0111 = lpen and enable x,y,z. = normal power, enable x,y,z, table 18 and 20
Don’t worry about WHO_AM_I when reading from the command
whoami = bus.read_byte_data(LSM303D_ADDR, WHO_AM_I)
This refers to the device LSM303D, where the WHO_AM_I register is 0x0f is supposed to return the value 0x49 as in page 28, table 19 and page 32. So this is irrelevant for the LSM303DHLC. Source document for the LSM303D is at https://www.pololu.com/file/download/LSM303D.pdf?file_id=0J703 . Yes the LSM303D does a similar thing to the LSM303DHLC
Thank you,
Anthony of Sydney