Hi again, what are we going to discuss today? Okay, so we are going to discuss a package which is named “LSM303DLHC“. Don’t take this package as an ordinary one because it is a valuable package. You will know its value soon.
In previous blogs we talked about – Communication with the Hardware, Capabilities of minicomputers and much more. If you want to read more about such topics then you can visit Rust Blogs.
As we are working with the Embedded Systems they make our task fast and reliable. Also, they are much smaller in size compared to traditional computers, which makes them compact and portable, and useful for mass production. Management of Embedded Systems is pretty easy, as elements used in their creation are cheap & long-lasting. Embedded Systems are also cost-effective.
Time to talk about our LSM303DLHC package.
What is “LSM303DLHC”??

The board STM32F303VCT6 Discovery Board contains multiple sensors like
- Accelerometer
- Gyroscope
- Magnetometer
All these three sensors are embedded inside the microcontroller. Now to work with them we have to access these sensors. But from where we can access them?
We access these sensors through a package. So the package “LSM303DLHC” contains two sensors which are Accelerometer and Magnetometer.
- LSM303DLHC is basically an IC that contains sensors of the stm323 board.
- Two of the sensors in the F3, the magnetometer and the accelerometer, are packaged in a single component: the LSM303DLHC integrated circuit.
- These two sensors can be accessed via an I2C bus. Each sensor behaves like an I2C slave and has a different address.
This valuable package is already present in the smt32-discovery crate and you can access them like this.
This is all about the package “LSM303DLHC”. Now it’s time to proceed further.
Why “LSM303DLHC” is Valuable? What it contains?
The package contains two of the sensors as told already and those two sensors are
- Magnetometer
- Accelerometer
Each sensor has its own memory where it stores the results of sensing its environment. Our interaction with these sensors will mainly involve reading their memory.
- The memory of these sensors is modeled as byte-addressable registers. We can also configure them by writing to their Registers.
- So, in a sense, these sensors are very similar to the peripherals inside the microcontroller. The only difference is we can access them using the i2C Bus as they are not present with the microcontroller’s memory like the other peripherals are.
Here we first configured the i2C to provide the data, clock line, and clocks. Then, we access the package using the i2c bus and unwrap the features of the “Lsm303dlhc”. This whole thing makes this package valuable.
The Sensors of lsm303dlhc package
Let’s talk about the internals of the valuable package.
Magnetometer
Magnetometers are sensors that measure magnetic fields. In the absence of nearby magnets, a magnetometer will measure Earth’s magnetic field, which points to the geographic north, so you can use the magnetometer as a digital compass.
Earth’s magnetic field is a 3D vector but the magnetometer in the LSM303DLHC decomposes it along three orthogonal axes.
The lsm303dlhc provides a method as mag() which makes us able to read the Magnetometer data.
The readings we got from the Magnetometer while it was in still position.
I16x3 { x: 45, y: 194, z: -3 }
I16x3 { x: 46, y: 195, z: -8 }
I16x3 { x: 47, y: 197, z: -2 }
Accelerometer
An accelerometer is a sensor that measures proper acceleration. Proper acceleration is the acceleration of a body in its own instantaneous rest frame; this is different from coordinate acceleration, which is acceleration in a fixed coordinate system. This means that even if an accelerometer is not moving it will sense the acceleration of gravity.
So the package contains another sensor as Accelerometer which measures a 3D acceleration vector but it reports the decomposition of the 3D vector along three orthogonal axes.
The way we read the data of Magnetometer similarly we can read the data of the Accelerometer using accel() method of the lsm303dlhc package.
Reading Output of Accelerometer–
(0.0, 0.0, 1.078125)
(0.0, 0.0, 1.078125)
(0.0, 0.0, 1.171875)
(0.0, 0.0, 1.03125)
(0.0, 0.0, 1.078125)
So these were the two sensors which are packed inside the ldm303dlhc package, there is one more sensor -“Gyroscope” we will talk about it also in coming blogs.
That’s all from today’s blog, I hope you liked the content. Thanks for Reading !!
If you want to read more content like this? Subscribe to Rust Times Newsletter and receive insights and latest updates, bi-weekly, straight into your inbox. Subscribe to Rust Times Newsletter: https://bit.ly/2Vdlld7.

2 thoughts on ““LSM303DLHC” – A Valuable Package.4 min read”
Comments are closed.