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

Smart Solar-Powered Lighting System with Motion Detection and Bluetooth Connectivity

View and Edit Project In Cirkit DesignerImage of Smart Solar-Powered Lighting System with Motion Detection and Bluetooth Connectivity

Smart Solar Light Controller Circuit Documentation

Summary

The Smart Solar Light Controller is a solar-powered lighting system designed to operate autonomously using various sensors. It is capable of monitoring solar panel voltage, battery voltage, load current, and light intensity, and it can detect motion to control floodlights. The system is designed to turn on the floodlights when motion is detected during nighttime conditions. Sensor data is collected and can be transmitted to a connected Bluetooth device, such as a smartphone.

Component List

Wiring Details

Solar Panel

Charge Controller

12v Battery

Power Inverter

PIR/Motion Sensor

Flood Lights 12v

Arduino UNO

5v Relay

Photocell (LDR)

ZMPT101B

HC-05 Bluetooth Module

ACS712 Current Sensor

Documented Code

/*
 * Smart Solar Light Controller
 * This Arduino sketch controls a solar-powered lighting system using various sensors.
 * It monitors solar panel voltage, battery voltage, load current, light intensity,
 * and motion detection. The system turns on floodlights when motion is detected at
 * night and sends all sensor data to a connected phone via Bluetooth.
 */

// Pin definitions
const int solarVoltagePin = A2;
const int batteryVoltagePin = A3;
const int currentSensorPin = A4;
const int ldrPin = A1;
const int pirPin = A0;
const int relayPin = 7;
const int bluetoothTxPin = 2;
const int bluetoothRxPin = 3;

// Variables
float solarVoltage = 0.0;
float batteryVoltage = 0.0;
float loadCurrent = 0.0;
float powerDraw = 0.0;
int ldrValue = 0;
int pirValue = 0;
bool relayState = false;
unsigned long motionEndTime = 0;

void setup() {
  Serial.begin(9600);
  pinMode(relayPin, OUTPUT);
  pinMode(pirPin, INPUT);
  digitalWrite(relayPin, LOW);
}

void loop() {
  // Read sensor values
  solarVoltage = analogRead(solarVoltagePin) * (5.0 / 1023.0);
  batteryVoltage = analogRead(batteryVoltagePin) * (5.0 / 1023.0);
  loadCurrent = analogRead(currentSensorPin) * (5.0 / 1023.0);
  ldrValue = analogRead(ldrPin);
  pirValue = digitalRead(pirPin);

  // Calculate power draw
  powerDraw = batteryVoltage * loadCurrent;

  // Check if it's night time
  if (ldrValue < 500) { // Adjust threshold as needed
    if (pirValue == HIGH) {
      digitalWrite(relayPin, HIGH);
      relayState = true;
      motionEndTime = millis() + 3000; // 3 seconds after motion stops
    }
  }

  // Turn off relay if motion has stopped
  if (millis() > motionEndTime) {
    digitalWrite(relayPin, LOW);
    relayState = false;
  }

  // Send data to Serial Monitor and Bluetooth
  Serial.print("Solar Voltage: ");
  Serial.println(solarVoltage);
  Serial.print("Battery Voltage: ");
  Serial.println(batteryVoltage);
  Serial.print("Load Current: ");
  Serial.println(loadCurrent);
  Serial.print("Power Draw: ");
  Serial.println(powerDraw);
  Serial.print("LDR Value: ");
  Serial.println(ldrValue);
  Serial.print("PIR Value: ");
  Serial.println(pirValue);
  Serial.print("Relay State: ");
  Serial.println(relayState);
  Serial.println();

  // Send data to Bluetooth
  Serial.print("BT:Solar Voltage: ");
  Serial.println(solarVoltage);
  Serial.print("BT:Battery Voltage: ");
  Serial.println(batteryVoltage);
  Serial.print("BT:Load Current: ");
  Serial.println(loadCurrent);
  Serial.print("BT:Power Draw: ");
  Serial.println(powerDraw);
  Serial.print("BT:LDR Value: ");
  Serial.println(ldrValue);
  Serial.print("BT:PIR Value: ");
  Serial.println(pirValue);
  Serial.print("BT:Relay State: ");
  Serial.println(relayState);
  Serial.println();

  delay(1000); // Adjust delay as needed
}

This code is designed to run on an Arduino UNO and controls the Smart Solar Light Controller system. It reads inputs from the various sensors, processes the data, controls the relay based on the sensor inputs, and sends sensor data to a connected Bluetooth device.