Pimoroni LSM303D Read 0x1E& 1D

Hi

Just bought two LSM303Ds and trying to read them both at the same time in the Arduino environment (set at 0x1D and 0x1E). Has anyone got any example code that does this in Arduino environment? They are both connected and can see them on a i2c scanner but cant unpick the standard lsm303 code to interrogate both.

Any help appreciated?

Richard

Posting the code your testing may help.

This will be controlled by whatever library you’re using to run the board with Arduino. Usually when you instantiate it (e.g. LSM303D sensor;) there’s an option to specify the address.

Thanks. Sorted. It was the additional commands in the init call that i wasnt aware of.

Using the standard LSM303 library I added the following commands in to the setup. And works now.

if(compass1.init(LSM303::device_auto,LSM303::sa0_low)) Serial.println(“1 ok”);
else Serial.println(“1 fail”);

if(compass2.init(LSM303::device_auto,LSM303::sa0_high)) Serial.println(“2 ok”);
else Serial.println(“2 fail”);

Thanks @Shoe I would have never figured that out. Saved that info for future reference though in case I ever get back to tinkering with my Arduino’s. =)