Usually 2 separate units are used to generate and store energy. 1. Something to generate the energy, like solar, coal, gas, etc. 2. A battery to store the energy. Now for the first time, using nanomaterials, a self-charging battery has been made.
They used a PVDF film, which is a piezoelectric material. That means when it's compressed, it generates a small amount of electricity. This is how many cigarette and barbecue lighters work. You have to press that "ignite" button pretty hard to make a spring-loaded hammer smack a piezoelectric material, to generate that spark.
A compressive force at 2.3Hz could generate 327 to 395 millivolts. While that is not enough to power an LED, which requires about 2200mv, that voltage can be boosted somewhat. This important because it creates energy from mechanical movement in one step.
Source
Phys.org. 2012-08.
Study: Xinyu Xue, et al. “Hybridizing Energy Conversion and Storage in a Mechanical-to-Electrochemical Process for Self-Charging Power Cell.” Nano Letters. DOI: 10.1021/nl302879t.