The accurate prediction of solar energy generation is significant for efficient energy management in Internet of Things (IoT) devices. However, current forecasting models frequently fail to account for the dynamic nature of weather conditions. Also, traditional methods often have limited accuracy and scalability. This paper proposes Solar Energy Prediction in IoT system based optimized Complex-Valued Spatio-Temporal Graph Convolutional Neural Network (SEP-CVSGCNN-IoT) to overcome the limitations of existing models. Initially, the data are collected from solar panel and weather forecast. The collected data is given to the pre-processing using Data-Adaptive Gaussian Average Filtering (DAGAF) to remove the unwanted data and replace missing data. The pre-processed data is given into Nutcracker Optimization (NCO) algorithm for selecting optimal features. Then, the selected features are given to the Complex-Valued Spatio-Temporal Graph Convolutional Neural Network (CVSGCNN) for solar energy prediction. Finally, Dipper Throated Optimization Algorithm (DTOA) is proposed to enhance the weight parameter of CVSGCNN classifier, which precisely predicts solar energy in IoT. The proposed SEP-CVSGCNN-IoT method provides 18.46%, 26.34, 15.69 and 20.84% higher accuracy and 18.24%, 23.77, 24.34 and 16.29% lower mean absolute error when analyzed with existing techniques, such as deep learning enhanced solar energy prediction and AI-driven IoT (DL-ESEF-AI), towards efficient renewable energy prediction using deep learning (TEE-REP-DL), a new deep learning method for effectual forecasting of short-term PV energy production (DL-EF-SPEP) and metaheuristic-dependent hyper parameter tuning for recurrent deep learning: application to the solar energy generation prediction (HT-RDL-PSEG) respectively.