Introduction: Plant Emoji Soil Moisture Detector
My dear grandmother loves plants but she often forgets to water them. I designed and created this lovely device that provides a colorful emoticon display to alert owners when to water the plants. The moisture meter displays a smiling face if the plant has enough water, and it frowns/cries when the soil is arid.
Step 1: Required Materials
Arduino Uno Microcontroller Board
8X8 LED Matrix Array
Soil Humidity Sensor
Electronic Expansion Board
Battery
Alarm Buzzer (optional)
Step 2: Soldering the Components
Solder the LED matrix array, soil humidity sensor, and the alarm buzzer to the expansion board. For the LED matrix array, I connected CLK to pin #4, CS to pin #3, and DIn to pin #2. For the soil humidity sensor, the AO is connected to A5 on the Arduino unit. The alarm buzzer is connected to pin #5. If you happen to solder the inputs/outputs to different pins, remember to reroute to the appropriate pins in the Arduino code. Replace “Stick the battery to the back of Arduino” with Attach the battery power supply to the back of the Arduino unit.
Step 3: Battery
Attach the battery power supply to the back of the Arduino unit.
Step 4: Connect the Arduino Controller to the Rest of the Device.
Attach the Arduino unit to the expansion board to complete the assembly.
Step 5: Arduino Source Code
The last step is to load the following programming code onto the Arduino controller. Remember to modify the pin assignments if your selections differ from the instructions provided.
//Put the following code into Arduino
long soilhumid;
long humid;
int dataIn = 2;
int load = 3;
int clock = 4;
byte max7219_reg_noop = 0x00;
byte max7219_reg_digit0 = 0x01;
byte max7219_reg_digit1 = 0x02;
byte max7219_reg_digit2 = 0x03;
byte max7219_reg_digit3 = 0x04;
byte max7219_reg_digit4 = 0x05;
byte max7219_reg_digit5 = 0x06;
byte max7219_reg_digit6 = 0x07;
byte max7219_reg_digit7 = 0x08;
byte max7219_reg_decodeMode = 0x09;
byte max7219_reg_intensity = 0x0a;
byte max7219_reg_scanLimit = 0x0b;
byte max7219_reg_shutdown = 0x0c;
byte max7219_reg_displayTest = 0x0f;
int e = 0;
void putByte(byte data) {
byte i = 8;
byte mask;
while(i > 0) {
mask = 0x01 << (i - 1); // get bitmask
digitalWrite( clock, LOW); // tick
if (data & mask){ // choose bit
digitalWrite(dataIn, HIGH);// send 1
}else{
digitalWrite(dataIn, LOW); // send 0
}
digitalWrite(clock, HIGH); // tock
--i; // move to lesser bit
}
}
void maxAll(byte reg, byte col) {
digitalWrite(load, LOW); // begin
putByte(reg); // specify register
putByte(col);//((data & 0x01) * 256) + data >> 1); // put data
digitalWrite(load, LOW);
digitalWrite(load,HIGH);
}
void maxSingle(byte reg, byte col) {
digitalWrite(load, LOW); // begin
putByte(reg); // specify register
putByte(col);//((data & 0x01) * 256) + data >> 1); // put data
digitalWrite(load, LOW); // and load da stuff
digitalWrite(load,HIGH);
}
void setup()
{
Serial.begin(9600);
pinMode(dataIn, OUTPUT);
pinMode(clock, OUTPUT);
pinMode(load, OUTPUT);
maxAll(max7219_reg_scanLimit, 0x07);
maxAll(max7219_reg_decodeMode, 0x00);
maxAll(max7219_reg_shutdown, 0x01);
maxAll(max7219_reg_displayTest, 0x00);
for (e=1; e<=8; e++) { maxAll(e,0);}
maxAll(max7219_reg_intensity, 0x0f & 0x0f);
pinMode(0, OUTPUT);
soilhumid = 0;
humid = 0;
}
void loop()
{
// detect soil humidity
soilhumid = analogRead(A0);
Serial.println(soilhumid);
// lack water
if (soilhumid < humid) {
// sad face
maxSingle(1,0);maxSingle(2,102);maxSingle(3,102);maxSingle(4,0);maxSingle(5,60);maxSingle(6,66);maxSingle(7,66);maxSingle(8,0);// buzzer on
digitalWrite(0,HIGH);
delay(3000);
// buzzer off
digitalWrite(0,LOW);
} else {
// happy face
maxSingle(1,0);maxSingle(2,102);maxSingle(3,102);maxSingle(4,0);maxSingle(5,126);maxSingle(6,66);maxSingle(7,36);maxSingle(8,24);// buzzer off
digitalWrite(0,LOW);
}
}

Participated in the
Arduino Contest 2016

Participated in the
Indoor Gardening Contest 2016
11 Comments
6 years ago
Hi, what was the expansion board that was used? Or does any expansion board work
6 years ago
bos how many input and output this program..?
6 years ago
Hello I'm having issue with the soil moisture. My sensor values are 974 out in the air and around 380-400 in the water instead of 0 and 1024. Someone knows this issue?
Reply 6 years ago
The sensor is probably deregulated. Look for a potentiometer on the module board, you can make some adjustments with it.
6 years ago
can you help me?
6 years ago
Looks interesting. would appreciate if you can share more details on the wiring on the expansion board. the attached picture is not very clear.
6 years ago
i am having zero luck compiling this in the IDE any suggestions?
6 years ago
The major problem of your project is the humidity sensor. I bought two just like yours and the first turn rusty very fast when exposed to moist soil.
One solution can be only stick it in the soil to get readings and then clean it.. well!
The other can be a mechanism with a servo and some sort of brush to clean the sensor on the way up.
Reply 6 years ago
You could try sending a very small current through the stick to help reduce/prevent rust. It's very similar to how rust proof systems work on vehicles.
6 years ago
I like your sense of humor!
6 years ago
Clever way to make a moisture sensor. You might also think about making a different expression for when the plant might be over watered.