Energy generation through renewable processes has represented a suitable option for power supply; nevertheless, wind generators and photovoltaic systems can suddenly operate under undesired conditions, leading to power quality problems. In this regard, the development of condition-monitoring strategies applied to the detection of power quality disturbances becomes mandatory to ensure proper working conditions of electrical machinery. Therefore, in this work we propose a diagnosis methodology for detecting power quality disturbances by means of the continuous wavelet transform (CWT) and convolutional neural network (CNN). The novelty of this work lies in the image processing that allows us to precisely highlight the discriminant patterns through spectrograms into 2D images; the images are cropped and reduced to a standard size of 128x128 pixels to retain the most relevant information. Subsequently, the identification of six power quality disturbances is automatically performed by a convolutional neural network. The effectiveness of the proposed method is validated under a set of synthetic data as well as a real data set; the obtained results make the proposal suitable for being incorporated into the monitoring of power quality disturbances in renewable energy systems.