Another possible cause of wrinkling or peeling of the PCB mask on a capacitive soil moisture sensor and its solutions:

Another possible cause of wrinkling or peeling of the PCB mask on a capacitive soil moisture sensor and its solutions:

After using this type of sensor for some time, there is a possibility that the PCB portion inserted into the soil may become damaged. Typically, the issue is the peeling or wrinkling of the PCB’s protective mask layer, which can impact the accuracy of the soil data intended for measurement.

We generally believe that this damage occurs due to defects in the sensor’s PCB protective mask, allowing soil moisture to penetrate the PCB’s interior. Over time, corrosion can cause the protective layer to wrinkle or peel. This possibility is widely acknowledged, and the solution to this problem is to coat the PCB with waterproof paint or a substance like nail polish to enhance its waterproofing.

However, in many cases, even after applying the above methods, the PCB mask may still wrinkle or peel.

We believe that this situation does not occur due to defects in the PCB’s protective mask.

Upon close examination of the damaged areas of the sensor, we found that the damage is specifically localized to the ground trace of the circuit, while other parts remain intact. Along the wrinkles in the mask protective layer around the ground trace, a gentle push with tweezers is enough to detach the mask protective layer. The exact reason for this phenomenon is not known to us, but it could be related to factors such as resonance in the timer chip used, electromagnetic pulses, or electronic charge coupling, among others. One of these factors may be causing the separation between the copper trace and the protective layer.

Although we haven’t fully understood the exact cause of this situation, we have found that simply changing the continuous sensor power supply to an intermittent or controlled power supply effectively resolves this issue.

How Can You Achieve This?

We all know that the sensor’s power input is originally connected to the power source of the MCU (Arduino board, ESP32 board).

Now, all you need to do is connect the sensor’s power input to any digital pin on the MCU. You can control the sensor’s power on and off using the digitalWrite() function.

Due to the very low power consumption of this type of soil moisture sensor, using a digital pin to provide power is sufficient, especially for the Plantmate capacitive soil moisture sensor 3.3V, which is designed with carefully selected components and even lower power consumption.

One important thing to note is that the output voltage of the digital pin on our MCU should match the voltage requirements of our moisture sensor.

For example, digital pins on an Arduino board typically provide voltage outputs of either 5V or 3.3V, so you should choose an Arduino board that matches the voltage requirement of your sensor.

In this example, we are using the Plantmate capacitive soil moisture sensor, which operates with a power supply voltage of 3.3V. Therefore, we have selected the Arduino Mini Pro 3.3V 8MHz for further explanation.

#define SENSOR_PIN A0     // Sensor signal pin connected to Arduino pin A0
#define PWR_PIN 10        // Sensor VCC pin connected to Arduino pin 10
int loopCounter= 0;       // Initial the loop counter 
int sensorValue;          // Store the sensor data

// This function turns the sensor power on, reads the sensor then turns the sensor power off.
// This function will be called once every 10,000 loops
void  readSensor(){
// Your function code goes here
  digitalWrite(PWR_PIN, HIGH);       // Turn sensor power on
  delay(300);   // Allow circuit time to settle, 300 is the minimum number
  sensorValue = analogRead(SENSOR_PIN); // Read analog value from sensor
  delay(100);                        // Small delay probably not needed
  digitalWrite(PWR_PIN, LOW);        // Turn sensor power off

//  Initialization:
void setup()
  pinMode(PWR_PIN, OUTPUT);    // Set pin used to power sensor as output
  digitalWrite(PWR_PIN, LOW);  // Set to LOW to turn the sensor off at the start
//  Main:
void loop()
// Your main loop code goes here
// Increment the loop counter
// Check if it’s time to call the function(every 10,000 loops)
If (loopCounter >=10000){
readSensor(); // Call the readSensor function
loopCounter=0; //Reset the counter
//Continue with the rest of your loop code

The time it takes for an Arduino Mini Pro to complete a loop 10,000 times depends on the complexity of the code inside the loop and the clock speed of the microcontroller.

The Arduino Mini Pro is available in different versions with different microcontrollers, and the clock speed can vary. The most common clock speed for an Arduino Mini Pro is 8 MHz or 16 MHz. The clock speed affects how quickly the microcontroller can execute instructions.

In general, if your loop contains simple instructions and does not involve long delays, it can execute quite quickly. For example, if each iteration of the loop takes 1 millisecond to execute, then looping 10,000 times would take approximately 10 seconds.

However, if your code inside the loop involves more complex calculations or includes long delays, the time to complete the loop will be longer. You can estimate the time it takes for the loop to complete by measuring the execution time of your code using the millis() function. Here’s an example:

unsigned long startTime = millis();

for (int i = 0; i < 10000; i++) {
  // Your code to be executed 10000 times goes here

unsigned long endTime = millis();
unsigned long elapsedTime = endTime - startTime;
Serial.println("Time taken to complete 1000 loops: " + String(elapsedTime) + " milliseconds");

This code measures the time it takes to complete 10,000 loops and prints it to the serial monitor. It will give you a more accurate measurement of the execution time for your specific code on your Arduino Mini Pro.

If we are using an ESP32 board, we can utilize the Ticker library to implement scheduled power on/off and reading operations for the sensor at specified intervals.

The ESP32 is a 3.3V device, which means that all of its input and output pins are designed to operate with a maximum voltage of 3.3 volts.

#include <Ticker.h>               //

Ticker check_soil_sensors_timer;  //  timer to run the readSensor function

check_soil_sensors_timer.attach(5, readSensor);       // Run the readSensor function every 5 seconds


Leave a Reply

Your email address will not be published. Required fields are marked *