With the advent of advanced technological developments such as IoT, edge, and fog computing, cyber attacks have become increasingly sophisticated. IoT networks facilitate collaborative and intelligent tasks across various domains, including Industry 4.0, digital healthcare, and home automation. However, the proliferation of IoT devices has raised concerns about severe attacks, particularly those targeting resource constraints such as energy and memory. In response to these challenges, Tiny Machine Learning (TinyML) has emerged as a new research area, focusing on machine learning techniques tailored for embedded and IoT systems. This study proposes an ML detection mechanism designed to categorize and detect resource-constrained attacks in IoT devices. We consider IoT devices to be integral components within the continuum of edge and cloud computing, leveraging EdgeML and CloudML for detection purposes. Our paper conducts a comparative analysis of ML models, with a specific focus on energy consumption and memory usage in IoT applications. We compare various ML methodologies, including cloud-based, edge-based, and device-based strategies for both training and detection. The evaluation encompasses the application of these ML techniques to petite IoT devices, utilizing TinyML, as well as cloud and edge devices. Our findings reveal that the Decision Tree algorithm deployed on smart devices surpasses other approaches in terms of training efficiency, resource utilization, and the ability to detect resource-constrained attacks on IoT devices. We demonstrate a high level of accuracy, exceeding 96.9%, across all presented ML models in detecting resource constraint attacks within IoT systems. In summary, this research serves as a guide for implementing effective security measures in the dynamic landscape of IoT and associated technologies.