{"id":162153,"date":"2025-05-01T15:50:44","date_gmt":"2025-05-01T10:20:44","guid":{"rendered":"https:\/\/www.electronicsforu.com\/?p=162153"},"modified":"2025-05-06T16:13:02","modified_gmt":"2025-05-06T10:43:02","slug":"real-time-soil-moisture-monitoring-arduino","status":"publish","type":"post","link":"https:\/\/www.electronicsforu.com\/electronics-projects\/real-time-soil-moisture-monitoring-arduino","title":{"rendered":"\u200bReal-Time Soil Moisture Monitoring with Arduino and Web Interface"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"alignright size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"178\" height=\"163\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/efy-tested-1.jpg\" alt=\"EFY Tested Project Markup\" class=\"wp-image-143513\"\/><\/figure><\/div>\n\n\n<p>Sensors now play a pivotal role in how environmental changes are perceived, monitored, and addressed. These smart devices capture real-world inputs\u2014temperature, humidity, pressure, moisture\u2014and generate the raw data that powers innovation across agriculture, healthcare, environmental science, and smart infrastructure. Their value lies not just in data collection but in effective visualisation and application.<\/p>\n\n\n\n<p>Consider a remote agricultural field where soil moisture is tracked continuously, anomalies are detected in real time, and decisions are made from afar. Integrating sensors with web technologies transforms this into a practical solution. This fusion bridges hardware and software, enabling real-time visualisation, trend analysis, and seamless offline data logging.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">POC Video Tutorial:<\/h2>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<span class=\"60FT8uSXa1L3UfDGkQbJewEZqsiYr4mnKPohRO2Bz9dvHgcCpMW5\"><iframe loading=\"lazy\" title=\"Smart sensors, smarter web: Capturing And Recording Data Online | Electronics For You\" width=\"696\" height=\"392\" src=\"https:\/\/www.youtube.com\/embed\/7DzlNhzc4Ss?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/span>\n<\/div><\/figure>\n\n\n\n<p>Built using a soil moisture sensor and an Arduino board, this system sends data to a web page via the browser\u2019s serial API. A dynamic line graph offers real-time updates, with an option to download data in CSV format.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td colspan=\"2\"><strong>Bill of Materials<\/strong><\/td><\/tr><tr><td><strong>Components<\/strong><\/td><td><strong>Quantity<\/strong><\/td><\/tr><tr><td><a href=\"https:\/\/www.electronicsforu.com\/technology-trends\/learn-electronics\/arduino-basics-schematics\">Arduino Uno<\/a> (MOD1)<\/td><td>1<\/td><\/tr><tr><td>Soil moisture sensor (S1)<\/td><td>1<\/td><\/tr><tr><td>USB cable for Arduino<\/td><td>1<\/td><\/tr><tr><td>Jumper wires (male to female)<\/td><td>As required<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The goal is to highlight how accessible tools\u2014HTML, JavaScript, and Chart.js\u2014can be used to build effective smart sensing systems. Designed for educational, experimental, or applied use, this setup serves as a strong foundation for exploring hardware-software integration.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"385\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Soil-sensor-in-pot-and-Arduino-connected-to-laptop-USB-for-data-transfer.jpg\" alt=\"Soil sensor in pot and Arduino connected to laptop USB for data transfer\" class=\"wp-image-162176\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Soil-sensor-in-pot-and-Arduino-connected-to-laptop-USB-for-data-transfer.jpg 800w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Soil-sensor-in-pot-and-Arduino-connected-to-laptop-USB-for-data-transfer-500x241.jpg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Soil-sensor-in-pot-and-Arduino-connected-to-laptop-USB-for-data-transfer-150x72.jpg 150w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Soil-sensor-in-pot-and-Arduino-connected-to-laptop-USB-for-data-transfer-696x335.jpg 696w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Fig. 1: Soil sensor in pot and Arduino connected to laptop USB for data transfer<\/figcaption><\/figure><\/div>\n\n\n<p>Fig. 1 shows the tested prototype in which soil sensor is in pot and Arduino is connected to laptop USB for data transfer. Refer to the Bill of Materials table to assemble the system. Fig. 2 shows the web page showing the data in real time with a graph.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"402\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Web-page-showing-the-data-in-real-time-with-a-graph.jpg\" alt=\"Web page showing the Soil Moisture Monitoring data in real time with a graph\" class=\"wp-image-162177\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Web-page-showing-the-data-in-real-time-with-a-graph.jpg 600w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Web-page-showing-the-data-in-real-time-with-a-graph-500x335.jpg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Web-page-showing-the-data-in-real-time-with-a-graph-150x101.jpg 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption class=\"wp-element-caption\">Fig. 2: Web page showing the data in real time with a graph<\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Soil Moisture Monitoring with Arduino &#8211; Circuit Diagram<\/strong><\/h2>\n\n\n\n<p>Fig. 3 shows the physical connection of the system, while Fig. 4 provides the schematic. In both diagrams, the sensor\u2019s output signal pin is connected to A0 pin of the Arduino board. VCC and GND pins of the sensor are connected to the Arduino\u2019s 5V and GND pins, respectively.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"292\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Physical-connection.jpg\" alt=\"Soil Moisture Monitoring Arduino Circuit\" class=\"wp-image-162178\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Physical-connection.jpg 600w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Physical-connection-500x243.jpg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Physical-connection-150x73.jpg 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption class=\"wp-element-caption\">Fig. 3: Physical connection<\/figcaption><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"421\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Circuit-diagram-3.jpg\" alt=\"Circuit Diagram for Soil Moisture Monitoring Project\" class=\"wp-image-162179\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Circuit-diagram-3.jpg 600w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Circuit-diagram-3-500x351.jpg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Circuit-diagram-3-150x105.jpg 150w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Circuit-diagram-3-100x70.jpg 100w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption class=\"wp-element-caption\">Fig. 4: Circuit diagram<\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Software<\/strong><\/h2>\n\n\n\n<p>Three sets of code are prepared for the system. The first is for the Arduino Uno, which collects sensor data and transmits it via the serial port. The second and third are for HTML and JavaScript, respectively. The HTML code defines the user interface, including the graph and control buttons, while the JavaScript code manages the serial port connection, processes the incoming data, displays it on the page and draws a graph, and allows users to download logged data in CSV format.<\/p>\n\n\n\n<p>To begin, upload the Arduino code by selecting the appropriate board and port in the Arduino IDE. Fig. 5 provides a snippet of the Arduino code.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"208\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Snippet-of-Arduino-code.jpg\" alt=\"Arduino Code for Soil Moisture Monitoring\" class=\"wp-image-162180\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Snippet-of-Arduino-code.jpg 600w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Snippet-of-Arduino-code-500x173.jpg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Snippet-of-Arduino-code-150x52.jpg 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption class=\"wp-element-caption\">Fig. 5: Snippet of Arduino code<\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Web Application Setup<\/strong><\/h2>\n\n\n\n<div class=\"mepr_error\"><div class=\"locked-content\">\n<b>EFY++ CONTENT: ACCESS TO THIS CONTENT IS FREE! BUT YOU NEED TO BE A REGISTERED USER.<\/b><\/p>\n<p>Oops! This is an EFY++ article, which means it's our Premium Content. You need to be a Registered User of our website to read its complete content.<\/p>\n<p><b>Good News: <\/b>You can register to our website for FREE! <a href=\"https:\/\/www.electronicsforu.com\/plans\/subscription-plans\" target=\"_blank\" rel=\"noopener\">CLICK HERE<\/a> to register now.<\/p>\n<p><b>Already a registered member? <\/b>If YES, then simply login to you account below. (TIP: Use 'forgot password' feature and reset and save your new password in your browser, if you forgot the last one!)\n<\/div>\n<\/div><div>\n<div class=\"mp_wrapper mp_login_form\">\n                  <!-- mp-login-form-start -->     <form name=\"mepr_loginform\" id=\"mepr_loginform\" class=\"mepr-form\" action=\"https:\/\/www.electronicsforu.com\/login\" method=\"post\">\n            <div class=\"mp-form-row mepr_username\">\n        <div class=\"mp-form-label\">\n                              <label for=\"user_login\">Username<\/label>\n        <\/div>\n        <input type=\"text\" name=\"log\" id=\"user_login\" value=\"\" \/>\n      <\/div>\n      <div class=\"mp-form-row mepr_password\">\n        <div class=\"mp-form-label\">\n          <label for=\"user_pass\">Password<\/label>\n          <div class=\"mp-hide-pw\">\n            <input type=\"password\" name=\"pwd\" id=\"user_pass\" value=\"\" \/>\n            <button type=\"button\" class=\"button mp-hide-pw hide-if-no-js\" data-toggle=\"0\" aria-label=\"Show password\">\n              <span class=\"dashicons dashicons-visibility\" aria-hidden=\"true\"><\/span>\n            <\/button>\n          <\/div>\n        <\/div>\n      <\/div>\n            <div>\n        <label><input name=\"rememberme\" type=\"checkbox\" id=\"rememberme\" value=\"forever\" \/> Remember Me<\/label>\n      <\/div>\n      <div class=\"mp-spacer\">&nbsp;<\/div>\n      <div class=\"submit\">\n        <input type=\"submit\" name=\"wp-submit\" id=\"wp-submit\" class=\"button-primary mepr-share-button \" value=\"Log In\" \/>\n        <input type=\"hidden\" name=\"redirect_to\" value=\"\/wp-json\/wp\/v2\/posts\/162153\" \/>\n        <input type=\"hidden\" name=\"mepr_process_login_form\" value=\"true\" \/>\n        <input type=\"hidden\" name=\"mepr_is_login_page\" value=\"false\" \/>\n      <\/div>\n    <\/form>\n    <div class=\"mp-spacer\">&nbsp;<\/div>\n    <div class=\"mepr-login-actions\">\n      <a href=\"https:\/\/www.electronicsforu.com\/login?action=forgot_password\">Forgot Password<\/a>\n    <\/div>\n\n      \n    <!-- mp-login-form-end --> \n  <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sensors now play a pivotal role in how environmental changes are perceived, monitored, and addressed. These smart devices capture real-world inputs\u2014temperature, humidity, pressure, moisture\u2014and generate the raw data that powers innovation across agriculture, healthcare, environmental science, and smart infrastructure. Their value lies not just in data collection but in effective visualisation and application. Consider a [&hellip;]<\/p>\n","protected":false},"author":109777,"featured_media":162178,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,23,3805,3713],"tags":[1985,1911,110,12709],"class_list":{"0":"post-162153","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-arduino-projects","10":"category-premium","11":"tag-diy-projects","12":"tag-do-it-yourself","13":"tag-electronics-projects","14":"tag-may-2025"},"_links":{"self":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/162153","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\/109777"}],"replies":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/comments?post=162153"}],"version-history":[{"count":2,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/162153\/revisions"}],"predecessor-version":[{"id":162721,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/162153\/revisions\/162721"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/media\/162178"}],"wp:attachment":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/media?parent=162153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/categories?post=162153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/tags?post=162153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}