Multiple soil moisture sensor arduino

In this post I will share a sketch which can control many soil moisture sensors at once. As you can see in picture above, I have used 2 soil moisture sensors to turn on and off 2 leds. I would have used more sensors if I had but that's all I had so I have used them all. Don't worry you can add more sensors if your Arduino board has too many pins control the thing you want.

The sketch:
int led1 = 4;
int led2 = 5;

void setup() {
// initialize serial communication at 9600 bits per second:
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);

void loop() {
// read the input on analog pin 1:
int sensorValue1 = analogRead(A1);

if (sensorValue1 >=600 && sensorValue1 <=800){
    digitalWrite(led1, HIGH);
  else {
    digitalWrite(led1, LOW);
int sensorValue2 = analogRead(A2);

if (sensorValue2 >=600 && sensorValue2 <=800){
    digitalWrite(led2, HIGH);
  else {
    digitalWrite(led2, LOW);

Places to edit:
int led1 = 4; // you can change it to what ever digital pin you like.
int led2 = 5; // you can change it to what ever digital pin you like.

int sensorValue1 = analogRead(A1); // I have  made A1 (analog pin number 1) for the first soil moisture sensor and A2 (analog pin number 2) for second sensor.

if (sensorValue1 >=600 && sensorValue1 <=800){ // Here the >=600 means if the value is over 600 and under 800  <=800 then it will turn on the first LED, and if the value is under 600 and over 800 the the LED will be turned off. You can change the number as you wish, but keep in mind that less value numbers means the soil is more wet and more value numbers means the soil is less wet.

What do you need:
  • 2x LEDs. What ever color you like.
  • 2x Soil Moisture Sensors.
  • 2x 10k ohm resistor. You can leave it if you want, I've used it just to make the leds dimmer.
  • One Arduino board. In this case I've used Arduino nano.
  • Few jumper wires
That's all for this post I hope this will help you. :)

multiple soil moisture sensor arduino. arduino moisture sensor code. soil moisture sensor arduino code. soil moisture sensor arduino. arduino soil moisture sensor code. arduino soil moisture sensor. soil sensors arduino. moisture sensor arduino code. arduino multiple sensors. moisture sensor arduino. soil moisture sensor arduino circuit diagram. ground humidity sensor arduino. arduino moisture sensor. soil sensor arduino. how to connect soil moisture sensor to arduino. soil humidity sensor arduino. multiple sensors arduino uno. how to use multiple sensors with arduino. connecting multiple sensors to arduino uno. soil moisture meter arduino. arduino code for multiple sensors. moisture meter arduino. arduino moisture sensor project. arduino read multiple sensors. connect soil moisture sensor to arduino. arduino soil. moisture sensor for arduino. moisture sensors. soil moisture sensor pin diagram. soil sensor arduino code. arduino code for moisture sensor. arduino with multiple sensors. connect multiple sensors to arduino. multiple sensors arduino. soil moisture sensor arduino program. arduino uno soil moisture sensor. multiple arduino soil moisture sensor arduino project soil moisture arduino. arduino wet sensor. soil hygrometer arduino. interfacing soil moisture sensor with arduino. arduino ground humidity sensor.


  1. how to connect 4 sensors and 1 FCB how to program that sir

  2. Great project, I added six zones to the one I built and it works well.

  3. Good day sir, how to program 5-8 soil moisture sensor in one Arduino atmega 2560 board?
    I am using an Arduino mega shield so that I can use multiple sensors but I don't no yet how to program it.

    1. I would've helped you, but since no one helps me so I can't bothered to waste my time for nothing in return.


Newly posted:
Reason why rich getting richer and poor getting poorer