Project tutorial
Keep Your Plant Under Control

Keep Your Plant Under Control © GPL3+

Use an addressable LED strip to keep your plant under control.

  • 1,327 views
  • 0 comments
  • 4 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

About this project

Hi, I'm a young software developer that works for a big automotive company. It's been three years since I've started using Arduino and developing IoT projects, but never published them. So actually in my workplace, there are several different plants and it's very difficult to understand when to watering the plant.

As a result, I've decided to use the soil moisture sensor combined with a WS2812 LED strip (as a visible indicator) to know when the plant needs water or not. If the percentage of humidity is under 20%, 20% of the LED strip's length will be colored red. If it's between 21% and 50%, 21% and 50% of the LED strip will turn yellow. If it's over 51%, 51% of the LED strip is colored green.

Code

SOIL METER C/C++
#include <FastLED.h>

#define LED_PIN     6
#define NUM_LEDS    15
#define BRIGHTNESS  30
#define LED_TYPE    WS2812
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define UPDATES_PER_SECOND 100

int analogPin = A0;
int moisture;
int percentage;
//map the max a min values
int map_low = 1023;
int map_high = 350;

void setup() {
  Serial.begin(9600);
  delay( 3000 ); // power-up safety delay
  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(  BRIGHTNESS );
  //reset the led strip color
  for (int i = 0; i < NUM_LEDS; i++) {
    leds[i] =  CRGB::Black;
    FastLED.show();
  }
}

void setColor(int perc) {
  //evaluate the number of leds to turn on (at least 1 for 0%)
  int num = ((NUM_LEDS * perc) / 100) + 1;
  //turn off the leds that are not needed, so the right percentage
  //of the leds will be on
  for (int i = NUM_LEDS; i > num - 1; i--) {
    leds[i] =  CRGB::Black;
    FastLED.show();
  }
  //here's the green 
  if (perc >= 51) {
    for (int i = 0; i < num; i++) {
      leds[i] =  CRGB::Green;
      FastLED.show();
    }
  } else if (perc >= 21 && perc <= 50) {//the yellow
    for (int i = 0; i < num; i++) {
      leds[i] =  CRGB::Yellow;
      FastLED.show();
    }
  } else if (perc <= 20) {
    for (int i = 0; i < num; i++) {//the red
      leds[i] =  CRGB::Red;
      FastLED.show();
    }
  }

}

void loop() {
  //we read raw value to evaluate the percentage
  moisture = analogRead(analogPin);
  Serial.print("Raw: ");
  Serial.print(moisture);

  percentage = map(moisture, map_low, map_high, 0, 100);

  Serial.print(" | Percentage: ");
  Serial.print(percentage);

  Serial.println("%");
  //then we set the color based on the percentage
  setColor(percentage);
  delay(1000);
}

Schematics

SOIL_METER
soil_meter_F2mCRoX75I.fzz

Comments

Similar projects you might like

Control an LED with the Remote Control

Project showcase by Nicholas_N

  • 3,806 views
  • 2 comments
  • 11 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,595 views
  • 5 comments
  • 17 respects

The Quantified Cactus: An Easy Plant Soil Moisture Sensor

Project tutorial by Jen Looper

  • 6,849 views
  • 2 comments
  • 25 respects

Plant watering alarm system with arduino

Project tutorial by Giannis Arvanitakis

  • 3,398 views
  • 1 comment
  • 5 respects

Control Your Computer With A Remote Control

Project tutorial by Arduino_Scuola

  • 5,942 views
  • 1 comment
  • 8 respects
Add projectSign up / Login