Circuit Documentation
Summary
This circuit is a solar-powered smart bin system that uses an Arduino UNO microcontroller and an HC-SR04 Ultrasonic Sensor to measure the fill level of a bin. The system is powered by a solar panel and a 2000mAh battery, regulated by a charge controller and an LM7805 voltage regulator.
Component List
Solar Panel
- Description: Converts sunlight into electrical energy.
- Pins: GND, VCC
Charge Controller
- Description: Manages the charging of the battery from the solar panel.
- Pins: GND, BAT, Vin
Arduino UNO
- Description: Microcontroller used to process data from the ultrasonic sensor.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
HC-SR04 Ultrasonic Sensor
- Description: Measures distance using ultrasonic waves.
- Pins: VCC, TRIG, ECHO, GND
2000mAh Battery
- Description: Stores electrical energy for powering the circuit.
- Pins: VCC, GND
LM7805
- Description: Voltage regulator that provides a stable 5V output.
- Pins: IN PIN, OUT PIN, GND
Wiring Details
Solar Panel
GND connected to:
- Charge Controller GND
- Arduino UNO GND
- LM7805 GND
VCC connected to:
- Charge Controller Vin
- LM7805 IN PIN
Charge Controller
GND connected to:
- Solar Panel GND
- 2000mAh Battery GND
BAT connected to:
- 2000mAh Battery VCC
Vin connected to:
- Solar Panel VCC
Arduino UNO
GND connected to:
- Solar Panel GND
- HC-SR04 Ultrasonic Sensor GND
5V connected to:
- HC-SR04 Ultrasonic Sensor VCC
- LM7805 OUT PIN
D9 connected to:
- HC-SR04 Ultrasonic Sensor TRIG
D10 connected to:
- HC-SR04 Ultrasonic Sensor ECHO
HC-SR04 Ultrasonic Sensor
VCC connected to:
- Arduino UNO 5V
- LM7805 OUT PIN
GND connected to:
- Arduino UNO GND
TRIG connected to:
- Arduino UNO D9
ECHO connected to:
- Arduino UNO D10
2000mAh Battery
VCC connected to:
- Charge Controller BAT
GND connected to:
- Charge Controller GND
LM7805
IN PIN connected to:
- Solar Panel VCC
OUT PIN connected to:
- Arduino UNO 5V
- HC-SR04 Ultrasonic Sensor VCC
GND connected to:
- Solar Panel GND
Code Documentation
/*
* Smartbin Arduino Based powered by solar
* This code interfaces with an HC-SR04 Ultrasonic Sensor to measure distance.
* The sensor is connected to the Arduino UNO. The distance is measured and
* can be used to determine the fill level of a bin.
*/
#define TRIG_PIN 9
#define ECHO_PIN 10
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Set the trigger pin as an output
pinMode(TRIG_PIN, OUTPUT);
// Set the echo pin as an input
pinMode(ECHO_PIN, INPUT);
}
void loop() {
// Clear the trigger pin
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
// Set the trigger pin high for 10 microseconds
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// Read the echo pin
long duration = pulseIn(ECHO_PIN, HIGH);
// Calculate the distance
float distance = duration * 0.034 / 2;
// Print the distance to the serial monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Wait for a short period before the next measurement
delay(1000);
}
This code initializes the HC-SR04 Ultrasonic Sensor and measures the distance by sending a pulse from the TRIG pin and reading the response from the ECHO pin. The measured distance is then printed to the serial monitor.
