We designed a piezoelectric energy harvesting system for self-powering a system like a black box that records the vibration and acceleration data of trains for their safety and health monitoring. To make the recording system self-powered, this harvesting system harvests inertial energy as well as vibration energy. To harvest these energies maximally, we proposed the piezoelectric energy harvesting system with magnetic pendulum movement (PEH-MPM).In this system, there are two magnets: one located at the end of a pendulum rod and the other located at the free end of a piezoelectric cantilever with an acrylic case. The vibration data was acquired from an actual passenger train. When the train moves, the magnet on the pendulum rod makes the piezoelectric cantilever vibrate, amplifying movement of the magnet at its free end. We set structural conditions such as the magnet thickness, length of the pendulum rod, and distance between the magnets. We determined optimizing conditions for increasing output power by changing three conditions: pendulum direction, magnetic pole, and load resistance. The pendulum directions investigated were the X-direction in the direction of train motion and the Y-direction, perpendicular to train motion. The magnetic pole was either attraction or repulsion between the pendulum magnet and the tip magnet. Finally, the impedance varied from 10 kΩ to 1000 kΩ. The system’s output power varied considerably with these three conditions.In conclusion, the optimizing conditions were pendulum motion in the Y-direction, an attractive magnetic pole, and an impedance of 200 kΩ. Under these conditions, the system generated 40.24 μW/cm3. This output power density is possible to be used as a power source for the safety sensor in trains.