So I needed a smart solar battery switch, and I couldn’t find one available as a finished product, so I decided to try and make one. I consulted my friend Akiba over at Freak Labs, and he taught me the basic circuits I’d need to use to do what I wanted to do.
To explain what that is, I have a small 240 watt 12V solar system I use as an emergency power supply. It has a 1500W DC-AC inverter running off around 400Ah of deep cycle battery storage, which in turn is charged by 2 x 120W 12V solar panels. I also have a product called an “eco switch” which takes one grid power and one renewable power source (AC) as inputs and has one regular (Japanese) 100V AC outlet. Power from the outlet is taken from the renewable input if available, with the grid power input as fallback.
The one problem with the system is that my inverter is capable of pulling more amperes than the charge controller wants to give it. The charge controller sits, usually, in between the panels, batteries, and inverter, controlling all three. It prevents the batteries from being overcharged and overdrained. My controller, in an effort to save money, is a Chinese manufactured model rated up to 40A DC. However, my 1500W inverter can pull up to 125A (peak 166.6A). In fact, it won’t even operate when there is no load on it when plugged into my 40A controller. However, it works fine when connected directly to the battery bank. But the problem with that is that now there is no overdrain protection. So long story short, I needed a smart switch which would monitor battery voltage and cut the power to the inverter when it got low. And while I’m at it, I figured I might as well monitor current drawn by the inverter and log the data so, upload it to a server wirelessly, and then graph the results.
This gallery shows the steps from initial prototyping of the basic circuit up to the functional prototype using my 200A capable 12V relay.
I started by setting up a manually switched circuit in order to learn how the various components functioned. It took me quite a while, despite the availability of component data sheets, to figure out how to correctly wire the transistor and relay, which are the most important components in the switch part. In my experiment, I’ve got a regular toggle switch sitting in as the “smart” part, so I pretend that the batteries are low when the switch is off, and charged when I turn the switch on. That toggle switch then powers a transistor, which itself is basically like another switch which provides power, or doesn’t, to yet another switch, the relay. The reason for the transistor is that the toggle switch here is sitting in for an integrated circuit which will only provide a digital signal, which means 5 volts at low current. This is not enough power to operate the relay, which is the component that actually turns on or cuts off the connection from the batteries to the inverter. The transistor solves that problem. It has three pins, the “base”, “collector”, and “emitter”. The collector is just your positive voltage, the emitter is negative, and the base acts kind of like a push button. Push the button down (power it) and the transister will allow voltage to pass from in to out, or from collector to emitter. Don’t push the button, and no voltage will pass. The point is that the power going to the in, to the collector, can come directly from your power source. You can think of it as though there is a huge water pipe with an on off valve in the middle, and a guy standing there operating the valve.
The relay that the transistor controls is also just another switch, but it can handle much higher power going through it than the transistor could. That is why I can’t just put a transistor between my batteries and inverter. So basically, I am taking a very small power signal, the digital “on” signal from a chip (the one that is going to check my battery voltage and make a decision to power the inverter or not), and stepping up the strength of that on signal until it is strong enough to operate the big switch that sits on the main power line.
In the initial experiment, I’m using a very tiny little relay that can control a 12V line (up to 1A) from a 5V signal. In the finished prototype, I’ve replaced that with a massive (fist sized) relay made for automotive applications that can control up to a whopping 200A at 12V from a 12V signal.
In order to get that 12V control voltage to the relay, I had to upgrade my transistor. The transistor I already described above is called an “NPN” transistor, which you can Google if you want because I’m not going to go into why it is called NPN. Passing on a 12V signal is a bit out of it’s range, so I’ve replaced it with what’s called an N channel MOSFET, again, Google it. The function is pretty much the same as the NPN transistor, but the pin order is different and the pins have different names. Also, while both transistors require resistors nearby to function properly, the position and wiring is different.
Also, in my finished prototype, the manual toggle switch is replaced by an Arduino Uno. I’m not going to explain what that is, so instead I recommend you just watch this video:
Massimo Banzi explains arduino at TED
So the arduino is a device that let’s you itch the scratch and make that thing that you wish someone had invented. In this case, I have the arduino check the voltage on the batteries, and when it detects there is enough charge, it sends a digital “on” signal to that MOSFET. When the charge is inadequate, it sends an “off” signal (actually, it just doesn’t send any voltage). In order to check the voltage, I use what is called a “voltage divider”, which is a fancy name for two resistors wired in series. A neat trick with wiring two resisters in a row is that if you have a wire running out from between them, that wire will have a lower voltage than the voltage going into the first resister, according to a certain equation. In this case I have somewhere between 10V (batteries almost completely empty) and 13.9V (batteries full) coming into my voltage divider. The divider cuts the voltage to 1/3, which maxes out under 5 volts. The reason I do this is because the arduino analog input I use to take in the data only accepts up to 5V. The arduino, basically a little computer with very little memory and a tiny, tiny OS (kind of like the first computer I ever owned, actually), then takes that 5V and multiplies it by 3 (actually it is a bit more complicated but still easy) to learn the original voltage. When there is enough, it sends out the “on” signal from another pin.
Also in the final prototype is a basic LCD screen which I plug directly into some pins on the arduino to let it control the screen. Luckily, the arduino IDE includes libraries for operating an LCD. Here I have it showing the voltage that it has read from the batteries, which for now are just 8 x AA batteries that are very quickly being drained by the circuit. That is actually a good thing, because I can watch the voltage drop in real time to make sure the whole thing works. And it does. You’ll notice in each picture that there is a LED light on the breadboard that is lit up. This LED light and its resistor companion are on their own separate circuit with their own power source. The LED light represents my inverter. If the light is on, the inverter runs. If it is off, the inverter is disconnected.
Also of note is that I have a 10k ohm potentiometer (basically a volume knob) on the circuit at all stages. Initially, I used it to simulate drain to the batteries. Later, I had to hook it up to the LCD screen because the only circuit diagram I found for wiring an LCD to the arduino required it to control LCD contrast. For my finished circuit, I’d rather just fix the contrast at a certain level, so I’m assuming I can swap the potentiometer out for a regular resistor of the appropriate rating.
Still to do are to connect either a DC current meter or AC current meter, and the box the project up in a more permanent way so that I can put it to work on my solar system. Also, I need to add logging and, hopefully, wireless data uplink.
I’ve gone ahead and ordered a beaglebone to act as my data collection server. I wanted a PC that I could leave on 24/7 without using very much power at all, and this single board PC seems to be in the lead for low power consumption at the moment. Ultimately I’d like to wire my whole farm with wireless sensors, so in the future this beaglebone will have much more to do than monitor a single solar battery switch.