{"id":144662,"date":"2024-08-06T16:23:44","date_gmt":"2024-08-06T10:53:44","guid":{"rendered":"https:\/\/www.electronicsforu.com\/?p=144662"},"modified":"2025-03-18T11:25:09","modified_gmt":"2025-03-18T05:55:09","slug":"metal-detector-using-indusboard","status":"publish","type":"post","link":"https:\/\/www.electronicsforu.com\/electronics-projects\/metal-detector-using-indusboard","title":{"rendered":"Metal Detector Using IndusBoard Coin"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"alignright size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"152\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2016\/12\/Screen-Shot-2016-12-24-at-15.19.33-e1644389186872.png\" alt=\"\" class=\"wp-image-28226\"\/><figcaption class=\"wp-element-caption\">Comment errors or corrections found for this circuit, and get the chance to win big!<\/figcaption><\/figure><\/div>\n\n\n<p>A metal detector is an instrument that detects the nearby presence of metal. These devices are useful for finding metal objects on the surface, underground, and even underwater. <\/p>\n\n\n\n<p>A display can be connected to the <a href=\"https:\/\/shop.electronicsforu.com\/product\/indusboard-iot-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">IndusBoard coin<\/a> in which the password can be entered or it can also used just to give the command of entering the password saved on the board depending on how it is programmed.<\/p>\n\n\n\n<p>In this project, IndusBoard is programmed to work as a metal detector. Magnetometer sensor is used to detect nearby magnetic fields; whenever a metal comes close to the board, there are fluctuations in magnetometer readings which are programmed to detect nearby metal.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Components Required<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>S. <\/strong><strong>N<\/strong><strong>o.<\/strong><\/td><td><strong>Components<\/strong><\/td><td><strong>Description<\/strong><\/td><td><strong>Quantity<\/strong><\/td><\/tr><tr><td>1.<\/td><td>Indusboard coin<\/td><td>3cm sized dev board.<\/td><td>1<\/td><\/tr><tr><td>2.<\/td><td>Arduino IDE<\/td><td>To program the Indus board coin.<\/td><td>1<\/td><\/tr><tr><td>3.<\/td><td>USB type C cable<\/td><td>To connect the board to PC for programming.<\/td><td>1<\/td><\/tr><tr><td>4.<\/td><td>3.3V battery<\/td><td>To power the Indus board.<\/td><td>1<\/td><\/tr><tr><td>5.<\/td><td>Metal<\/td><td>To test the program.<\/td><td>1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Code for Metal Detection<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n #include &lt;Wire.h&gt; \n#include &lt;LSM303AGR_ACC_Sensor.h&gt; \n#include &lt;LSM303AGR_MAG_Sensor.h&gt; \n#define SerialPort Serial \n\/\/ Initialize components \nLSM303AGR_ACC_Sensor Acc(&amp;Wire); \nLSM303AGR_MAG_Sensor Mag(&amp;Wire); \n\/\/ Baseline magnetometer values \nfloat baselineMag&#91;3]; \nfloat magThreshold = 100.0; \/\/ Threshold for detecting metal \n\/\/ Function prototype for calibrateBaseline() \nvoid calibrateBaseline(); \nvoid setup() { \n\/\/ Initialize serial communication \nSerialPort.begin(115200); \n\/\/ Initialize I2C communication \nWire.begin(); \n\/\/ Initialize the accelerometer and magnetometer \nif (Acc.begin() != 0) { \nSerialPort.println(\"Failed to initialize LSM303AGR accelerometer!\"); \nwhile (1); \n} \nif (Mag.begin() != 0) { \nSerialPort.println(\"Failed to initialize LSM303AGR magnetometer!\"); \nwhile (1); \n} \n\/\/ Enable the accelerometer and magnetometer \nAcc.Enable(); \nMag.Enable(); \n\/\/ Calibrate baseline magnetometer readings \ncalibrateBaseline(); \n} \nvoid loop() { \n\/\/ Read accelerometer and magnetometer data \nint32_t accData&#91;3], magData&#91;3]; \nAcc.GetAxes(accData); \nMag.GetAxes(magData); \n\/\/ Calculate magnitude of the current magnetometer readings \nfloat magMagnitude = sqrt(sq(magData&#91;0]) + sq(magData&#91;1]) + sq(magData&#91;2])); \n\/\/ Calculate magnitude of the baseline magnetometer readings \nfloat baselineMagnitude = sqrt(sq(baselineMag&#91;0]) + sq(baselineMag&#91;1]) + sq(baselineMag&#91;2])); \n\/\/ Check for metal detection \nif (abs(magMagnitude - baselineMagnitude) &gt; magThreshold) { \nSerialPort.println(\"Metal detected!\"); \n} else { \nSerialPort.println(\"No metal detected.\"); \n} \n\/\/ Output sensor data for debugging \nSerialPort.print(\"Acc&#91;mg]: \"); \nSerialPort.print(accData&#91;0]); \nSerialPort.print(\" \"); \nSerialPort.print(accData&#91;1]); \nSerialPort.print(\" \"); \nSerialPort.print(accData&#91;2]); \nSerialPort.print(\" | Mag&#91;uT]: \"); \nSerialPort.print(magData&#91;0]); \nSerialPort.print(\" \"); \nSerialPort.print(magData&#91;1]); \nSerialPort.print(\" \"); \nSerialPort.print(magData&#91;2]); \nSerialPort.println(); \ndelay(500); \/\/ Adjust delay as needed \n} \nvoid calibrateBaseline() { \nint32_t magData&#91;3]; \nMag.GetAxes(magData); \n\/\/ Store baseline magnetometer readings \nbaselineMag&#91;0] = magData&#91;0]; \nbaselineMag&#91;1] = magData&#91;1]; \nbaselineMag&#91;2] = magData&#91;2]; \nSerialPort.println(\"Baseline calibration completed.\"); \n} <\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><em>Author(s): Manjeet Vishwakarma, &nbsp;Abhay Verma and Satywanti Kundu are B.Tech ECE students at GJUS&amp;T HISAR<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A metal detector is an instrument that detects the nearby presence of metal. These devices are useful for finding metal objects on the surface, underground, and even underwater. A display can be connected to the IndusBoard coin in which the password can be entered or it can also used just to give the command of [&hellip;]<\/p>\n","protected":false},"author":55758,"featured_media":142030,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,23,776,11851],"tags":[1985,1911,110],"class_list":{"0":"post-144662","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-electronics-projects","8":"category-hardware-diy","9":"category-prototypes","10":"category-super-innovative-projects","11":"tag-diy-projects","12":"tag-do-it-yourself","13":"tag-electronics-projects"},"_links":{"self":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/144662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/users\/55758"}],"replies":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/comments?post=144662"}],"version-history":[{"count":2,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/144662\/revisions"}],"predecessor-version":[{"id":159622,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/144662\/revisions\/159622"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/media\/142030"}],"wp:attachment":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/media?parent=144662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/categories?post=144662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/tags?post=144662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}