Рет қаралды 47
Welcome to our latest DIY project! In this video, we'll guide you step-by-step through building an Arduino-based Sunlight Monitor that automatically sends email notifications based on sunlight exposure. Perfect for monitoring your terrarium, greenhouse, or any setup where light levels are crucial.
🔧 What You'll Learn:
Setting up the BH1750 light sensor with Arduino
Connecting to Wi-Fi using the WiFiNINA module
Sending automated email alerts using the ESP Mail Client library
Programming logic to track and notify sunlight exposure durations
🛠️ Components You'll Need:
Arduino Board (e.g., Arduino MKR WiFi 1010 or similar with WiFi capabilities)
BH1750 Light Sensor for measuring light intensity
ESP8266/ESP32 Module (if not integrated into your Arduino board)
Connecting Wires
Breadboard (optional, for prototyping)
Resistors (if required by your setup)
Power Supply (USB or battery, depending on your project)
🔌 Circuit Connections:
BH1750 Light Sensor Connections:
VCC → 5V on Arduino
GND → GND on Arduino
SCL → A5 (SCL) on Arduino
SDA → A4 (SDA) on Arduino
WiFi Module Connections (if using a separate ESP module):
VCC → 3.3V on Arduino
GND → GND on Arduino
Ensure all components share a common ground.
Use pull-up resistors for I2C lines if necessary.
📂 Code Overview:
Libraries Used:
Wire.h for I2C communication
BH1750.h for interfacing with the light sensor
WiFiNINA.h for Wi-Fi connectivity
ESP_Mail_Client.h for sending emails
Functionality:
Connects to your Wi-Fi network.
Reads light levels from the BH1750 sensor.
Monitors sunlight exposure based on a predefined threshold.
Sends email notifications when sunlight conditions change or when a total sunlight duration is met.
🔑 Key Features:
Real-Time Monitoring: Continuously track light intensity.
Automated Alerts: Receive timely email notifications without manual checks.
Customizable Thresholds: Adjust light level and duration settings to fit your needs.
📧 Email Setup:
Uses Gmail's SMTP server for sending emails.
Ensure you enable App Passwords in your Gmail account for secure access.
Update the email credentials in the code with your own information.
📌 Important Notes:
Security: Never share your email passwords publicly. Use environment variables or secure storage methods for sensitive information.
Power Management: For long-term projects, consider using a stable power source to prevent interruptions.
Error Handling: The code includes basic error handling for sensor initialization and email sending failures.