{"id":3233,"date":"2022-11-05T06:22:26","date_gmt":"2022-11-05T13:22:26","guid":{"rendered":"https:\/\/www.donluc.com\/?p=3233"},"modified":"2022-11-05T06:22:26","modified_gmt":"2022-11-05T13:22:26","slug":"project-24-rtos-magnetometers-hmc5883l-mk02","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=3233","title":{"rendered":"Project #24 &#8211; RTOS &#8211; Magnetometers HMC5883L &#8211; Mk02"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3233-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #SparkFunRedBoard #RTOS #FreeRTOS #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\/DL2210Mk03a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03a.png\" alt=\"Magnetometers HMC5883L\" width=\"720\" height=\"444\" class=\"alignnone size-full wp-image-3236\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03a-300x185.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\/DL2210Mk03b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03b.png\" alt=\"Magnetometers HMC5883L\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3237\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03b-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\/DL2210Mk03c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03c.png\" alt=\"Magnetometers HMC5883L\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3238\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk03c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>SparkFun Triple Axis Magnetometer Breakout &#8211; HMC5883L<\/strong><\/p>\n<p>This is a breakout board for Honeywell&#8217;s HMC5883L, a 3-axis digital compass. Communication with the HMC5883L is simple and all done through an I2C interface. There is no on-board regulator, so a regulated voltage of 2.16-3.6VDC should be supplied. The breakout board includes the HMC5883L sensor and all filtering capacitors as shown. The power and 2-wire interface pins are all broken out to a 0.1&#8243; pitch header.<\/p>\n<p>Magnetometers have a wide range of uses. The most common include using the chip as a digital compass to sense direction or using them to detect ferrous (magnetic) metals. Magnetic fields and current go hand-in-hand. When current flows through a wire, a magnetic field is created. This is the basic principle behind electromagnets. This is also the principle used to measure magnetic fields with a magnetometer. The direction of Earth&#8217;s magnetic fields affects the flow of electrons in the sensor, and those changes in current can be measured and calculated to derive a compass heading or other useful information.<\/p>\n<p><strong>DL2210Mk03<\/strong><\/p>\n<p>1 x SparkFun RedBoard Qwiic<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>DL2210Mk03p.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 #24 - RTOS - Magnetometer - Mk02\r\n24-02\r\nDL2210Mk03p.ino\r\n1 x SparkFun RedBoard Qwiic\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\/\/ FreeRTOS\r\n#include &lt;Arduino_FreeRTOS.h&gt;\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\r\n\/\/ Define two tasks for Triple Axis Magnetometer\r\nvoid isTaskMagnetometer( void *pvParameters );\r\n\r\n\/\/ Software Version Information\r\nString sver = &quot;24-02&quot;;\r\n\r\nvoid loop() {\r\n\r\n  \/\/ Empty. Things are done in Tasks.\r\n  \r\n}\r\n<\/pre>\n<p><strong>getTasks.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Tasks\r\n\/\/ Setup Task\r\nvoid isSetupTask(){\r\n\r\n  \/\/ Now set up one tasks to run independently\r\n  \/\/ Magnetometer\r\n  \/\/xTaskCreatePinnedToCore(\r\n  xTaskCreate(\r\n    isTaskMagnetometer\r\n    ,  &quot;Magnetometer&quot;\r\n    ,  128  \/\/ Stack size\r\n    ,  NULL\r\n    ,  1  \/\/ Priority\r\n    ,  NULL);\r\n\r\n  \/\/ Now the task scheduler, which takes over control of scheduling individual tasks,\r\n  \/\/ is automatically started.\r\n  \r\n}\r\n\/\/ This is a Task Magnetometer Serial\r\nvoid isTaskMagnetometer(void *pvParameters)\r\n{\r\n  \r\n  (void) pvParameters;\r\n  \r\n  \/\/ Triple Axis Magnetometer\r\n  HMC5883L compass;\r\n\r\n  \/\/ Magnetometer Serial\r\n  \/\/ Initialize HMC5883L\r\n  Serial.println(&quot;Initialize HMC5883L&quot;);\r\n  while (!compass.begin())\r\n  {\r\n    Serial.println(&quot;Could not find a valid HMC5883L sensor, check wiring!&quot;);\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  for (;;)\r\n  {\r\n    \r\n    \/\/ Vector Norm\r\n    Vector norm = compass.readNormalize();\r\n    \/\/ Vector X, Y, Z\r\n    Serial.print(&quot;Xnorm = &quot;);\r\n    Serial.print(norm.XAxis);\r\n    Serial.print(&quot; Ynorm = &quot;);\r\n    Serial.print(norm.YAxis);\r\n    Serial.print(&quot; ZNorm = &quot;);\r\n    Serial.print(norm.ZAxis);\r\n    Serial.println();  \r\n    \/\/ One tick delay in between reads\r\n    vTaskDelay(500);\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  \/\/ Initialize serial communication\r\n  \/\/ at 9600 bits per second:\r\n  Serial.begin(9600);\r\n\r\n  \/\/ Setup Task\r\n  isSetupTask();\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>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>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 #RTOS #FreeRTOS #Magnetometer #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; SparkFun Triple Axis Magnetometer Breakout &#8211; HMC5883L This is a breakout board for Honeywell&#8217;s HMC5883L, a 3-axis digital compass. Communication with the HMC5883L is simple and all done through an I2C interface. There is no on-board regulator, &#8230; <a title=\"Project #24 &#8211; RTOS &#8211; Magnetometers HMC5883L &#8211; Mk02\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=3233\" aria-label=\"Read more about Project #24 &#8211; RTOS &#8211; Magnetometers HMC5883L &#8211; Mk02\">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":[236,50,49,38,5,58,10,43],"tags":[6,102,4,19,243,85,246,245,24,9,27,244,109,33,34],"class_list":["post-3233","post","type-post","status-publish","format-standard","hentry","category-rtos","category-arduino","category-consultant","category-digitalelectronics","category-microcontrollers","category-arduino-programming","category-projects","category-sparkfun","tag-arduino","tag-components","tag-consultant","tag-electronics","tag-freertos","tag-fritzing","tag-magnetometer","tag-magnetometers-hmc5883l","tag-microcontroller","tag-programming","tag-projects-2","tag-rtos","tag-sparkfun","tag-technology","tag-video-blog"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3233","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=3233"}],"version-history":[{"count":1,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3233\/revisions"}],"predecessor-version":[{"id":3239,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3233\/revisions\/3239"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}