{"id":3503,"date":"2023-07-08T06:15:54","date_gmt":"2023-07-08T13:15:54","guid":{"rendered":"https:\/\/www.donluc.com\/?p=3503"},"modified":"2023-07-08T06:15:54","modified_gmt":"2023-07-08T13:15:54","slug":"project-26-radio-frequency-bluetooth-mpu-9150-mk17","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=3503","title":{"rendered":"Project #26 &#8211; Radio Frequency &#8211; Bluetooth MPU-9150 &#8211; Mk17"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3503-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #Accelerometer #Magnetometer #Gyroscope #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04a.png\" alt=\"Bluetooth MPU-9150\" width=\"720\" height=\"453\" class=\"alignnone size-full wp-image-3505\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04a-300x189.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04b.png\" alt=\"Bluetooth MPU-9150\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3506\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04b-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04c.png\" alt=\"Bluetooth MPU-9150\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3507\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk04c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>MPU-9150<\/strong><\/p>\n<p>MotionInterface is becoming a &#8220;Must-Have&#8221; function being adopted by smartphone and tablet manufacturers due to the enormous value it adds to the end user experience. In smartphones, it finds use in applications such as gesture commands for applications and phone control, enhanced gaming, augmented reality, panoramic photo capture and viewing, and pedestrian and vehicle navigation. With its ability to precisely and accurately track user motions, MotionTracking technology can convert handsets and tablets into powerful 3D intelligent devices that can be used in applications ranging from health and fitness monitoring to location-based services. Key requirements for MotionInterface enabled devices are small package size, low power consumption, high accuracy and repeatability, high shock tolerance, and application specific performance programmability, all at a low consumer price point.<\/p>\n<p><strong>DL2306Mk04<\/strong><\/p>\n<p>1 x Arduino Uno<br \/>\n1 x SparkFun Bluetooth Mate Silver<br \/>\n1 x SparkFun 9 Degrees of Freedom Breakout &#8211; MPU-9150<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>Arduino Uno<\/strong><\/p>\n<p>RX &#8211; Digital 3<br \/>\nTX &#8211; Digital 2<br \/>\nSDA &#8211; Analog A4<br \/>\nSCL &#8211; Analog A5<br \/>\nVIN &#8211; +3.3V<br \/>\nGND &#8211; GND<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>DL2306Mk04p.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/* ***** Don Luc Electronics \u00a9 *****\r\nSoftware Version Information\r\nProject #26 - Radio Frequency - Bluetooth MPU-9150 - Mk17\r\n26-17\r\nDL2306Mk07p.ino\r\n1 x Arduino Uno\r\n1 x SparkFun Bluetooth Mate Silver\r\n1 x SparkFun 9 Degrees of Freedom Breakout - MPU-9150\r\n1 x SparkFun Cerberus USB Cable\r\n*\/\r\n\r\n\/\/ Include the Library Code\r\n\/\/ Software Serial\r\n#include &lt;SoftwareSerial.h&gt;\r\n\/\/ Two Wire Interface (TWI\/I2C)\r\n#include &lt;Wire.h&gt;\r\n\/\/ I2CDev I2C utilities\r\n#include &quot;I2Cdev.h&quot;\r\n\/\/ MPU9150Lib 9-axis fusion\r\n#include &quot;MPU9150Lib.h&quot;\r\n\/\/ CalLib magnetometer and accelerometer calibration\r\n#include &quot;CalLib.h&quot;\r\n\/\/ Motion Driver InvenSense Embedded SDK v5.1\r\n#include &lt;dmpKey.h&gt;\r\n#include &lt;dmpmap.h&gt;\r\n#include &lt;inv_mpu.h&gt;\r\n#include &lt;inv_mpu_dmp_motion_driver.h&gt;\r\n\/\/ EEPROM Magnetometer and Accelerometer data is stored\r\n#include &lt;EEPROM.h&gt;\r\n\r\n\/\/ the MPU object\r\nMPU9150Lib MPU;\r\n\/\/  MPU_UPDATE_RATE defines the rate (in Hz)\r\n\/\/ at which the MPU updates the sensor data and DMP output\r\n#define MPU_UPDATE_RATE  (20)\r\n\/\/  MAG_UPDATE_RATE defines the rate (in Hz) at which the\r\n\/\/ MPU updates the magnetometer data\r\n\/\/  MAG_UPDATE_RATE should be less than or equal to the MPU_UPDATE_RATE\r\n#define MAG_UPDATE_RATE  (10)\r\n\/\/  MPU_MAG_MIX defines the influence that the magnetometer has on the yaw output.\r\n\/\/  The magnetometer itself is quite noisy so some mixing with the gyro yaw can help\r\n\/\/  significantly. Some example values are defined below:\r\n\/\/ Just use gyro yaw\r\n#define  MPU_MAG_MIX_GYRO_ONLY          0\r\n\/\/ Just use magnetometer and no gyro yaw\r\n#define  MPU_MAG_MIX_MAG_ONLY           1\r\n\/\/ A good mix value \r\n#define  MPU_MAG_MIX_GYRO_AND_MAG       10\r\n\/\/ mainly gyros with a bit of mag correction\r\n#define  MPU_MAG_MIX_GYRO_AND_SOME_MAG  50\r\n\/\/  MPU_LPF_RATE is the low pas filter rate and can be between 5 and 188Hz\r\n#define MPU_LPF_RATE   5\r\n\r\n\/\/ This is our earth frame gravity vector - quaternions and vectors\r\nMPUQuaternion gravity;\r\n\r\n\/\/ Quaternion Result\r\nfloat Quaternion_X = 0.0;\r\nfloat Quaternion_Y = 0.0;\r\nfloat Quaternion_Z = 0.0;\r\n\r\n\/\/  SERIAL_PORT_SPEED defines the speed to use for the debug serial port\r\n#define  SERIAL_PORT_SPEED  115200\r\n\r\n\/\/ Software Serial\r\n\/\/ TX-O pin of bluetooth mate, Arduino D2\r\nint bluetoothTx = 2;\r\n\/\/ RX-I pin of bluetooth mate, Arduino D3\r\nint bluetoothRx = 3;\r\n\/\/ Bluetooth\r\nSoftwareSerial bluetooth(bluetoothTx, bluetoothRx);\r\n\/\/ BTA\r\nString BTA = &quot;0006664FDC9E&quot;; \r\n\r\n\/\/ Variable to calculate frequency\r\nunsigned long curr = 0;\r\nunsigned long last = 0;\r\nunsigned long freq;\r\n\r\n\/\/ Software Version Information\r\nString sver = &quot;26-17&quot;;\r\n\r\nvoid loop() {\r\n  \r\n  \/\/ MPU\r\n  isMPU();\r\n\r\n}\r\n<\/pre>\n<p><strong>getMPU.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ MPU\r\n\/\/ Setup MPU\r\nvoid isSetupMPU() {\r\n\r\n  \/\/ MPU\r\n  MPU.init(MPU_UPDATE_RATE, MPU_MAG_MIX_GYRO_AND_MAG, MAG_UPDATE_RATE, MPU_LPF_RATE);     \/\/ start the MPU\r\n\r\n  \/\/ Set up the initial gravity vector for quaternion rotation\r\n  \/\/ Max value down the z axis\r\n  gravity[QUAT_W] = 0;\r\n  gravity[QUAT_X] = 0;\r\n  gravity[QUAT_Y] = 0;\r\n  gravity[QUAT_Z] = SENSOR_RANGE;\r\n  \r\n}\r\n\/\/ MPU\r\nvoid isMPU() {\r\n\r\n  \/\/ Quaternion\r\n  \/\/ This is our body frame gravity vector\r\n  MPUQuaternion rotatedGravity;\r\n  \/\/ This is the conjugate of the fused quaternion\r\n  MPUQuaternion fusedConjugate;\r\n  \/\/ Used in the rotation\r\n  MPUQuaternion qTemp;\r\n  \/\/ The accelerations\r\n  MPUVector3 result;\r\n\r\n  \/\/ Get the latest data\r\n  if (MPU.read()) {\r\n    \r\n    \/\/ Need this for the rotation\r\n    MPUQuaternionConjugate(MPU.m_fusedQuaternion, fusedConjugate);\r\n    \r\n    \/\/ Rotate the gravity vector into the body frame\r\n    MPUQuaternionMultiply(gravity, MPU.m_fusedQuaternion, qTemp);\r\n    MPUQuaternionMultiply(fusedConjugate, qTemp, rotatedGravity);\r\n    \r\n    \/\/ Now subtract rotated gravity from the body accels to get real accelerations.\r\n    \/\/ Note that signs are reversed to get +ve acceleration results\r\n    \/\/ in the conventional axes.\r\n    \/\/ Quaternion Result\r\n    Quaternion_X = -(MPU.m_calAccel[VEC3_X] - rotatedGravity[QUAT_X]);\r\n    Quaternion_Y = -(MPU.m_calAccel[VEC3_Y] - rotatedGravity[QUAT_Y]);\r\n    Quaternion_Z = -(MPU.m_calAccel[VEC3_Z] - rotatedGravity[QUAT_Z]);\r\n\r\n    \/\/ Variable to calculate frequency\r\n    curr = micros();\r\n    freq = curr - last;\r\n    last = curr;\r\n    \/\/ Bluetooth\r\n    Serial.print( &quot;Blue|&quot; + BTA + &quot;|&quot; );\r\n    Serial.print( Quaternion_X );\r\n    Serial.print( &quot;|&quot; );\r\n    Serial.print( Quaternion_Y );\r\n    Serial.print( &quot;|&quot; );\r\n    Serial.print( Quaternion_Z );\r\n    Serial.print( &quot;|&quot; );\r\n    Serial.print( freq );\r\n    Serial.println( &quot;|*&quot; );\r\n    \/\/ Send any characters the Serial monitor prints to the bluetooth\r\n    bluetooth.print((char)Serial.read());\r\n   \r\n  }\r\n\r\n}\r\n<\/pre>\n<p><strong>setup.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Setup\r\nvoid setup()\r\n{\r\n  \r\n  \/\/ Serial\r\n  Serial.begin(SERIAL_PORT_SPEED);\r\n\r\n  \/\/ Bluetooth\r\n  \/\/ The Bluetooth Mate defaults to 115200bps\r\n  bluetooth.begin(115200);\r\n  \r\n  \/\/ Give display time to power on\r\n  delay(100);\r\n\r\n  \/\/ Wire communicate with I2C \/ TWI devices\r\n  Wire.begin();\r\n\r\n  \/\/ Pause\r\n  delay(50);\r\n\r\n  \/\/ Setup MPU\r\n  isSetupMPU();\r\n\r\n}\r\n<\/pre>\n<p>&#8212;&#8212;<\/p>\n<p><strong>People can contact us:<\/strong> https:\/\/www.donluc.com\/?page_id=1927<\/p>\n<p><strong>Technology Experience<\/strong><\/p>\n<ul>\n<li>Programming Language<\/li>\n<li>Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc&#8230;)<\/li>\n<li>IoT<\/li>\n<li>Wireless (Radio Frequency, Bluetooth, WiFi, Etc&#8230;)<\/li>\n<li>Robotics<\/li>\n<li>Camera and Video Capture Receiver Stationary, Wheel\/Tank and Underwater Vehicle<\/li>\n<li>Unmanned Vehicles Terrestrial and Marine<\/li>\n<li>Machine Learning<\/li>\n<li>RTOS<\/li>\n<li>Research &#038; Development (R &#038; D)<\/li>\n<\/ul>\n<p><strong>Instructor, E-Mentor, STEAM, and Arts-Based Training<\/strong><\/p>\n<ul>\n<li>Programming Language<\/li>\n<li>IoT<\/li>\n<li>PIC Microcontrollers<\/li>\n<li>Arduino<\/li>\n<li>Raspberry Pi<\/li>\n<li>Espressif<\/li>\n<li>Robotics<\/li>\n<\/ul>\n<p><strong>Follow Us<\/strong><\/p>\n<p><strong>Luc Paquin \u2013 Curriculum Vitae &#8211; 2023<\/strong><br \/>\nhttps:\/\/www.donluc.com\/luc\/<\/p>\n<p><strong>Web:<\/strong> https:\/\/www.donluc.com\/<br \/>\n<strong>Facebook:<\/strong> https:\/\/www.facebook.com\/neosteam.labs.9\/<br \/>\n<strong>YouTube:<\/strong> https:\/\/www.youtube.com\/@thesass2063<br \/>\n<strong>Twitter:<\/strong> https:\/\/twitter.com\/labs_steam<br \/>\n<strong>Pinterest:<\/strong> https:\/\/www.pinterest.com\/NeoSteamLabs\/<br \/>\n<strong>Instagram:<\/strong> https:\/\/www.instagram.com\/neosteamlabs\/<\/p>\n<p><strong>Don Luc<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8212; #DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #Accelerometer #Magnetometer #Gyroscope #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; MPU-9150 MotionInterface is becoming a &#8220;Must-Have&#8221; function being adopted by smartphone and tablet manufacturers due to the enormous value it adds to the end user experience. In smartphones, it finds use in applications such as gesture &#8230; <a title=\"Project #26 &#8211; Radio Frequency &#8211; Bluetooth MPU-9150 &#8211; Mk17\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=3503\" aria-label=\"Read more about Project #26 &#8211; Radio Frequency &#8211; Bluetooth MPU-9150 &#8211; Mk17\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[247,50,49,38,59,5,287,58,10,43],"tags":[251,6,242,289,4,19,85,252,246,24,9,27,264,109,33,34],"class_list":["post-3503","post","type-post","status-publish","format-standard","hentry","category-radio-frequency","category-arduino","category-consultant","category-digitalelectronics","category-fritzing","category-microcontrollers","category-program","category-arduino-programming","category-projects","category-sparkfun","tag-accelerometer","tag-arduino","tag-bluetooth","tag-bluetooth-mpu-9150","tag-consultant","tag-electronics","tag-fritzing","tag-gyroscope","tag-magnetometer","tag-microcontroller","tag-programming","tag-projects-2","tag-radio-frequency","tag-sparkfun","tag-technology","tag-video-blog"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3503"}],"version-history":[{"count":2,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3503\/revisions"}],"predecessor-version":[{"id":3907,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3503\/revisions\/3907"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}