-
Notifications
You must be signed in to change notification settings - Fork 27
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
Lesson11 (mpu6050) scripts: Eugene.Ovdiyuk #118
base: Eugene.Ovdiyuk
Are you sure you want to change the base?
Conversation
ovdiyuk
commented
Jan 7, 2019
- Implemented get_temperature.sh shell script which prints value of temperature (TEMP_OUT_H, TEMP_OUT_L) once per second using i2cget in infinite loop. Value converted to F and C. Upload the script into to folder ‘mpu6050_scripts’.
- Added ins_mod.sh and rm_mod.sh for fast Module load
- Fixed errors in driver mpu6050.c from the repository.
- Makefile was modified to build module on OrangePI
- Implemented GUI script gui_mpu6050.sh to pull mpu6050 module data in the terminal
84dc537
to
a997688
Compare
Updated Makefile to build on OrangePI Updated C file: corrected errors
insmod and rmmod scripts are added gui_mpu6050.sh script added for pulling information in console
implemented get_temperature.sh to get Temp via i2c-tool
a997688
to
faf9c69
Compare
LB=$(sudo i2cget -y 0 0x68 0x42) | ||
|
||
#Upper Bit + Lower Bit | ||
TEMP=$(( (UB<<8)+LB-65535 )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it require to use -65535?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the only way to XOR all 16 bits. I don't know why, but ^0xFFFF works incorrectly in the bash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do You need XOR for all bits?
TEMP=$(( (UB<<8)+LB-65535 )) | ||
|
||
# Calc C value | ||
TEMP_C=$(bc << EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use bash operators using (( )) instead of calling bc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not possible, because bash cannot work with decimal variables. Of cause, we can use 10^3 multiplicator and convert variable on UI. But I choose this solution.
|
||
#Read data | ||
UB=$(sudo i2cget -y 0 0x68 0x41) | ||
LB=$(sudo i2cget -y 0 0x68 0x42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to read high and low part of data in single command using i2cget option '-w' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, "sudo i2cget -y 0 0x68 0x41 w" works. I didn't know about this. Thanks a lot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then I need to swap Lo and Hi bytes. Not sure in a method for bash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this: UB=$(sudo i2cget -y 0 0x68 0x41) && LB=$(sudo i2cget -y 0 0x68 0x42) && UBLB=$(sudo i2cget -y 0 0x68 0x41 w) && echo $UB $LB $UBLB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose command 'sudo i2cget -y 0 0x68 0x41 w' will give You UBLB as result. Is it correct?