Earliier this month, Elon Musk, CEO of Tesla Motors unveiled the Tesla Powerwall. The Powerwall is a wall mounted rechargeable battery module that is connected to your homes electrical box as well as to a power source. It is designed to work in tandem with solar panels, as a device that: provides backup energy; stores energy during the sunny, low consumption hours; allows homeowners to shift their source power from grid to battery during expensive peak hours. The lithium-ion battery in the Powerwall as well as the P & N-type semiconductors used in today`s solar panels are creative applications of chemistry which I will be going over in greater detail.
Lithium-ion Battery
Lithium-Ion batteries are a common type of reversible battery unit seen in appliances. As the name suggests, the electronic cell that dictates the performance of the battery is driven by the behavior of the lithium ion. Lithium is a very useful substance in making batteries, due to its high oxidation potential and small molecular weight. The composition of the lithium-ion cell (shown below) is quite a brilliant arrangement of chemistry, one which has ushered in new approaches to storing electrical energy. 
Scientists have been trying to use lithium in making batteries for quite some time but this was not an easy quest. For starters, lithium is not an easy metal to work with. In its metallic form, it is unstable and reactive, making it a difficult species to control. This led to scientists trying to use the ionic and other forms of lithium in the design of the cell. This is where the lithium-ion cell comes in. Key to it’s function is the phenomena of intercalation. Intercalation is a type of non-covalent bonding where atoms/molecules associate between layers of a macromolecular structure. You can think of this as atoms are being sandwiched.
The electrodes at both terminals are composed of lithium intercalaters. The (+) terminal is a metal oxide crystal, where the lithium ion(Li +) forms a layer between the unit crystals of the reduced metal oxide. At the (-) terminal, materials such as graphite are used. Graphite is able to coordinate the reduced form of lithium such that lithium atoms exists along a plane in between sheets of graphite. The electrolyte is a non-aqueous solvent (typically a carbonate) with dissolved lithium ions. Aqueous media are unsuitable to cell function due to electrolysis reactions that can occur during the recharge steps where very high voltages are delivered to the cell.
The cell discharges as follows: Upon completing the circuit between the (+) and (-) terminals, elemental lithium is oxidized into it’s ion form (Li +) and “escapes” from the graphite. At the same time, the cathode metal is reduced. Lithium ions flow through the electrolyte and sandwich themselves between the metal oxide crystals. This entire process is capable of releasing nearly 3.6 volts per cell, outclassing many of the nickel based cells on the market. The recharge process is simply the opposite of that. In the case of the Powerwall, the recharging current comes from unused electricity generated from the solar panels.
Solar Panels
Solar panels are all about semiconductors. Semiconductors are materials that do not conduct electricity as readily as metals but are more conductive than insulating materials. With respect to band theory of solids, semiconductors have a small energy gap between the valence band where electrons are “localized” in the orbit of a given atom/molecule and the conduction band where the electrons are “delocalized” and free to move throughout the length of the material. 
Silicon is typically the material of choice when making solar panels. What is unique about silicon is that it can be chemically treated or “doped”. When doped, other atoms are introduced into the crystal structure of silicon. When silicon is doped with a pentavalent atom such as Phosphorous, the material is said to be an N-type semiconductor. On the other hand, doping silicon with a trivalent atom like Boron will create a P-type semiconductor. Phosphorous has 5 valence electrons-let’s consider the consequence of such an arrangement in a silicon crystal network. 
Remembering the old octet rule from high school chemistry; Phosphorous can actually “give up” one of it’s valence electrons and form a stable octet with the neighboring silicon atoms. This is what makes N-type semiconductors so special, they can conduct electricity much easier because Phosphorous atoms may easily promote an electron to the conduction band. Back to our idea of band gaps, we can appreciate that the energy difference between the conduction band and the valence band is smaller in N-type semiconductors compared to pure semiconductors, allowing electrons to flow more freely. P-type semiconductors are the foil to the aforementioned N-types. Due to Boron having only 3 electrons, these materials fall short of the octet rule. As such, they have what is called a “hole” or a deficiency in their valence electrons. These materials collect electrons in order to fill the valence shell.
The real magic happens when P & N type semiconductors are brought into contact. Extra electrons from the n-type materials flow to the p-type material, creating an electrically neutral zone (Depletion zone) with negative ions and positive ions on opposite sides of this zone. An electric field is formed across this PN junction, pointing from the N to the P type.
When light strikes the material, an electron is pushed to the conduction band. This electron moves towards the N-type semiconductor due to the electric field across the PN junction, creating an electric potential (Voltage) across the material due to the N-type side having an excess negative charge. By connecting the N & P semiconductors with an external wire, a current is created as electrons flow back to the P-type material and the excess charges are neutralized. The process repeats as light rays continually strike the material, allowing electrical work to be done. This is how solar panels function- by placing N & P-type semiconductors together, a light-responsive system that can produce electricity is created.
Putting it all together
Solar panels make the electricity and the Powerwall stores it. Sounds straightforward, doesn’t it. You are perhaps starting to feel that these cutting edge inventions are actually quite simple. You’re not wrong. These innovations, like many others, arose from basic scientific ideas applied imaginatively by exceptional thinkers. That’s what makes technology so magical; A playground where ideas comes together in the most creative manners.
