Re: Assistance with a solar charge controller project

I've made a circuit for solar charge controller. The problem with this circuit is that when the Induino board is power through USB port from laptop, the code works fine. But when I use the same battery which is being sensed as supply to run the board, the Led's all are ON, indicating malfunction.
Here's the code.

#define voltage_in 0
#define voltage_out 1

#define LED1 12
#define LED2 10
#define charge_enable 11

int x;
int y;

int chon = 5000; // charge on time
int choff = 2000; // charge off time

int CP = 368; // charge point variable
// CP sets the battery charge voltage level. Can vary from 346 - 410.
void setup() {

pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(charge_enable, OUTPUT);

digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(charge_enable, LOW);

}

void loop() {

x = analogRead(voltage_in); // voltage from solar panel
//under CP on ADC indicates not enough voltage to charge battery
y = analogRead(voltage_out); // voltage on battery to be charged
// over or equal to CP on ADC indicates fully charged battery

if (x < CP) digitalWrite(LED1, HIGH);
else digitalWrite(LED1, LOW);
// LED off indicates good input voltage

if (y > CP) digitalWrite(LED2, HIGH);
else if (y <= CP) digitalWrite(LED2, LOW);
// LED on means battery is charged

if ((x > y) & (y < CP) & (x > CP)) { // check input voltage and voltage on battery
// turn on charge cycle if voltage input good AND battery voltage low.

digitalWrite(charge_enable, HIGH); // turn on voltage to battery
chon = (CP - y) * 1000;
delay(chon); // ON wait
digitalWrite(charge_enable, LOW); // turn off charge enable
delay(choff); // OFF wait
} // end if
}

Arduino board.docx (1.15 MB)

Hello,

so this is probably not a problem with the code but with power supply and GND connection. How do you connect the board to the battery?

Elektrix

You could ask the original author, Lewis Loflin.

Who has a better understanding of his circuit & code than anyone else here.

Hi,

I initially connected using the connecters provided in the induino board. But later found that there is a voltage drop happening. So I stripped a USB cord female and connected the +ve and -ve of the stripped USB female to the +ve and -ve of the battery. This USB female was then connected to the USB male connector of the induino board

JB_AU:
Who has a better understanding of his circuit & code than anyone else here.

You know, I honestly hate it when I see this kind of crap.

pmadithya, your problems with this charge controller aside - just what thoughts were you having when you posted this plea for help?

You posted the code and a description of the problem, but never once gave any indication as to the original developer's work - this is plagiarism at its most fundamental level, and should be severely frowned upon. A simple acknowledgement of the developer's work not only would have been the right thing to do, but it likely would have helped us to help you better, as his site shows the original code along with the proper circuit to use with it (plus other notes relating to the circuit).

Instead - whether through thoughtlessness or deceit - you left out the important details of where you obtained the code and schematic for the controller (presumably - because you haven't posted a schematic). This doesn't help us at all, and makes you look like the north end of a south-bound donkey. In this age of google, nearly anything can be easily fact-checked.

Even if I did have an answer for your problem, I would be loathe to give it to you after this. Hopefully, you have learned your lesson, and will better uphold the values of many of those in the Maker movement in the future.

Hi,

Apologies for my grave mistake. I should have written "I've got this circuit" and not "I've made this circuit". Also I forgot to mention the link Arduino Solar Battery Charge Controller.
The actual problem might be because of the same reason that charge voltage is more than the battery voltage.
About connecting an auxiliary battery source, is there any way I can connect something which might drain out easily as 9V battery i've used just drains out. The application is an off-grid solution. So I might not be able to use a power supply.

So...you're having issues when trying to run the Arduino from a 9v battery?

Hello,

Well I can run it barely for 10 mins and then it stops. The thing is I need a constant voltage and the board needs to draw low current.

You know, I honestly hate it when I see this kind of crap.

That's not fair, who better to ask than the original author, he designed the circuit and he wrote the code, so i would think he would have the most experience.

I did not mention any copyright infringement and there was no melodramatic overtone. (my bad , neither did i fully read your post)

The majority of code is open source, that circuit is open source, i don't think the author would mind, but now we have a link & better understanding.

This system is 12v, it requires a 12v battery. You can run from the battery or create a separate source.

A 9v battery is a low milliamp supply.

Your best option is to feed off the 12v bank with a voltage regulator , im not familiar with induino, so it may run from 7-12v.

pmadithya:
So I stripped a USB cord female and connected the +ve and -ve of the stripped USB female to the +ve and -ve of the battery. This USB female was then connected to the USB male connector of the induino board

Give more information!!!

What kind of battery do you use? Which voltage? When you have a 12V battery and you connect the USB connector to 12V then you will kill the board. USB has 5V.

Elektrix

Give more information!!!

Read more!!!

The schematic uses a 12v panel to charge a 12v battery, i have recommended to regulate 7-12v from the battery to power the board, depending on what the induino recommends as a safe voltage. You can/should not be supplying usb any other voltage than 5v 500ma, this is generally supplied by your pc. Their should be a jack or other means to supply power to. This system is designed to harvest 12v from solar, you can not mix and match voltages, it will end disastrously otherwise.

If you do not understand the circuit to make the appropriate modifications, then consult the original author.

Having taken a quick look at the code and schem...
Ad0 And Ad1 Are Assumedly Connected To The arduino. They Are Being fed From A Voltage Divider, Ad0 Being Fed From The Panel Voltage And Ad1 From The Battery.

A Two Resistor Voltage Divider Is Made According To What Output range You Want from An Input Range,
Assuming the Battery Runs From 12v To 10v When Discharged, If You Put 9v In, The Output Read By Ad1 Is Probly Below A Coded Threshold.

I Havent spent Much Time Looking At It, Nor Am I A Good Arduinoer, But I Think you should Be Able To Work Out Whats going On From That.

In English the first word in each sentence starts with a capital letter, and so do proper nouns. There are a few other places where capitals are appropriate. You don't need to capitalise the first letter of every word, and when you do it is almost as irritating as SHOUTING AT US. You seem to be doing it on every post recently. Please stop doing it.

Hello,

Well i'm using a 6 Volt 4.5 Ah lead acid battery commonly available in emergency lamps. This is so that I can charge my battery faster by using my 5 W solar panel. I've included my schematic below. I've used a switching regulator to stabilize my voltage to the section to 7.5 V. Also to the arduino i'm feeding 5 V supply as i've built a 5V switch mode power supply.

My house runs on solar, i have 4x 12v 200w panels, wired to my 12v controller, connected to my 12v bank, i feed my inverter off of the bank, i also feed my mega with regulated power from the same bank. I could have bought 24v panels & charged my 12v batteries twice as quick, but there was a danger from overheating & poisoning myself in the process or my house catching on fire.

Im curious if your regulator does under/over & cutoff protection, and what your using after the battery.

Looks like this could be an expensive setup, after it's all worked out.

PeterH:
In English the first word in each sentence starts with a capital letter, and so do proper nouns. There are a few other places where capitals are appropriate. You don't need to capitalise the first letter of every word, and when you do it is almost as irritating as SHOUTING AT US. You seem to be doing it on every post recently. Please stop doing it.

Not as irritating as your continued whining.

I found this post while googling for a arduino based charge controler and after reading through it I am frankly disconcerted (shouting of troll may begin now). As a coder who uses quite a few languages I can't tell you how many snippets of code I have grabbed from some random site because they seemed like somthing I might use in the future or were a cool solution to a difficult problem, I do my best to give credit but thats tricky sometimes when you have thousands of little and not so little snippets and a scattered mind. I have to ask myself if this is the kind of reception I should expect if I post in this forum while trying to debug code and forget to sight the source?

To everyone who had constructive advice thanks, I think this, with a bit of tweaking may very well work. I was using a off the shelf charge controller for my rather hacked together workshop power system until I upgraded, putting six more 50w panels and a small wind generator into the mix. Finding a charge controller with multiple inputs in my budget was laughable, $525 was the cheapest and didn't support gell cell batteries. I'll post the code I use once I get it up and running or maybe on another site if I can't.

~thought without action is labor lost, action without thought is perilous.