সোলার চার্জ কন্ট্রোলারSolar Charge Controller with Arduino and Relay
প্যানেল TP4056 দিয়ে চার্জ দেয় 2S BMS এর পেছনে থাকা দুই সেলের প্যাকে, আর relay লোড সুইচ করে। 3.0 V/cell এর নিচে লোড কাট, 3.3 V এর ওপরে ফিরে আসে, রোদ না থাকলে লোড অফ। সত্যি কথাটাও দেখায়: 6 V প্যানেল 1S চার্জার দিয়ে 7.4 V প্যাকে চার্জ ঢোকাতে পারে না।
A panel charges through a TP4056 into a two-cell 18650 pack behind a 2S BMS, and a relay switches the load output. The sketch cuts the load below 3.0 V a cell, reconnects above 3.3 V, and refuses the load while the panel is dark. It also shows an honest catch: a 6 V panel through a 1S charger cannot push into a 7.4 V pack, so the controller says FULL while the sun is up.
সার্কিট ডায়াগ্রাম · Circuit diagram
যা যা লাগবে · Parts you need
- 1 × Arduino Uno R3 Arduino Uno
- 1 × Solar panel (6 V) সোলার প্যানেল (6 V)
- 1 × Li-ion charger (TP4056) লিথিয়াম চার্জার (TP4056)
- 1 × Voltage sensor (0–25 V) ভোল্টেজ সেন্সর (0–25 V)
- 2 × Resistor 10000Ω Resistor
- 1 × Battery protection (2S 20A BMS) ব্যাটারি প্রোটেকশন (2S 20A BMS)
- 2 × 18650 Li-ion cell (3.7 V) 18650 লিথিয়াম ব্যাটারি (3.7 V)
- 1 × Relay module (5V, 1 channel) রিলে মডিউল (5V, ১ চ্যানেল)
- 1 × LCD 16x2 with I2C LCD ১৬x২ (I2C)
- 23 × Jumper wires জাম্পার তার
তার লাগানো · Wiring
| Solar panel (6 V) + | → | Li-ion charger (TP4056) IN+ |
| Solar panel (6 V) - | → | Li-ion charger (TP4056) IN- |
| 18650 Li-ion cell (3.7 V) - | → | 18650 Li-ion cell (3.7 V) + |
| 18650 Li-ion cell (3.7 V) + | → | Battery protection (2S 20A BMS) B+ |
| 18650 Li-ion cell (3.7 V) - | → | Battery protection (2S 20A BMS) B- |
| Li-ion charger (TP4056) OUT+ | → | Battery protection (2S 20A BMS) C+ |
| Li-ion charger (TP4056) OUT- | → | Battery protection (2S 20A BMS) C- |
| Battery protection (2S 20A BMS) C+ | → | Voltage sensor (0–25 V) VCC |
| Battery protection (2S 20A BMS) C- | → | Voltage sensor (0–25 V) GND |
| Battery protection (2S 20A BMS) C- | → | Arduino Uno R3 GND |
| Voltage sensor (0–25 V) S | → | Arduino Uno R3 A1 |
| Solar panel (6 V) + | → | Resistor a |
| Resistor b | → | Resistor a |
| Resistor b | → | Arduino Uno R3 GND |
| Resistor b | → | Arduino Uno R3 A0 |
| Relay module (5V, 1 channel) VCC | → | Arduino Uno R3 5V |
| Relay module (5V, 1 channel) GND | → | Arduino Uno R3 GND |
| Relay module (5V, 1 channel) IN | → | Arduino Uno R3 D7 |
| Battery protection (2S 20A BMS) C+ | → | Relay module (5V, 1 channel) COM |
| LCD 16x2 with I2C VCC | → | Arduino Uno R3 5V |
| LCD 16x2 with I2C GND | → | Arduino Uno R3 GND |
| LCD 16x2 with I2C SDA | → | Arduino Uno R3 A4 |
| LCD 16x2 with I2C SCL | → | Arduino Uno R3 A5 |
Code (Arduino C++)
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Solar charge controller: the panel feeds a TP4056 (the charge path), the
// two-cell pack sits behind a 2S BMS, and the relay is the load switch on the
// BMS's output. The voltage sensor reads the pack rail (its divider divides by
// 5) and the panel hangs on A0 so the sketch can see the charge source; the
// controller's ground and the Arduino's are tied (no common ground, no reading).
// Two protections, the way real controllers do it:
// 1. low-voltage disconnect - below 3.0 V/cell the load is cut, and it only
// comes back above 3.3 V/cell (hysteresis, so a weak pack cannot chatter);
// 2. no harvest, no load - with the panel dark the load output stays off.
// The load hangs on the relay's NO terminal; its return goes to C- (through the
// BMS), never straight to B-, so when the BMS opens, the load really dies.
// The honest catch this sim shows: a 6 V panel through a 1S TP4056 cannot push
// current into a 7.4 V pack, so the charger shows full - and the sketch agrees,
// printing CHARGING only when the panel voltage is above the pack voltage.
// (A real 2S controller boosts the panel to 8.4 V first.)
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int panelPin = A0, packPin = A1, relayPin = 7;
const float CUT = 3.0, RECONNECT = 3.3; // volts per cell
bool cutoff = false;
void setup() {
pinMode(relayPin, OUTPUT);
lcd.init();
lcd.backlight();
Serial.begin(9600);
}
void loop() {
float panelV = analogRead(panelPin) * (5.0 / 1023.0) * 2.0; // 10k + 10k divider halves it
float packV = analogRead(packPin) * (5.0 / 1023.0) * 5.0; // the sensor divides by 5
float cellV = packV / 2.0; // two cells in series
if (cellV < CUT) cutoff = true;
else if (cellV > RECONNECT) cutoff = false;
bool day = panelV > 4.5; // charge source present
digitalWrite(relayPin, (!cutoff && day) ? HIGH : LOW);
lcd.setCursor(0, 0);
lcd.print("Pack "); lcd.print(packV, 1); lcd.print("V ");
lcd.setCursor(0, 1);
if (cutoff) lcd.print("CUT-OFF ");
else if (day && panelV > packV) lcd.print("CHARGING ");
else if (day) lcd.print("FULL ");
else lcd.print("LOAD OFF ");
Serial.print("panel="); Serial.print(panelV, 1);
Serial.print(" pack="); Serial.print(packV, 1);
Serial.print(" cell="); Serial.print(cellV, 2);
Serial.print(" relay="); Serial.println(!cutoff && day ? "ON" : "OFF");
delay(300);
}