A Practical Guide To Resilience – Week 06

Plants need various conditions such as soil, humidity, and light etc to grow. To know a more suitable environment for my plant, I have added light dependent sensor(LDR) to my moisture sensor this week. Before that, I tested my LDR according to the youtube video tutorial that Benedetta linked.

LED is turned off when LDR is covered by hand. If you want it to turn on when you cover the LDR with your hands, you can change the value on (255,0).

* Added to LDR sensor with moisture sensor

I added to my light sensor with moisture sensor in arduino Nano 33 IoT board. I connected the moisture sensor with analog pin A0 and light sensor with analog pin A2.

with no moisture/ with light

Without moisture, the value of the moisture is 1023, consistently and With fluorescent light at night, the value of the light is about 320.

with moisture/ with no light

With moisture, (I watered on the plant.), the value of moisture is getting low about 470 and With no light( I covered the light sensor with my hand), I can see the value of it is getting low about 25.

*update

-adding sound!

I added some tones with my moisture sensor through my speaker. With moisture, The music is played to let you know when the plant is lacked of water.

Please turn up the volume. the sound is small.

#include "pitches.h"
 
// notes in the melody:
int melody[] = {
NOTE_C4, NOTE_G3,NOTE_G3, NOTE_GS3, NOTE_G3,0, NOTE_B3, NOTE_C4};
 
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {4,8,8,4,4,4,4,4 };


const int MoisturePin = A0;
const int LightPin = A2;

void setup() {
  Serial.begin(9600);

}
void loop() {
  int moistureValue;
  int lightValue;

  moistureValue = analogRead(MoisturePin);

  lightValue = analogRead(LightPin);

  //moisture of the soil
  Serial.print("M:");
  Serial.print(moistureValue);
  Serial.print(", ");
  //light intensity
  Serial.print("L:");
  Serial.print(lightValue);
  Serial.print(", ");
  delay(300);

  if (moistureValue < 500) {

    Serial.println("Soil is humid");
    noTone(11);
  }
  else {
    Serial.println("Soil is Dry");
    for (int thisNote = 0; thisNote < 8; thisNote++) {
    // to calculate the note duration, take one second
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000/noteDurations[thisNote];
    tone(11, melody[thisNote],noteDuration);
 
    //pause for the note's duration plus 30 ms:
    delay(noteDuration +30);
   // tone(11,  , 200);
    //delay(200);
  }
  delay(300);
}
}
// also pitches.h included

Instead of plants, I used a plastic bottle filled with water. with moisture, the music is played and the music stops with no moisture.

  • problem: I knew my sound is too small through the speaker. I used Tip120 to speak up the sound but it seemed not working.