Mod edit:
This is related to the OP's previous topic:
Hi everyone,
I'm building a small solar-powered fountain and I'm trying to make it run for long periods, ideally during the day from the solar panel and then from the batteries after sunset.
My components
- Water pump: 5V, approximately 300–500 mA
- Battery: 3 × NiMH AA batteries
- Motor driver: DRV8833
- Solar panel: 5V, 5W — in good sunlight I can actually measure around 1A from the panel
- Solar charging module:
https://www.aliexpress.com/item/1005005428598186.html - Controller: ATtiny85
- Voltage booster:
https://www.amazon.se/dp/B07L56BN8W
How I connected everything
The basic arrangement is:
Solar panel
│
▼
Solar charger module
│
▼
POWER RAIL ◄──────► 3 × NiMH batteries
│
├──────────────► ATtiny85
│
▼
Voltage booster
│
▼
DRV8833
│
▼
5V water pump
ATtiny85 ─────────► DRV8833 IN1 / IN2
So the solar charger feeds the main power rail, the batteries are connected to the same rail, and the ATtiny85 controls the DRV8833.
The voltage booster raises the battery/rail voltage to what the pump needs, and the DRV8833 drives the pump.
I have also created schematics in KiCad:
SolarPindDrawing.pdf (257.6 KB)
Attiny code
int pumpPin1 = 0;
int pumpPin2 = 1;
int indicatorPin = 4;
int first_run = true;
bool pumpRunning = false;
int BATTERY_PACK_RUN_VOLTAGE = 4000; // (the idea is to charge it until I see 4V), and to start the batteries
int BATTERY_PACK_STOP_VOLTAGE = 3000; // (the idea is that I want to stop the system at 3v, which is a critical level for 3x NiMH batteries)
void start_pump(){
analogWrite(pumpPin1, 210);
digitalWrite(pumpPin2, LOW);
delay(1000);
// reduce power
analogWrite(pumpPin1, 200); // ~78% PWM
}
void stop_pump(){
digitalWrite(pumpPin1, LOW);
digitalWrite(pumpPin2, LOW);
}
long readVcc4() {
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = _BV(MUX3) | _BV(MUX2);
#else
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Start conversion
while (bit_is_set(ADCSRA,ADSC)); // measuring
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both
long result = (high<<8) | low;
result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
return result;
}
void blink(int battery) {
int blinks = battery / 100; // 1000 mV steps
for (int i = 0; i < blinks; i++) {
digitalWrite(indicatorPin, HIGH);
delay(100);
digitalWrite(indicatorPin, LOW);
delay(300);
}
delay(2000); // pause between measurements
}
void blink(int num, int delay_ms) {
for (int i = 0; i < num; i++) {
digitalWrite(indicatorPin, HIGH);
delay(delay_ms);
digitalWrite(indicatorPin, LOW);
delay(delay_ms);
}
}
void setup()
{
pinMode(pumpPin1, OUTPUT);
pinMode(pumpPin2, OUTPUT);
pinMode(indicatorPin, OUTPUT);
digitalWrite(pumpPin1, LOW);
digitalWrite(pumpPin2, LOW);
delay(3000);
}
void loop()
{
long battery = readVcc4();
if (first_run){
blink(10, 100);
first_run = false;
}
// Start only when battery is sufficiently charged
if (!pumpRunning) {
if (battery > BATTERY_PACK_RUN_VOLTAGE) {
pumpRunning = true;
start_pump();
}
}
else {
if (battery < BATTERY_PACK_STOP_VOLTAGE) {
pumpRunning = false;
stop_pump();
}
}
// Wait before measuring again
delay(60000);
}
What I wanted to achieve
My original goal was simply to have the fountain running for as long as possible using solar power.
Ideally, during the day the solar panel should provide enough power to run the pump, while any excess power charges the batteries. When the solar power becomes insufficient, the batteries should take over automatically.
After sunset, I would like the pump to continue running from the batteries for a couple of hours, and then shut down to avoid completely discharging them.
What actually happened
Initially, everything seemed to work.
With fully charged batteries, the pump could run for around 3–4 hours.
Then the pump stopped.
After some time it would sometimes start again, presumably because the battery voltage recovered somewhat.
This continued for a while. After approximately 3–4 days, I eventually measured almost 0V on the battery pack and nothing worked anymore.
The batteries only became usable again after I charged them from a normal mains-powered charger.
So apparently my system was eventually draining the batteries much more deeply than I expected, and the solar charging system did not recover them.
My main questions are:
1. Why did this circuit completely drain the NiMH batteries?
Is the problem with the way I connected the solar charger, batteries and load?
Could the voltage booster, DRV8833, ATtiny85, or some other part of the circuit be consuming the batteries when there isn't enough solar power?
2. Why didn't the solar charging module recover the batteries?
The solar panel is 5V/5W and can produce around 1A in good sunlight, so I expected that there should be enough power during the day to at least recharge the batteries.
However, it seems that the pump/load was able to consume more energy than the panel could replace.
3. Is my intended architecture realistic?
What I really want now is a system where the solar panel powers the pump directly during the day while simultaneously charging the batteries, and then the batteries automatically take over when solar power becomes insufficient.
NOTE:
I am a beginner in electronics (it's just a hobby for me).
The circuit design I originally came up with was suggested by an AI assistant. After several iterations and a lot of troubleshooting, I eventually realized that I should probably stop asking the robot and ask real people instead. ![]()
So sorry if I have made some very basic or obvious mistakes. I'm mainly trying to understand what is wrong with my current design and what would be the correct architecture for this project.
Any advice or criticism is very welcome!

