This document provides a detailed overview of an Arduino-based combined piezoelectric and solar PV energy harvesting system. The system includes a rain sensor, motor drive module, solar charger controller, switch, and 12V battery storage. The Arduino microcontroller reads the rain sensor and controls the motor driver accordingly. It also monitors the piezo sensors and solar panel for energy harvesting.
Arduino UNO
YL-83 Rain Sensor - Detection Board
L298N DC Motor Driver
Motor amarillo motorreductor hobby
Solar Panel
Solar Charge Controller
Piezo Sensor
12V Battery (mini)
Rocker Switch (SPST)
/*
* Arduino Based Combined Piezoelectric and Solar PV Energy Harvesting System
* with Rain Sensor, Motor Drive Module, Solar Charger Controller, Switch, and
* 12V Battery Storage
*
* This code reads the rain sensor and controls the motor driver accordingly.
* It also monitors the piezo sensors and solar panel for energy harvesting.
*/
// Pin definitions
const int rainSensorPin = 7; // Rain sensor connected to D7
const int motorEnablePin = 9; // Motor driver enable pin connected to D9
const int motorControlPin1 = 2; // Motor control pin 1 connected to D2
const int motorControlPin2 = 3; // Motor control pin 2 connected to D3
void setup() {
// Initialize motor control pins as outputs
pinMode(motorControlPin1, OUTPUT);
pinMode(motorControlPin2, OUTPUT);
// Initialize rain sensor pin as input
pinMode(rainSensorPin, INPUT);
// Initialize motor enable pin as output
pinMode(motorEnablePin, OUTPUT);
// Start with motors disabled
digitalWrite(motorEnablePin, LOW);
}
void loop() {
// Read the rain sensor value
int rainSensorValue = digitalRead(rainSensorPin);
if (rainSensorValue == HIGH) {
// If rain is detected, stop the motors
stopMotors();
} else {
// If no rain, run the motors
runMotors();
}
delay(1000); // Wait for 1 second before next check
}
void stopMotors() {
digitalWrite(motorEnablePin, LOW);
digitalWrite(motorControlPin1, LOW);
digitalWrite(motorControlPin2, LOW);
}
void runMotors() {
digitalWrite(motorEnablePin, HIGH);
digitalWrite(motorControlPin1, HIGH);
digitalWrite(motorControlPin2, LOW);
}
/*
* Arduino Based Combined Piezoelectric and Solar PV Energy Harvesting System
* with Rain Sensor, Motor Drive Module, Switch, Solar Charger Controller, and
* 12V Battery Storage
*
* This code reads the rain sensor and controls the motor driver accordingly.
* It also monitors the piezo sensors and solar panel for energy harvesting.
*/
// Pin definitions
const int rainSensorPin = 7; // Rain sensor connected to D7
const int motorEnablePin = 9; // Motor driver enable pin connected to D9
const int motorControlPin1 = 2; // Motor control pin 1 connected to D2
const int motorControlPin2 = 3; // Motor control pin 2 connected to D3
void setup() {
// Initialize motor control pins as outputs
pinMode(motorControlPin1, OUTPUT);
pinMode(motorControlPin2, OUTPUT);
// Initialize rain sensor pin as input
pinMode(rainSensorPin, INPUT);
// Initialize motor enable pin as output
pinMode(motorEnablePin, OUTPUT);
// Start with motors disabled
digitalWrite(motorEnablePin, LOW);
}
void loop() {
// Read the rain sensor value
int rainSensorValue = digitalRead(rainSensorPin);
if (rainSensorValue == HIGH) {
// If rain is detected, stop the motors
stopMotors();
} else {
// If no rain, run the motors
runMotors();
}
delay(1000); // Wait for 1 second before next check
}
void stopMotors() {
digitalWrite(motorEnablePin, LOW);
digitalWrite(motorControlPin1, LOW);
digitalWrite(motorControlPin2, LOW);
}
void runMotors() {
digitalWrite(motorEnablePin, HIGH);
digitalWrite(motorControlPin