Plant Health Bar
Give your plant a health bar that updates in real time! Just be careful not to trigger the boss fight. Component List:- 1 x Arduino Uno R3
- 1 x Capacitive soil moisture sensor
- 1 x 1602 LCD
- Jumper wires (male-to-male)
- Jumper wires (male-to-female)
- Connect the SDA pin on the I2C module to the A4 pin on the Arduino.
- Connect the SCL pin on the I2C module to the A5 pin on the Arduino.
- Connect VCC on the I2C module to the 5V pin on the Arduino (or breadboard).
- Connect GND on the I2C module to the GND pin on the Arduino (or breadboard).
- Connect the GND (ground) pin on the Arduino Uno to the GND pin on the soil moisture sensor using a jumper wire.
- Connect the VCC (power) pin on the Arduino Uno to the VCC pin on the soil moisture sensor using a jumper wire.
- Connect the AO (analog output) pin on the soil moisture sensor to the A0 (analog input) pin on the Arduino Uno using a jumper wire.
- وصل دبوس SDA من وحدة I2C إلى الدبوس A4 على الأردوينو.
- وصل دبوس SCL من وحدة I2C إلى الدبوس A5 على الأردوينو.
- وصل دبوس VCC من وحدة I2C إلى دبوس 5V على الأردوينو (أو لوحة التجارب).
- وصل دبوس GND من وحدة I2C إلى دبوس GND على الأردوينو (أو لوحة التجارب).
- وصل دبوس GND (الأرض) من الأردوينو Uno إلى دبوس GND على حساس رطوبة التربة باستخدام سلك توصيل.
- وصل دبوس VCC (الطاقة) من الأردوينو Uno إلى دبوس VCC على حساس رطوبة التربة باستخدام سلك توصيل.
- وصل دبوس AO (الإخراج التناظري) من حساس رطوبة التربة إلى دبوس A0 (الإدخال التناظري) على الأردوينو Uno باستخدام سلك توصيل.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Define the analog pin to which the sensor is connected
const int moistureSensorPin = A0;
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 columns and 2 rows
// Make custom characters:
byte Heart[] = {
B00000,
B01010,
B11111,
B11111,
B01110,
B00100,
B00000,
B00000
};
byte hp[] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.createChar(0, Heart);
lcd.createChar(1, hp);
}
void loop() {
// Read the raw analog value from the sensor
int moistureValue = analogRead(moistureSensorPin);
// Map the raw value to a range (0-100 or any other range you prefer)
int moisturePercentage = map(moistureValue, 500, 250, 0, 15); //you will need to tune in the numbers based on your scenario
// Print the moisture percentage to the serial monitor
Serial.print("Moisture Percentage: ");
Serial.print(moisturePercentage);
Serial.println("%");
lcd.clear(); // Clear the LCD display
lcd.setCursor(0, 0);
lcd.print("House Plant");
lcd.setCursor(0, 1);
lcd.write((byte)0);
for(int x=0;x<moisturePercentage;x++)
lcd.write((byte)1); // Display temperature with one decimal place
// Delay for a short period before reading again (adjust as needed)
delay(5000);
}
Get started with BitWare's Arduino Starter Kit
https://www.bitware.store/product/arduino-uno-r3-compatible-with-arduino-ide/[bitware_arabic_portfolio_content]
Project Details | |
| Level: | Beginner (1/5) |
| Category: | Monitoring System |
| Platform: | Arduino |
| Creator: | BitWare Store |