Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Solar-Powered Smart Bin with Arduino and Ultrasonic Sensor

View and Edit Project In Cirkit DesignerImage of Solar-Powered Smart Bin with Arduino and Ultrasonic Sensor

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

  1. Solar Panel

    • Description: Converts sunlight into electrical energy.
    • Pins: GND, VCC
  2. Charge Controller

    • Description: Manages the charging of the battery from the solar panel.
    • Pins: GND, BAT, Vin
  3. 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
  4. HC-SR04 Ultrasonic Sensor

    • Description: Measures distance using ultrasonic waves.
    • Pins: VCC, TRIG, ECHO, GND
  5. 2000mAh Battery

    • Description: Stores electrical energy for powering the circuit.
    • Pins: VCC, GND
  6. LM7805

    • Description: Voltage regulator that provides a stable 5V output.
    • Pins: IN PIN, OUT PIN, GND

Wiring Details

Solar Panel

Charge Controller

Arduino UNO

HC-SR04 Ultrasonic Sensor

2000mAh Battery

LM7805

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.