Anomaly detection is critical in the smart industry for preventing equipment failure, reducing downtime, and improving safety. Internet of Things (IoT) has enabled the collection of large volumes of data from industrial machinery, providing a rich source of information for Anomaly Detection (AD). However, the volume and complexity of data generated by the Internet of Things ecosystems make it difficult for humans to detect anomalies manually. Machine learning (ML) algorithms can automate anomaly detection in industrial machinery by analyzing generated data. Besides, each technique has specific strengths and weaknesses based on the data nature and its corresponding systems. However, a large portion of the existing systematic mapping studies on AD primarily focus on addressing network and cybersecurity-related problems, with limited attention given to the industrial sector. Additionally, the related literature do not cover the challenges involved in using ML for AD in industrial machinery within the context of the IoT ecosystems. Therefore, this paper presents a systematic mapping study on AD for industrial machinery using IoT devices and ML algorithms to address this gap. Our primary objective is to investigate the use of ML models for anomaly detection within an industrial setting, particularly within IoT ecosystems. The study comprehensively evaluates 84 relevant studies spanning from 2016 to 2023, providing an extensive review of AD research. Our findings identify the most commonly used algorithms, preprocessing techniques, and sensor types. Additionally, this review identifies application areas and points to future challenges and research opportunities.