{"id":3247,"date":"2022-11-19T06:51:22","date_gmt":"2022-11-19T14:51:22","guid":{"rendered":"https:\/\/www.donluc.com\/?p=3247"},"modified":"2022-11-19T06:51:22","modified_gmt":"2022-11-19T14:51:22","slug":"project-25-movement-sensors-mk01","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=3247","title":{"rendered":"Project #25 &#8211; Movement &#8211; Sensors &#8211; Mk01"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3247-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #SparkFunRedBoard #Movement #Magnetometer #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05a.png\" alt=\"Sensors\" width=\"720\" height=\"524\" class=\"alignnone size-full wp-image-3249\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05a-300x218.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\/2022\/11\/DL2210Mk05b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05b.png\" alt=\"Sensors\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3250\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05b-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\/2022\/11\/DL2210Mk05c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05c.png\" alt=\"Sensors\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3251\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk05c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>Movement<\/strong><\/p>\n<p>Accelerometers, gyroscopes, and magnetometers are the three main sensors we use for detecting motion and orientation. We can sense motion with an accelerometer.<\/p>\n<p>Accelerometers are used to measure acceleration, that means linear motion in X, Y or Z. They can be used to detect when they are being moved around, detect motion, shock or vibration. They can also be used to detect gravitational pull in order to detect orientation or tilt.<\/p>\n<p>Gyroscopes are used to measure rotational motion in X, Y or Z. They are often paired with accelerometers for inertial guidance systems, 3D motion capture and inverted pendulum type applications.<\/p>\n<p>Magnetometers can sense where the strongest magnetic force is coming from, generally used to detect magnetic north, but can also be used for measuring magnetic fields. When combined with accelerometers and gyroscopes you can stabilize orientation calculations and also determine orientation with respect to the Earth.<\/p>\n<p>Many 6-DoF sensors, which combine accelerometer and gyroscope or compass, accelerometer and magnetometer, and 9-DoF sensors that have 9DoF IMU accelerometers and gyroscopes and magnetometers.<\/p>\n<p><strong>DL2210Mk05<\/strong><\/p>\n<p>1 x SparkFun RedBoard Qwiic<br \/>\n1 x SparkFun Micro OLED (Qwiic)<br \/>\n1 x Qwiic Cable &#8211; 100mm<br \/>\n1 x SparkFun Triple Axis Magnetometer Breakout &#8211; HMC5883L<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>SparkFun RedBoard Qwiic<\/strong><\/p>\n<p>SDA &#8211; Analog A4<br \/>\nSCL &#8211; Analog A5<br \/>\nVIN &#8211; +3.3V<br \/>\nGND &#8211; GND<\/p>\n<p><strong>DL2210Mk05p.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 #25 - Movement - Sensors - Mk01\r\n25-01\r\nDL2210Mk05p.ino\r\n1 x SparkFun RedBoard Qwiic\r\n1 x SparkFun Micro OLED (Qwiic)\r\n1 x Qwiic Cable - 100mm\r\n1 x SparkFun Triple Axis Magnetometer Breakout - HMC5883L\r\n1 x SparkFun Cerberus USB Cable\r\n*\/\r\n\r\n\/\/ Include the Library Code\r\n\/\/ Two Wire Interface (TWI\/I2C)\r\n#include &lt;Wire.h&gt;\r\n\/\/ Triple Axis Magnetometer\r\n#include &lt;HMC5883L.h&gt;\r\n\/\/ SparkFun Micro OLED\r\n#include &lt;SFE_MicroOLED.h&gt;\r\n\r\n\/\/ Triple Axis Magnetometer\r\nHMC5883L compass;\r\n\r\n\/\/ SparkFun Micro OLED\r\n#define PIN_RESET 9\r\n#define DC_JUMPER 1\r\n\/\/ I2C declaration\r\nMicroOLED oled(PIN_RESET, DC_JUMPER);\r\n\r\n\/\/ Triple Axis Magnetometer\r\nint X = 0;\r\nint Y = 0;\r\nint Z = 0;\r\n\r\n\/\/ Software Version Information\r\nString sver = &quot;25-01&quot;;\r\n\r\nvoid loop() {\r\n\r\n  \/\/ Triple Axis Magnetometer\r\n  isMagnetometer(),\r\n  \r\n  \/\/ Micro OLED\r\n  isMicroOLED();\r\n\r\n  \/\/ One delay in between reads\r\n  delay(1000);\r\n  \r\n}\r\n<\/pre>\n<p><strong>getMagnetometer.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Magnetometer\r\n\/\/ Setup Magnetometer\r\nvoid isSetupMagnetometer(){\r\n\r\n  \/\/ Magnetometer Serial\r\n  \/\/ Initialize HMC5883L\r\n  while (!compass.begin())\r\n  {\r\n    delay(500);\r\n  }\r\n\r\n  \/\/ Set measurement range\r\n  \/\/ +\/- 1.30 Ga: HMC5883L_RANGE_1_3GA (default)\r\n  compass.setRange(HMC5883L_RANGE_1_3GA);\r\n\r\n  \/\/ Set measurement mode\r\n  \/\/ Continuous-Measurement: HMC5883L_CONTINOUS (default)\r\n  compass.setMeasurementMode(HMC5883L_CONTINOUS);\r\n \r\n  \/\/ Set data rate\r\n  \/\/ 15.00Hz: HMC5883L_DATARATE_15HZ (default)\r\n  compass.setDataRate(HMC5883L_DATARATE_15HZ);\r\n\r\n  \/\/ Set number of samples averaged\r\n  \/\/ 1 sample:  HMC5883L_SAMPLES_1 (default)\r\n  compass.setSamples(HMC5883L_SAMPLES_1);\r\n  \r\n}\r\n\/\/ Magnetometer\r\nvoid isMagnetometer(){\r\n\r\n  \/\/ Vector Norm\r\n  Vector norm = compass.readNormalize();\r\n  \/\/ Vector X, Y, Z\r\n  \/\/ X Normalize\r\n  X = norm.XAxis;\r\n  \/\/ Y Normalize\r\n  Y = norm.YAxis;\r\n  \/\/ Z Normalize\r\n  Z = norm.ZAxis;\r\n\r\n}\r\n<\/pre>\n<p><strong>getMicroOLED.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ SparkFun Micro OLED\r\n\/\/ Setup Micro OLED\r\nvoid isSetupMicroOLED() {\r\n\r\n  \/\/ Initialize the OLED\r\n  oled.begin();\r\n  \/\/ Clear the display&#039;s internal memory\r\n  oled.clear(ALL);\r\n  \/\/ Display what&#039;s in the buffer (splashscreen)\r\n  oled.display();\r\n\r\n  \/\/ Delay 1000 ms\r\n  delay(1000);\r\n\r\n  \/\/ Clear the buffer.\r\n  oled.clear(PAGE);\r\n  \r\n}\r\n\/\/ Micro OLED\r\nvoid isMicroOLED() {\r\n\r\n  \/\/ Text Display Magnetometer\r\n  \/\/ Clear the display\r\n  oled.clear(PAGE);\r\n  \/\/ Set cursor to top-left\r\n  oled.setCursor(0, 0);\r\n  \/\/ Set font to type 0\r\n  oled.setFontType(0);\r\n  \/\/ Magnetometer\r\n  oled.print(&quot;Magneto&quot;);\r\n  oled.setCursor(0, 12);\r\n  \/\/ X Normalize\r\n  oled.print(&quot;X: &quot;);\r\n  oled.print(X);\r\n  oled.setCursor(0, 25);\r\n  \/\/ Y Normalize\r\n  oled.print(&quot;Y: &quot;);\r\n  oled.print(Y);\r\n  oled.setCursor(0, 39);\r\n  \/\/ Z Normalize\r\n  oled.print(&quot;Z: &quot;);\r\n  oled.print(Z);\r\n  oled.display();\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  \/\/ Give display time to power on\r\n  delay(100);\r\n  \r\n  \/\/ Set up I2C bus\r\n  Wire.begin();\r\n\r\n  \/\/ Setup Triple Axis Magnetometer\r\n  isSetupMagnetometer();\r\n\r\n  \/\/ Setup Micro OLED\r\n  isSetupMicroOLED();\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>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 and E-Mentor<\/strong><\/p>\n<ul>\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>J. Luc Paquin \u2013 Curriculum Vitae &#8211; 2022 English &#038; Espa\u00f1ol<\/strong><br \/>\nhttps:\/\/www.jlpconsultants.com\/luc\/<\/p>\n<p><strong>Web:<\/strong> https:\/\/www.donluc.com\/<br \/>\n<strong>Web:<\/strong> https:\/\/www.jlpconsultants.com\/<br \/>\n<strong>Facebook:<\/strong> https:\/\/www.facebook.com\/neosteam.labs.9\/<br \/>\n<strong>YouTube:<\/strong> https:\/\/www.youtube.com\/channel\/UC5eRjrGn1CqkkGfZy0jxEdA<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 #SparkFunRedBoard #Movement #Magnetometer #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; Movement Accelerometers, gyroscopes, and magnetometers are the three main sensors we use for detecting motion and orientation. We can sense motion with an accelerometer. Accelerometers are used to measure acceleration, that means linear motion in X, Y or &#8230; <a title=\"Project #25 &#8211; Movement &#8211; Sensors &#8211; Mk01\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=3247\" aria-label=\"Read more about Project #25 &#8211; Movement &#8211; Sensors &#8211; Mk01\">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":[240,50,49,38,59,5,58,10,43],"tags":[6,102,4,87,19,85,246,24,249,9,27,248,109,33,34],"class_list":["post-3247","post","type-post","status-publish","format-standard","hentry","category-movement","category-arduino","category-consultant","category-digitalelectronics","category-fritzing","category-microcontrollers","category-arduino-programming","category-projects","category-sparkfun","tag-arduino","tag-components","tag-consultant","tag-display","tag-electronics","tag-fritzing","tag-magnetometer","tag-microcontroller","tag-movement","tag-programming","tag-projects-2","tag-sensors","tag-sparkfun","tag-technology","tag-video-blog"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3247","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=3247"}],"version-history":[{"count":2,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3247\/revisions"}],"predecessor-version":[{"id":4780,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3247\/revisions\/4780"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}