mpu6050:Add shell script for get temperature from mpu6050 - #130
ghostzero2000 wants to merge 1 commit into
Conversation
|
Please attach the results of script's execution. |
ab047e5 to
20853cd
Compare
|
Added the screenshot with the result of the script's execution. |
|
Did You check the value of temperature? Are they correct? |
20853cd to
67b8175
Compare
|
Hello. I found a mistake, I perceived the variable as unsigned. Now it is a value 16 bit signed |
|
Please attach the results of script execution in format of text file. |
67b8175 to
b79cd83
Compare
|
Attached file "mpu6050_get_temp_C_and_F.log" which content of script execution. |
b79cd83 to
76f161e
Compare
|
Like I cleaned everything. |
| function get_temperature { | ||
| H_BYTE_MPU6060=$(i2cget -y 0 0x68 0x41 b) | ||
| L_BYTE_MPU6060=$(i2cget -y 0 0x68 0x42 b) | ||
| TWO_BYTE_HEX="${H_BYTE_MPU6060:2}${L_BYTE_MPU6060:2}" | ||
| TWO_BYTE_DEC_convert=$(conv_16_bit_hex_dec_signed $TWO_BYTE_HEX ) | ||
| # echo "TWO_BYTE_DEC=$TWO_BYTE_DEC_convert" | ||
| echo "Temp TWO_BYTE_HEX $( echo "scale=3; $TWO_BYTE_DEC_convert/340+36.53" | bc)" | ||
| echo "Temp Fahrenheit $(echo "scale=3; (($TWO_BYTE_DEC_convert/340+36.53)*9)/5+32" | bc)" | ||
|
|
||
| } |
There was a problem hiding this comment.
Can You implement the conversation without additional call of printf and using out from i2cget with option -w
There was a problem hiding this comment.
The changes are not implemented.
bc1f8b5 to
7071531
Compare
|
Update shell script with i2cget option w |
|
The additional commit from other task was included in this PR. Please rebase your PR. |
7071531 to
7323aae
Compare
|
In the pull request is one commit that belongs to this task. |
| echo "Temp TWO_BYTE_HEX $( echo "scale=3; $TWO_BYTE_DEC_convert/340+36.53" | bc)" | ||
| echo "Temp Fahrenheit $(echo "scale=3; (($TWO_BYTE_DEC_convert/340+36.53)*9)/5+32" | bc)" | ||
| LONG_WORD=$(i2cget -y 0 0x68 0x41 w) | ||
| CONVERT_LONG_WORD=$(((LONG_WORD & 0xFF)<<8 | (LONG_WORD>>8) & 0xFF)) | ||
| (( CONVERT_LONG_WORD > 32767 )) && (( CONVERT_LONG_WORD -= 65536 )) | ||
| Celsiy=$(bc -l <<< "scale=4;$CONVERT_LONG_WORD/340+36.53") | ||
| Fahrenheit=$(bc -l <<< "scale=4;$Celsiy*9/5+32") |
There was a problem hiding this comment.
What is the reason for different scale for file and for stdout output? Is the 4th digit after point significant?
Signed-off-by: Vladyslav <omelya1998chirk@gmail.com>
f37e80a to
aa9eb31
Compare
|
The conversion from a simple fraction to a decimal fraction makes rounding significant for any number of decimal places. |
| Temp Celsiy 27.401 | ||
| Temp Fahrenheit 81.321 | ||
| Temp long_word | ||
| Celsius 27.40058823529411764706 |
There was a problem hiding this comment.
What is the value of least significant bit for this sensor? Are 20 digits after comma enough?
Add shell script for getting temperature from mpu6050 , log file with i2c commands and screenshot with it.