The growth of the Internet of Things (IoT) and its integration with Industry 4.0 and 5.0 are generating new security challenges. One of the key elements of IoT systems is effective anomaly detection, which identifies abnormal behavior in devices or entire systems. This paper presents a comprehensive overview of existing methods for anomaly detection in IoT networks using machine learning (ML). A detailed analysis of various ML algorithms, both supervised (e.g., Random Forest, Gradient Boosting, SVM) and unsupervised (e.g., Isolation Forest, Autoencoder), was conducted. The results of tests conducted on popular datasets (IoT-23 and CICIoT-2023) were collected and analyzed in detail. The performance of the selected algorithms was evaluated using commonly used metrics (Accuracy, Precision, Recall, F1-score). The experimental results showed that the Random Forest and Autoencoder methods are highly effective in detecting anomalies. The article highlights the importance of appropriate data preprocessing to improve detection accuracy. Furthermore, the limitations of a centralized machine learning approach in the context of distributed IoT networks are discussed. The article also presents potential directions for future research in the field of anomaly detection in the IoT.