{"id":52358,"date":"2026-11-01T10:51:00","date_gmt":"2026-11-01T10:51:00","guid":{"rendered":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/"},"modified":"2026-11-01T10:51:00","modified_gmt":"2026-11-01T10:51:00","slug":"soil-moisture-sensor","status":"publish","type":"siratek_tutorial","link":"https:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/","title":{"rendered":"Reading Soil Moisture"},"content":{"rendered":"<body><p><\/p>\n<h2>What it does<\/h2>\n<p>Two exposed metal tracks on a fork-shaped probe, pushed into soil. Wet soil conducts better than dry soil, so the resistance between the tracks falls as the soil gets wetter, and a small comparator board turns that into something an Arduino can read.<\/p>\n<p>It is the same voltage divider as the LDR, with soil in place of the photoresistor. If you have done that tutorial, the electronics here will already make sense, and this page can spend its time on the two things that actually catch people out: what the sensor really measures, and why it destroys itself if you leave it switched on.<\/p>\n<h2>Before you begin<\/h2>\n<h3>Required parts and tools<\/h3>\n<ul>\n<li>An Arduino Uno or compatible board.<\/li>\n<li>One soil moisture sensor set. This is Siratek product 2841, which comes as <strong>two pieces<\/strong>: the fork probe and a small comparator board, with two jumper leads to join them.<\/li>\n<li>Four more jumper wires.<\/li>\n<\/ul>\n<h3>The two boards<\/h3>\n<p><strong>The probe<\/strong> is the fork with two gold-coloured tracks and a two-pin header marked <code>+<\/code> and <code>-<\/code>. It contains no electronics at all. It is two electrodes.<\/p>\n<p><strong>The comparator board<\/strong> is the small blue board carrying an LM393, a blue trimmer, two indicator LEDs and a four-pin header labelled:<\/p>\n<p><strong><code>AO<\/code>  <code>DO<\/code>  <code>GND<\/code>  <code>VCC<\/code><\/strong><\/p>\n<p>The supplied leads join the probe\u2019s two pins to the two pins on the end of the comparator board. Either way round; the probe has no polarity that matters.<\/p>\n<h3>Analog or digital<\/h3>\n<p>This board gives you both, and the choice matters more here than anywhere else in the library.<\/p>\n<ul>\n<li><strong><code>AO<\/code><\/strong> is the raw divider voltage. Wetter soil, lower reading, with everything in between.<\/li>\n<li><strong><code>DO<\/code><\/strong> is HIGH or LOW depending on whether <code>AO<\/code> has crossed a threshold set by the blue trimmer.<\/li>\n<\/ul>\n<p><strong>Use <code>AO<\/code>.<\/strong> Soil is not a consistent material, and \u201cwet enough\u201d depends on your soil, your pot and your plant. The analog reading lets you watch the real numbers and choose a threshold from them. The trimmer makes you guess by eye and hides what is happening.<\/p>\n<p>Fit <code>DO<\/code> at the end if you need the Arduino pin back. Not before.<\/p>\n<h3>What it actually measures<\/h3>\n<p>It measures <strong>electrical conductivity<\/strong>, not water.<\/p>\n<p>That distinction is not pedantry. Conductivity depends on dissolved salts as well as water, so feeding a plant can raise the reading with no change in moisture at all. Different soils give different numbers at the same dampness. Compost and sandy soil are not comparable.<\/p>\n<p>So a number from this sensor means something only against other numbers from the same probe, in the same pot. Every threshold must be measured where it will be used. A value copied from a tutorial, including this one, is worthless.<\/p>\n<h3>It corrodes, and this is the real limitation<\/h3>\n<p>Running a current through two metal electrodes in damp soil is electrolysis. The tracks oxidise and eventually the plating lifts off, and the readings drift the whole way through.<\/p>\n<p>Left permanently powered in a damp pot, a resistive probe like this can degrade visibly within weeks.<\/p>\n<p>The fix is to <strong>power it only while reading<\/strong>. Instead of wiring <code>VCC<\/code> to the <code>5V<\/code> rail, wire it to a digital pin: turn the pin on, wait a moment for the reading to settle, take it, turn the pin off. A plant does not dry out in a minute, so reading once every ten minutes is plenty, and the probe spends 99.9 percent of its life unpowered.<\/p>\n<p>The board draws only a few milliamps, well within what a pin can supply. The example below does this, and it is the main reason to prefer it to the simpler version.<\/p>\n<p>If you need a probe that will last outdoors for years, the capacitive type is the answer, because its electrodes are not in contact with the soil at all.<\/p>\n<h2>Pin reference<\/h2>\n<table>\n<thead>\n<tr>\n<th>Pin or label<\/th>\n<th>Connect to<\/th>\n<th>Purpose<\/th>\n<th>Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>VCC<\/code><\/td>\n<td>Uno <code>D7<\/code><\/td>\n<td>Power, switched<\/td>\n<td>Not the <code>5V<\/code> rail, so the probe is only live while reading<\/td>\n<\/tr>\n<tr>\n<td><code>GND<\/code><\/td>\n<td>Uno <code>GND<\/code><\/td>\n<td>Ground<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>AO<\/code><\/td>\n<td>Uno <code>A0<\/code><\/td>\n<td>Analog reading<\/td>\n<td>The one to use<\/td>\n<\/tr>\n<tr>\n<td><code>DO<\/code><\/td>\n<td>Not connected<\/td>\n<td>Threshold output<\/td>\n<td>Only if you need the pin back<\/td>\n<\/tr>\n<tr>\n<td>Probe <code>+<\/code> and <code>-<\/code><\/td>\n<td>The comparator board\u2019s two-pin end<\/td>\n<td>The electrodes<\/td>\n<td>Either way round<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<figure class=\"siratek-tutorial-figure\"><img decoding=\"async\" src=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/soil-moisture-sensor-wiring.svg\" alt=\"A soil moisture probe joined to its comparator board, with VCC on a digital pin so the probe is powered only while a reading is taken, and AO on A0\" loading=\"lazy\"><figcaption>Powering VCC from a digital pin rather than the 5V rail is what stops the probe corroding.<\/figcaption><\/figure>\n<h2>Wiring steps<\/h2>\n<ol>\n<li>Unplug the USB cable.<\/li>\n<li>Join the probe to the comparator board with the two supplied leads.<\/li>\n<li><code>GND<\/code> on the comparator board to the Uno\u2019s <code>GND<\/code>.<\/li>\n<li><code>VCC<\/code> on the comparator board to <code>D7<\/code>. Not to <code>5V<\/code>.<\/li>\n<li><code>AO<\/code> to <code>A0<\/code>.<\/li>\n<li>Leave <code>DO<\/code> unconnected.<\/li>\n<li>Plug the USB cable back in. The power LED stays dark until the sketch drives <code>D7<\/code> high, which is correct.<\/li>\n<\/ol>\n<h2>Software and libraries<\/h2>\n<p>No library is required.<\/p>\n<h2>Minimal working example<\/h2>\n<p>Measure your own range first. Nothing else in this tutorial is useful until you have.<\/p>\n<pre><code>\/\/ Siratek: find the real range of your probe, in your soil.\n\nconst int sensorPin = A0;\nconst int powerPin = 7;\n\nvoid setup() {\n  pinMode(powerPin, OUTPUT);\n  digitalWrite(powerPin, LOW);\n\n  Serial.begin(9600);\n  Serial.println(\"Siratek: try the probe dry in air, then in water, then in your pot.\");\n}\n\nvoid loop() {\n  digitalWrite(powerPin, HIGH);\n  delay(200);                       \/\/ let the divider settle\n  int reading = analogRead(sensorPin);\n  digitalWrite(powerPin, LOW);\n\n  Serial.print(\"reading = \");\n  Serial.println(reading);\n\n  delay(1000);\n}<\/code><\/pre>\n<p>Do three things with this and write the numbers down: hold the probe in <strong>dry air<\/strong>, stand it in a <strong>glass of water<\/strong> up to the line on the board, and push it into the <strong>pot you actually care about<\/strong>, once just after watering and once when the plant is ready for more.<\/p>\n<p>Air and water give you the two extremes. The two pot readings give you the range that matters, and the threshold belongs between them.<\/p>\n<p>Note the 200 millisecond settle after switching the power on. Without it you read the divider before it has stabilised and get a number that is too high.<\/p>\n<h3>Watering only when it is needed<\/h3>\n<pre><code>\/\/ Siratek: check every ten minutes and report when the soil is dry.\n\nconst int sensorPin = A0;\nconst int powerPin = 7;\n\n\/\/ Measure your own. Higher reading means drier on this wiring.\nconst int dryAbove = 700;\nconst int wetBelow = 450;\n\nconst unsigned long interval = 600000UL;  \/\/ ten minutes\n\nunsigned long lastCheck = 0;\nbool dry = false;\n\nint readSoil() {\n  digitalWrite(powerPin, HIGH);\n  delay(200);\n\n  long total = 0;\n  for (int i = 0; i &lt; 8; i++) {\n    total += analogRead(sensorPin);\n    delay(10);\n  }\n\n  digitalWrite(powerPin, LOW);\n  return total \/ 8;\n}\n\nvoid setup() {\n  pinMode(powerPin, OUTPUT);\n  digitalWrite(powerPin, LOW);\n  Serial.begin(9600);\n  lastCheck = millis() - interval;   \/\/ check once at startup\n}\n\nvoid loop() {\n  if (millis() - lastCheck &gt;= interval) {\n    lastCheck = millis();\n\n    int reading = readSoil();\n    Serial.print(\"soil = \");\n    Serial.println(reading);\n\n    if (!dry &amp;&amp; reading &gt; dryAbove) {\n      dry = true;\n      Serial.println(\"dry: water the plant\");\n    } else if (dry &amp;&amp; reading &lt; wetBelow) {\n      dry = false;\n      Serial.println(\"watered\");\n    }\n  }\n}<\/code><\/pre>\n<p>Two thresholds again, not one, for the same reason as the LDR: a single threshold makes the state flap whenever the reading wavers. Here it would be worse than untidy, because this is the sketch that eventually drives a pump.<\/p>\n<p>Averaging eight readings smooths the noise. The probe is in damp earth, which is not a quiet electrical environment.<\/p>\n<h2>Expected result<\/h2>\n<p>A reading that is high in dry air, low in water, and somewhere between in soil. The exact numbers are yours alone.<\/p>\n<p>The power LED on the comparator board should blink briefly once per reading and be dark the rest of the time. If it stays lit, <code>VCC<\/code> is still on the <code>5V<\/code> rail.<\/p>\n<h2>Troubleshooting<\/h2>\n<table>\n<thead>\n<tr>\n<th>Symptom<\/th>\n<th>Likely cause<\/th>\n<th>Check or fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Reading never changes<\/td>\n<td>Probe leads not connected<\/td>\n<td>Check the two-pin link to the probe<\/td>\n<\/tr>\n<tr>\n<td>Reading pinned at maximum<\/td>\n<td><code>AO<\/code> not connected, or probe open<\/td>\n<td>Check <code>A0<\/code> and the probe leads<\/td>\n<\/tr>\n<tr>\n<td>Power LED always on<\/td>\n<td><code>VCC<\/code> on the <code>5V<\/code> rail<\/td>\n<td>Move it to a digital pin<\/td>\n<\/tr>\n<tr>\n<td>Reading drifts over weeks<\/td>\n<td>Electrodes corroding<\/td>\n<td>Switch the power; consider a capacitive probe<\/td>\n<\/tr>\n<tr>\n<td>Tracks look dull or pitted<\/td>\n<td>Already corroded<\/td>\n<td>Replace the probe; it will not recover<\/td>\n<\/tr>\n<tr>\n<td>Numbers differ from a friend\u2019s<\/td>\n<td>Different soil and probe<\/td>\n<td>Normal; always measure your own<\/td>\n<\/tr>\n<tr>\n<td>Reading jumps after feeding<\/td>\n<td>Fertiliser raises conductivity<\/td>\n<td>Expected; it measures conductivity, not water<\/td>\n<\/tr>\n<tr>\n<td>Values unstable<\/td>\n<td>No settle time after power-up<\/td>\n<td>Wait 200 ms before reading; average several<\/td>\n<\/tr>\n<tr>\n<td><code>DO<\/code> never changes<\/td>\n<td>Trimmer set past the range<\/td>\n<td>Use <code>AO<\/code> instead<\/td>\n<\/tr>\n<tr>\n<td>Works in a glass, odd in soil<\/td>\n<td>Probe not fully in contact<\/td>\n<td>Firm the soil around it<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Next steps<\/h2>\n<ul>\n<li><strong>Easier first:<\/strong> <em>Measuring Light with an LDR<\/em>, which is the same divider with light.<\/li>\n<li><strong>Related products:<\/strong> the rain and water level sensor, which works the same way, and a relay for switching a pump.<\/li>\n<li><strong>Next project:<\/strong> an automatic watering system. Build it with a low-voltage pump and read the relay tutorial\u2019s safety section first.<\/li>\n<\/ul>\n<h2>Sources and attribution<\/h2>\n<p>All text, wiring guidance and code in this tutorial are original Siratek work.<\/p>\n<ul>\n<li>The two-part construction described here, a passive fork probe plus an LM393 comparator board with an <code>AO DO GND VCC<\/code> header, a trimmer and two indicator LEDs, was read from the Siratek product photographs for item 2841.<\/li>\n<\/ul>\n<p>Every threshold in this tutorial is presented as something the reader must measure in their own soil rather than copy. The corrosion behaviour of resistive probes is a property of the electrochemistry rather than a fault, and the switched-power approach given here is the standard mitigation. No third-party tutorial text, diagrams, photographs or code has been reproduced here.<\/p>\n<p><\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>Two exposed metal tracks on a fork-shaped probe, pushed into soil. Wet soil conducts better than dry soil, so the resistance between the tracks falls as the soil gets wetter, and a small comparator board turns that into something an&#8230;<\/p>\n","protected":false},"featured_media":0,"template":"","siratek_tutorial_level":[],"class_list":["post-52358","siratek_tutorial","type-siratek_tutorial","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Reading Soil Moisture - siratek<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Reading Soil Moisture - siratek\" \/>\n<meta property=\"og:description\" content=\"Two exposed metal tracks on a fork-shaped probe, pushed into soil. Wet soil conducts better than dry soil, so the resistance between the tracks falls as the soil gets wetter, and a small comparator board turns that into something an...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/\" \/>\n<meta property=\"og:site_name\" content=\"siratek\" \/>\n<meta property=\"og:image\" content=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/soil-moisture-sensor-wiring.svg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/soil-moisture-sensor\\\/\",\"url\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/soil-moisture-sensor\\\/\",\"name\":\"Reading Soil Moisture - siratek\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/soil-moisture-sensor\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/soil-moisture-sensor\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/soil-moisture-sensor-wiring.svg\",\"datePublished\":\"2026-11-01T10:51:00+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/soil-moisture-sensor\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/soil-moisture-sensor\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/soil-moisture-sensor\\\/#primaryimage\",\"url\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/soil-moisture-sensor-wiring.svg\",\"contentUrl\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/soil-moisture-sensor-wiring.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/soil-moisture-sensor\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/siratek.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials\",\"item\":\"https:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Reading Soil Moisture\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\",\"url\":\"https:\\\/\\\/siratek.net\\\/\",\"name\":\"siratek\",\"description\":\"Your Best Electronic Retail Shop\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/siratek.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Reading Soil Moisture - siratek","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/","og_locale":"en_US","og_type":"article","og_title":"Reading Soil Moisture - siratek","og_description":"Two exposed metal tracks on a fork-shaped probe, pushed into soil. Wet soil conducts better than dry soil, so the resistance between the tracks falls as the soil gets wetter, and a small comparator board turns that into something an...","og_url":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/","og_site_name":"siratek","og_image":[{"url":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/soil-moisture-sensor-wiring.svg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/","url":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/","name":"Reading Soil Moisture - siratek","isPartOf":{"@id":"https:\/\/siratek.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/#primaryimage"},"image":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/#primaryimage"},"thumbnailUrl":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/soil-moisture-sensor-wiring.svg","datePublished":"2026-11-01T10:51:00+00:00","breadcrumb":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/#primaryimage","url":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/soil-moisture-sensor-wiring.svg","contentUrl":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/soil-moisture-sensor-wiring.svg"},{"@type":"BreadcrumbList","@id":"http:\/\/siratek.net\/index.php\/tutorials\/soil-moisture-sensor\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/siratek.net\/"},{"@type":"ListItem","position":2,"name":"Tutorials","item":"https:\/\/siratek.net\/index.php\/tutorials\/"},{"@type":"ListItem","position":3,"name":"Reading Soil Moisture"}]},{"@type":"WebSite","@id":"https:\/\/siratek.net\/#website","url":"https:\/\/siratek.net\/","name":"siratek","description":"Your Best Electronic Retail Shop","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/siratek.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial"}],"about":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/types\/siratek_tutorial"}],"version-history":[{"count":0,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52358\/revisions"}],"wp:attachment":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/media?parent=52358"}],"wp:term":[{"taxonomy":"siratek_tutorial_level","embeddable":true,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial_level?post=52358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}