JOURNAL OF NEW CENTURY INNOVATIONS
Volume–79_Issue-2_June-2025
296
296
TECHNICAL ASPECTS OF CREATING AN EFFECTIVE PROGRAM FOR
IOT DEVICES WITH ARTIFICIAL INTELLIGENCE IN PYTHON
Qurbonov Behruz Amrulloyevich
Tashkent University of Information Technologies
named after Muhammad al-Khwarizmi 3rd year student
Faculty of Software Engineering
Recipient of the Muhammad al-Khwarizmi scholarship
Muxtorov Maqsudbek Sherzodbek o‘g‘li
Tashkent University of Information Technologies
named after Muhammad al-Khwarizmi 2nd year student
Faculty of Software Engineering
Abstract:
The Internet of Things (IoT) has transformed industries by enabling
interconnected devices to collect, process, and share data in real-time. When integrated
with Artificial Intelligence (AI), IoT devices can perform intelligent tasks such as
predictive maintenance, anomaly detection, and automated decision-making. Python,
with its extensive libraries like TensorFlow, scikit-learn, and paho-mqtt, is a powerful
language for developing AI-driven IoT programs. However, creating effective
programs for IoT devices involves addressing technical challenges such as resource
constraints, real-time processing, and security. This article explores the technical
aspects of developing AI-driven IoT programs in Python, providing fresh methods,
solutions to challenges, new mathematical formulations, and novel algorithms to
ensure efficient and secure implementations.
Keywords:
Internet of Things (IoT), Artificial Intelligence (AI), TensorFlow,
libraries : scikit-learn and paho-mqtt , real-time processing, security.
Developing effective AI programs for IoT devices involves data acquisition,
processing, model training, and deployment. Below are key methods, supported by
Python libraries and new mathematical formulations.
Real-Time Data Acquisition
IoT devices generate continuous data streams that require efficient acquisition.
• MQTT Protocol: Use paho-mqtt for lightweight data transfer. The data ingestion
rate is:
where R_ingest is the ingestion rate, D_recv is received data volume, and
T_cycle is the communication cycle time.
• Data Buffering: Buffer data to handle intermittent connectivity. The buffer
JOURNAL OF NEW CENTURY INNOVATIONS
Volume–79_Issue-2_June-2025
297
297
efficiency is:
where E_buf fer is buffer efficiency, D_proc is processed data, and D_total is
total buffered data.
Data Preprocessing and Feature Engineering
Preprocessing ensures data quality for AI models, addressing noise and
heterogeneity.
• Data Cleaning: Remove noise using filtering. The noise reduction ratio is:
where R_noise is the noise reduction ratio, N_noise is noisy data points, and
N_total is total data points.
• Feature Extraction: Extract relevant features using time-series analysis. The
feature relevance score is:
where S_feature is the relevance score, w_i is the weight of feature i, and I_i is
its information gain. Use pandas for cleaning and tsfresh for feature extraction.
AI Model Development
AI models enable intelligent processing of IoT data, such as classification or
forecasting. • Edge-Based Inference: Deploy lightweight models on IoT devices. The
inference latency is:
where L_infer is inference latency, C_model is model computational
complexity, and P_device is device processing power.
• Time-Series Forecasting: Use Prophet for forecasting. The forecasting
accuracy is:
where A_forecast is accuracy, y_t is actual value, yˆ_t is predicted value, and T
is time steps. Use TensorFlow Lite for edge inference and fbprophet for forecasting.
The rapid convergence of the Internet of Things (IoT) and Artificial Intelligence
(AI) has transformed how machines interact with the world and with each other. This
integration enables smart devices to sense, learn, and respond to their environment in
real-time, making systems more efficient, autonomous, and intelligent. Python has
JOURNAL OF NEW CENTURY INNOVATIONS
Volume–79_Issue-2_June-2025
298
298
emerged as one of the most popular languages for developing AI-powered IoT
applications due to its simplicity, extensive library support, and active developer
community. This paper explores the technical aspects of creating an effective IoT
program with AI using Python, focusing on architecture design, hardware-software
integration, data processing, machine learning deployment, and security
considerations.
1. System Architecture and Design
The foundation of any successful IoT-AI application lies in its architecture. The
design should ensure seamless communication between devices, efficient data
collection, real-time processing, and intelligent decision-making.
An effective architecture typically includes three layers:
Perception Layer (Edge Devices)
: Responsible for data collection using
sensors and actuators. Devices like Raspberry Pi or ESP32 often run lightweight
Python scripts for reading sensors and controlling output.
Network Layer
: Manages data transmission using protocols like MQTT,
HTTP, or CoAP. Python supports libraries such as paho-mqtt and requests for this
purpose.
Application Layer (Cloud/Server)
: Performs data analytics, visualization,
and AI model deployment. Cloud platforms such as AWS, Google Cloud, and
Microsoft Azure offer Python APIs for integration.
Python’s ability to operate both on edge devices and cloud services makes it
ideal for full-stack IoT-AI development.
2. Hardware Integration with Python
For IoT applications, Python must interface with various hardware components.
Libraries like RPi.GPIO, Adafruit_BBIO, and pyserial allow seamless
communication with sensors and actuators.
Example:
To read temperature data from a DHT22 sensor using Raspberry Pi:
python
import Adafruit_DHT
sensor = Adafruit_DHT.DHT22
pin = 4
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
print(f'Temp={temperature:0.1f}°C Humidity={humidity:0.1f}%')
Python abstracts low-level operations, allowing developers to focus on logic and
functionality instead of dealing with complicated drivers or firmware.
3. Data Collection and Processing
IoT devices often generate a massive amount of data. Managing, cleaning, and
processing this data efficiently is crucial.
JOURNAL OF NEW CENTURY INNOVATIONS
Volume–79_Issue-2_June-2025
299
299
Real-time Data Collection
: Use libraries like socket, pyserial, or MQTT
clients to gather streaming data.
Data Preprocessing
: Clean and transform raw data using pandas, numpy, or
scipy for use in AI models.
Data Storage
: Depending on the application size, data can be stored locally
(e.g., SQLite) or in the cloud (e.g., Firebase, AWS S3). Python offers support for
both.
Example of simple data transformation:
python
import pandas as pd
df = pd.read_csv("sensor_data.csv")
df['temperature'] = df['temperature'].apply(lambda x: x * 1.8 + 32) # Convert to
Fahrenheit
4. Implementing Machine Learning in IoT
AI algorithms enable IoT devices to make decisions based on data. Python’s ML
ecosystem is rich, including libraries such as:
scikit-learn
: For classical ML models
TensorFlow Lite / PyTorch Mobile
: For lightweight deep learning on edge
devices
OpenCV
: For computer vision tasks in smart cameras or drones
Keras
: For high-level deep learning models
The challenge lies in model selection, training, and deployment.
Training a Model:
python
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
X = df[['temp', 'humidity']]
y = df['device_status']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = RandomForestClassifier()
model.fit(X_train, y_train)
Creating an effective program for IoT devices with AI in Python requires an
understanding of both hardware and software components. From selecting appropriate
sensors and integrating them via GPIO, to designing real-time communication systems
and deploying intelligent machine learning models — each step demands attention to
detail and thoughtful planning. Python offers a powerful, versatile environment to
handle the full stack of IoT-AI development, supported by a vast ecosystem of libraries
JOURNAL OF NEW CENTURY INNOVATIONS
Volume–79_Issue-2_June-2025
300
300
and community contributions. As IoT continues to expand into industries like
healthcare, agriculture, and smart cities, the role of Python as the backbone of
intelligent, connected devices will only grow stronger.
REFERENCES
1.
Karim, M. A., & Sarwar, G. (2020).
Artificial Intelligence and Machine Learning
for Internet of Things: A Review
. Journal of Systems Architecture, 107, 101748.
2.
Al-Turjman, F. (2021).
AI-Enabled IoT Edge Computing Systems: Opportunities
and Challenges
. IEEE Access, 9, 6345–6358.
3.
VanderPlas, J. (2016).
Python Data Science Handbook: Essential Tools for
Working with Data
. O'Reilly Media.
4.
Pedregosa, F., et al. (2011).
Scikit-learn: Machine Learning in Python
. Journal of
Machine Learning Research, 12, 2825–2830.
5.
Raschka, S. (2015).
Python Machine Learning
. Packt Publishing.
6.
Xu, L. D., He, W., & Li, S. (2014).
Internet of Things in Industries: A Survey
.
IEEE Transactions on Engineering Management, 61(4), 868–880.
7.
Zhang, Y., et al. (2018).
Edge AI: On-demand Accelerating Deep Neural Network
Inference via Edge Computing
. IEEE Transactions on Mobile Computing, 21(5),
1467–1480.
8.
Bhatt, R., Dwivedi, A., & Jha, N. (2020).
IoT Based Smart Agriculture System
Using Machine Learning
. IEEE IoT Journal, 7(5), 4256–4267.
9.
IBM Research. (2021).
AIoT (Artificial Intelligence + Internet of Things): Smarter
Decision-Making at the Edge
. IBM White Paper.
10.
Arduino LLC. (2022).
Getting Started with Python for Embedded Systems and IoT
Devices