Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpu6050:Add shell script for get temperature from mpu6050 #130

Open
wants to merge 1 commit into
base: Vladyslav.Kryzhanovskyi
Choose a base branch
from

Conversation

ghostzero2000
Copy link

Add shell script for getting temperature from mpu6050 , log file with i2c commands and screenshot with it.

@ghostzero2000 ghostzero2000 added the ready The PR is ready for review (set by author). label Dec 3, 2019
@yekovalyov yekovalyov added changes requested The PR review revealed issues which should be fixed (set by reviewer) and removed ready The PR is ready for review (set by author). labels Dec 4, 2019
@yekovalyov
Copy link
Contributor

Please attach the results of script's execution.

@ghostzero2000 ghostzero2000 force-pushed the mpu6050_userspace_solution_ver_02 branch from ab047e5 to 20853cd Compare December 5, 2019 13:12
@ghostzero2000
Copy link
Author

Added the screenshot with the result of the script's execution.

@ghostzero2000 ghostzero2000 added ready The PR is ready for review (set by author). and removed changes requested The PR review revealed issues which should be fixed (set by reviewer) labels Dec 5, 2019
@yekovalyov
Copy link
Contributor

Did You check the value of temperature? Are they correct?

@yekovalyov yekovalyov added changes requested The PR review revealed issues which should be fixed (set by reviewer) and removed ready The PR is ready for review (set by author). labels Dec 6, 2019
@ghostzero2000 ghostzero2000 force-pushed the mpu6050_userspace_solution_ver_02 branch from 20853cd to 67b8175 Compare December 7, 2019 12:58
@ghostzero2000
Copy link
Author

Hello. I found a mistake, I perceived the variable as unsigned. Now it is a value 16 bit signed

@ghostzero2000 ghostzero2000 added ready The PR is ready for review (set by author). and removed changes requested The PR review revealed issues which should be fixed (set by reviewer) labels Dec 8, 2019
@yekovalyov
Copy link
Contributor

Please attach the results of script execution in format of text file.

@yekovalyov yekovalyov added changes requested The PR review revealed issues which should be fixed (set by reviewer) and removed ready The PR is ready for review (set by author). labels Dec 8, 2019
@ghostzero2000 ghostzero2000 force-pushed the mpu6050_userspace_solution_ver_02 branch from 67b8175 to b79cd83 Compare December 9, 2019 12:37
@ghostzero2000
Copy link
Author

Attached file "mpu6050_get_temp_C_and_F.log" which content of script execution.

@ghostzero2000 ghostzero2000 added ready The PR is ready for review (set by author). and removed changes requested The PR review revealed issues which should be fixed (set by reviewer) labels Dec 9, 2019
@yekovalyov yekovalyov added changes requested The PR review revealed issues which should be fixed (set by reviewer) and removed ready The PR is ready for review (set by author). labels Dec 16, 2019
@ghostzero2000 ghostzero2000 force-pushed the mpu6050_userspace_solution_ver_02 branch from b79cd83 to 76f161e Compare December 16, 2019 14:45
@ghostzero2000 ghostzero2000 added ready The PR is ready for review (set by author). and removed changes requested The PR review revealed issues which should be fixed (set by reviewer) labels Dec 16, 2019
@ghostzero2000
Copy link
Author

Like I cleaned everything.

Comment on lines 12 to 28
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)"

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can You implement the conversation without additional call of printf and using out from i2cget with option -w

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are not implemented.

@yekovalyov yekovalyov added changes requested The PR review revealed issues which should be fixed (set by reviewer) and removed ready The PR is ready for review (set by author). labels Dec 26, 2019
@ghostzero2000 ghostzero2000 force-pushed the mpu6050_userspace_solution_ver_02 branch 3 times, most recently from bc1f8b5 to 7071531 Compare January 8, 2020 21:14
@ghostzero2000 ghostzero2000 added ready The PR is ready for review (set by author). and removed changes requested The PR review revealed issues which should be fixed (set by reviewer) labels Jan 8, 2020
@ghostzero2000
Copy link
Author

Update shell script with i2cget option w

@yekovalyov
Copy link
Contributor

The additional commit from other task was included in this PR. Please rebase your PR.

@yekovalyov yekovalyov added changes requested The PR review revealed issues which should be fixed (set by reviewer) and removed ready The PR is ready for review (set by author). labels Jan 10, 2020
@ghostzero2000 ghostzero2000 force-pushed the mpu6050_userspace_solution_ver_02 branch from 7071531 to 7323aae Compare January 11, 2020 12:23
@ghostzero2000 ghostzero2000 added ready The PR is ready for review (set by author). and removed changes requested The PR review revealed issues which should be fixed (set by reviewer) labels Jan 11, 2020
@ghostzero2000
Copy link
Author

In the pull request is one commit that belongs to this task.

Comment on lines 18 to 24
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for different scale for file and for stdout output? Is the 4th digit after point significant?

@yekovalyov yekovalyov added changes requested The PR review revealed issues which should be fixed (set by reviewer) and removed ready The PR is ready for review (set by author). labels Jan 14, 2020
@ghostzero2000 ghostzero2000 force-pushed the mpu6050_userspace_solution_ver_02 branch from f37e80a to aa9eb31 Compare January 14, 2020 21:46
@ghostzero2000 ghostzero2000 added ready The PR is ready for review (set by author). and removed changes requested The PR review revealed issues which should be fixed (set by reviewer) labels Jan 14, 2020
@ghostzero2000
Copy link
Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the value of least significant bit for this sensor? Are 20 digits after comma enough?

@yekovalyov yekovalyov added changes requested The PR review revealed issues which should be fixed (set by reviewer) and removed ready The PR is ready for review (set by author). labels Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested The PR review revealed issues which should be fixed (set by reviewer)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants