0

LIS3DH accelerometer temperature reading
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

LIS3DH accelerometer temperature reading

by merlymk on Tue Feb 23, 2021 6:28 am

Hi I am very new to Arduino products and C programming.
I have been using a LIS3DH sensor for vibration monitoring using the I2C protocol and have been successful in data collection. However i have a new requirement of reading temperature data along with the vibration data. In the data sheet for LIS3DH an embedded temperature sensor is mentioned. I have done some research on using registers to read the temperature data but so far i have not had any success. Few queries
1) Can the temperature data be read using the I2C protocol along with the vibration data
2) Do we require an external sensor to be connected to the LIS3DH for temperature measurement
Testing code has been attached.
Note:- There is no vibration call because i did like to take the temperature separately and simulate.
Attachments
temp.ino
(1.19 KiB) Not downloaded yet

merlymk
 
Posts: 3
Joined: Thu Feb 04, 2021 1:02 am

Re: LIS3DH accelerometer temperature reading

by adafruit_support_carter on Tue Feb 23, 2021 1:01 pm

1) Can the temperature data be read using the I2C protocol along with the vibration data

Yes.
2) Do we require an external sensor to be connected to the LIS3DH for temperature measurement

Yes/No/Maybe.

Keep in mind that the temperature sensor on the LIS3DH is internal, so it will be heavily affected by the LIS3DH itself. If you are wanting something closer to ambient air temperature an external temperature sensor may be better.

See datasheet:
https://www.st.com/resource/en/datasheet/lis3dh.pdf
section 3.7 for details about how to enable, configure, and read the internal temperature sensor.
lis3dh_temp.jpg
lis3dh_temp.jpg (77.32 KiB) Viewed 52 times

adafruit_support_carter
 
Posts: 18729
Joined: Tue Nov 29, 2016 2:45 pm

Re: LIS3DH accelerometer temperature reading

by merlymk on Wed Feb 24, 2021 2:00 am

Hello Team

I have simulated the code and the temperature reading on the serial monitor screen shot is attached.
Notice that temperature reading is constant irrespective of where the sensor is placed.
I am unsure if its the code or the installation.
Attachments
Install7.jpg
Install7.jpg (78.58 KiB) Viewed 44 times
Install5.jpg
Install5.jpg (58.11 KiB) Viewed 44 times
LIS3DH Temp Reading.jpg
LIS3DH Temp Reading.jpg (181.2 KiB) Viewed 44 times

merlymk
 
Posts: 3
Joined: Thu Feb 04, 2021 1:02 am

Re: LIS3DH accelerometer temperature reading

by adafruit_support_carter on Wed Feb 24, 2021 11:15 am

Make sure you've done this setup also:
lis_temp.jpg
lis_temp.jpg (82.47 KiB) Viewed 38 times



The block diagram might help. There are two steps. (1) Enable AD Convert2 and (2) set the Input 3 mux to point to the Temperature Sensor. I think you've only done (2).
lis_block.jpg
lis_block.jpg (42.29 KiB) Viewed 38 times

adafruit_support_carter
 
Posts: 18729
Joined: Tue Nov 29, 2016 2:45 pm

Re: LIS3DH accelerometer temperature reading

by merlymk on Thu Feb 25, 2021 3:29 am

Hi I am still having an issue with the temperature display. Screen shot attached.
The temp1 and temp2 data type is int..please suggest if this needs to be changed.
Attachments
Temp Not Dsiplaying 2.jpg
Temp Not Dsiplaying 2.jpg (108.8 KiB) Viewed 33 times
Temp Not Dsiplaying 1.jpg
Temp Not Dsiplaying 1.jpg (205.04 KiB) Viewed 33 times

merlymk
 
Posts: 3
Joined: Thu Feb 04, 2021 1:02 am

Re: LIS3DH accelerometer temperature reading

by adafruit_support_carter on Thu Feb 25, 2021 11:56 am

Not sure. Look in the datasheet for specifics on how I2C works with the LIS3DH. You may need to read back both bytes without a stop?

adafruit_support_carter
 
Posts: 18729
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.