{"id":3516,"date":"2023-07-15T06:07:47","date_gmt":"2023-07-15T13:07:47","guid":{"rendered":"https:\/\/www.donluc.com\/?p=3516"},"modified":"2023-07-15T06:07:47","modified_gmt":"2023-07-15T13:07:47","slug":"project-26-radio-frequency-bluetooth-moteino-mk18","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=3516","title":{"rendered":"Project #26 &#8211; Radio Frequency &#8211; Bluetooth Moteino &#8211; Mk18"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3516-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05W.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\/DL2306Mk05a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05a.png\" alt=\"Bluetooth Moteino\" width=\"720\" height=\"430\" class=\"alignnone size-full wp-image-3518\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05a-300x179.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\/DL2306Mk05b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05b.png\" alt=\"Bluetooth Moteino\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3519\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05b-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\/DL2306Mk05c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05c.png\" alt=\"Bluetooth Moteino\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3520\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/07\/DL2306Mk05c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>Moteino<\/strong><\/p>\n<p>Moteino began as a low power wireless Arduino compatible development platform based on the popular ATmega328p chip used in the Arduino UNO. Moteinos are compatible and can communicate with any other Arduino or development platform that uses the popular HopeRF RFM69 or LoRa transceivers, or even the older RFM12B. Moteino also comes with an optional SPI flash memory chip for wireless programming, or data logging. Moteino was designed to be a compact, highly customizable and affordable development platform, suitable for IoT, home automation and long range wireless projects.<\/p>\n<p>Moteino in RFM12B to rebuild suggests doing as new without completely replacing. I decided to stripped down at RFM12B and rebuild in Bluetooth.<\/p>\n<p><strong>DL2306Mk05<\/strong><\/p>\n<p>1 x Moteino<br \/>\n1 x SparkFun Bluetooth Mate Silver<br \/>\n1 x SparkFun 9 Degrees of Freedom Breakout &#8211; MPU-9150<br \/>\n1 x LED Red<br \/>\n1 x SparkFun FTDI Basic Breakout &#8211; 5V<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>Moteino<\/strong><\/p>\n<p>LED &#8211; Digital 8<br \/>\nRX &#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>DL2306Mk05p.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 Moteino - Mk18\r\n26-18\r\nDL2306Mk05p.ino\r\n1 x Moteino\r\n1 x SparkFun Bluetooth Mate Silver\r\n1 x SparkFun 9 Degrees of Freedom Breakout - MPU-9150\r\n1 x LED Red\r\n1 x SparkFun FTDI Basic Breakout - 5V\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;0006664FAE18&quot;;\r\n\r\n\/\/ LED Red\r\nint iLedRed = 8;\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-18&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  \/\/ LED Red\r\n  pinMode(iLedRed, OUTPUT);\r\n  digitalWrite(iLedRed, HIGH);\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; Moteino Moteino began as a low power wireless Arduino compatible development platform based on the popular ATmega328p chip used in the Arduino UNO. Moteinos are compatible and can communicate with any other Arduino or development platform &#8230; <a title=\"Project #26 &#8211; Radio Frequency &#8211; Bluetooth Moteino &#8211; Mk18\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=3516\" aria-label=\"Read more about Project #26 &#8211; Radio Frequency &#8211; Bluetooth Moteino &#8211; Mk18\">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,261,287,58,10,43],"tags":[251,6,92,242,290,102,4,19,85,252,246,24,263,249,9,27,264,109,33,34],"class_list":["post-3516","post","type-post","status-publish","format-standard","hentry","category-radio-frequency","category-arduino","category-consultant","category-digitalelectronics","category-fritzing","category-microcontrollers","category-moteino","category-program","category-arduino-programming","category-projects","category-sparkfun","tag-accelerometer","tag-arduino","tag-battery","tag-bluetooth","tag-bluetooth-moteino","tag-components","tag-consultant","tag-electronics","tag-fritzing","tag-gyroscope","tag-magnetometer","tag-microcontroller","tag-moteino","tag-movement","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\/3516","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=3516"}],"version-history":[{"count":1,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3516\/revisions"}],"predecessor-version":[{"id":3521,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3516\/revisions\/3521"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}