Net Labs UGReport
Net Labs UGReport
NAMUBIRU CONSTANCE
21/U/22161/PS
August 2024
Approval
To certify that Namubiru Constance completed a 8 week industrial training period at
netLabsUG!. This report accurately captures the work she was able to complete while
working under our careful supervision. We hereby provide our approval for the report to
be delivered to the Board of examiners.
FIELD SUPERVISOR
Signature:
I
Declaration
I, Namubiru Constance, hereby declare that the work submitted in this report is uniquely
prepared by me after the completion of a two months internship training with netLabsUG!
at the College of Engineering, Design, Art and Technology (CEDAT),Makerere University.
I confirm that this report is only prepared for my academic requirement and not for any
other purpose.
Namubiru Constance
21/U/22161/PS
Signature:
II
Acknowledgment
I would like to take this opportunity to thank the almighty God for the gift of life and
good health during the training period. It has been a very great pleasure to be trained
at netLabsUG!.
I am particularly grateful to my field supervisor Mr. Kaddu Titus and my training officers
Ms. Immaculate Kamusiime and Mr. Wayne Opio for their guidance and mentoring
during this period. I extend my gratitude to my benefactors Dr. and Mrs. Paul Masajjage
for their financial and moral support without which this endeavor would have been futile.
III
TABLE OF CONTENTS
APPROVAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I
DECLRATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . II
ACKNOWLEGMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . III
LIST OF ACRONYMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . VI
LIST OF FIGURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V
. III
1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Background of the Internship . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 netLabsUG! Company Details . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1 Nature of the Business . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.2 Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.3 Vision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.4 Mission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.5 Organizational Structure . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Objectives of the Internship . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 LITERATURE REVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1 Python Programming Language . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.1 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.2 Variables and Simple Data Types . . . . . . . . . . . . . . . . . . . 4
2.1.3 Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.4 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.5 Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.6 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.7 Modules and Packages . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.8 Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.9 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.10 File Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Object Oriented Programming (OOP) . . . . . . . . . . . . . . . . . . . . 7
2.2.1 Classes: The Blueprints . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.2 Objects: The Instances . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.3 Attributes and Methods . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.4 Advantages of OOP . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Flask Web Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Embedded Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4.1 Characteristics of an Embedded System . . . . . . . . . . . . . . . 10
2.4.2 Basic Structure of an Embedded System . . . . . . . . . . . . . . . 10
2.4.3 Sensor and Actuator Examples . . . . . . . . . . . . . . . . . . . . 11
IV
2.4.4 Embedded System Development Boards . . . . . . . . . . . . . . . 13
2.4.5 Arduino UNO R3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.4.6 ESP32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.4.7 Arduino IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.5 IoT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.6 Machine Learning with Python . . . . . . . . . . . . . . . . . . . . . . . . 16
2.6.1 Research Question . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.6.2 Data Validation and Cleaning . . . . . . . . . . . . . . . . . . . . . 17
2.6.3 Exploratory Data Analysis . . . . . . . . . . . . . . . . . . . . . . . 17
2.6.4 Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.7 Solar PV Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.7.1 Components of a Solar PV System: . . . . . . . . . . . . . . . . . . 19
2.7.2 Solar Irradiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.7.3 Design and Sizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3 WORK DONE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.1 Introduction to Programming with Python . . . . . . . . . . . . . . . . . . 21
3.1.1 Library Management System (LMS) . . . . . . . . . . . . . . . . . 21
3.1.2 University Management System (UMS) . . . . . . . . . . . . . . . . 23
3.2 Introduction to OOP in Python . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2.1 LMS using OOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2.2 Social Media Platform . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.3 Introduction to Embedded Systems with Arduino UNO . . . . . . . . . . . 27
3.3.1 Blinking LED Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3.2 Traffic Light Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3.3 Proximity Sensor Circuit . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3.4 Door Access Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.4 Introduction to IoT with ESP32 . . . . . . . . . . . . . . . . . . . . . . . . 29
3.4.1 DHT Circuit to Upload Data to the ThingSpeak IoT Plaform . . . 29
3.5 Introduction to PCB Design . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.6 Introduction to Machine Learning . . . . . . . . . . . . . . . . . . . . . . . 31
3.7 Solar PV Systems Design and Maintenance . . . . . . . . . . . . . . . . . . 33
3.8 CapStone Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.8.1 Embedded System Design . . . . . . . . . . . . . . . . . . . . . . . 34
3.8.2 Machine Learning Model Development . . . . . . . . . . . . . . . . 37
3.8.3 Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
REFERENCES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
APPENDICES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
V
List of Acronyms
IC Intergrated Circuit
ML Machine Learning
VI
List of Figures
VII
3.29 Code Block in Arduino IDE to implement a central gateway using ESP-
NOW communication protocol. . . . . . . . . . . . . . . . . . . . . . . . . 37
3.30 e-farm prototype showing the irrigation module. . . . . . . . . . . . . . . . 37
3.31 Sample EDA of crops dataset. . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.32 The web application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.33 User authentication page. . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.34 Code block to interact with Firebase. . . . . . . . . . . . . . . . . . . . . . 39
3.35 Th Firebase database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
VIII
1 INTRODUCTION
This report provides a comprehensive overview of my activities and insights garnered over
the course of an 8-week internship training program conducted at netLabsUG!. The in-
ternship transpired from June 4, 2024, to August 4, 2024, and was pursued as a mandatory
component for fulfilling the prerequisites of a Bachelor of Science in Electrical Engineering
degree at Makerere University.
During this internship period, I engaged in various tasks, projects, and learning op-
portunities that align with the practical aspects of my academic pursuits. This report
encapsulates my experiences, achievements, and the skill sets I acquired while working
within the dynamic environment of netLabsUG!.
1
tasks, managing their responsibilities, and demonstrating self-motivation to achieve
objectives.
Interpersonal Skills:
Students should exhibit strong interpersonal skills by understanding and appreciat-
ing individual differences among their colleagues. Developing positive relationships,
effective teamwork, and building self-confidence are integral components of success-
ful internship experiences.
Effective Project Management:
Interns are expected to demonstrate proficiency in planning, managing, and contin-
uously monitoring projects. Quality delivery of projects is emphasized, and students
are encouraged to refine their project management skills during their internship.
Overall, the internship training program not only provides students with practical expo-
sure to their chosen field but also fosters personal and professional growth. The skills
gained during this period contribute to students’ holistic development and readiness for
their future careers.
1.2.2 Address
Room 3013, New Building, CEDAT, Makerere University, Kampala, Uganda; info@netlabs.com.
1.2.3 Vision
To be a regional leader in collaborative research, development and solutions on innovative
telecommunication and networking technologies, strengthening the Ugandan and regional
technological economy.
1.2.4 Mission
To be a regional Centre of Excellence (CoE) in the area of telecommunications and net-
working technologies.
2
1.2.5 Organizational Structure
3
2 LITERATURE REVIEW
Within this chapter, the focus is directed towards the technologies used in the design and
production of an IoT solution during the internship.
4
2.1.3 Data Structures
Python has mutable (Lists , Sets and Dictionary) and immutable(tuples) data structures.
For mutable the state can be changed after creation and the reverse is true for immutable.
1 # mutable type : list
2 cars = [ ’ Mazda ’ , ’ Honda ’ , ’ Toyota ’]
3 cars [0] = ’ Mercedes ’
4 print ( cars ) # Output : [ ’ Mercedes , ’ Honda ’,’ Toyota ’]
5
2.1.4 Operators
Python supports various types of operators like arithmetic operators (+, -, *, /, %),
comparison operators (==, !=, <, >, <=, >=), logical operators (and, or, not).
1 x = 10
2 y = 5
3 z_add = x + y # Addition
4 z_mult = x * y # Multiplication
5 is_equal = ( x == y ) # Comparison
6 logical_result = ( x > 5 and y < 10) # Logical
7
2.1.6 Functions
Functions in Python are defined using the def keyword, promoting code reuse, modularity,
and maintainability. By encapsulating logic into functions, developers can write cleaner
code and reduce redundancy. For example:
1 def greet ( name ) :
2 """ Function to greet the user . """
3 return f " Hello , { name }! "
4
5 # Calling the function
6 message = greet ( " Alice " )
5
7 print ( message ) # Output : Hello , Alice !
8
6
1 # Example of file handling
2 # Writing to a file
3 with open ( " example . txt " , " w " ) as f :
4 f . write ( " Hello , World !\ n " )
5 f . write ( " This is a file written in Python . " )
6
7 # Reading from a file
8 with open ( " example . txt " , " r " ) as f :
9 content = f . read ()
10 print ( content )
11
Base Classes The foundation of inheritance is the base class, which defines the
common attributes and methods shared by related objects. This allows for code
reuse and the creation of more specialized classes.
1 # Example of a base class
2 class Animal :
3 def __init__ ( self , name )
4 self . name = name
5
6 def speak ( self )
7 pass
8
9
Derived Classes Derived classes, also known as subclasses, inherit the properties
and behaviors from the base class, adding or modifying them as needed. This creates
a hierarchical relationship, with subclasses inheriting from superclasses.
1 # Example of a derived class
2 class Dog ( Animal ) :
3 def __init__ ( self , name )
4 self . name = name
5
6 def speak ( self )
7 return ’ Woof ! ’
8
7
2.2.2 Objects: The Instances
Objects are the instances created from a class. They inherit the characteristics and
capabilities defined within the class, allowing you to work with real world entities in your
code. [3]
1 # Example of creating objects
2 class Person :
3 def __init__ ( self , name , age )
4 self . name = name
5 self . age = age
6
1 class Animal :
2 def make_sound ( self ) :
3 pass # Base class with a method to be overridden
4
5 class Dog ( Animal ) :
6 def make_sound ( self ) :
7 return " Woof ! "
8
8
9 class Cat ( Animal ) :
10 def make_sound ( self ) :
11 return " Meow ! "
12
13 # Function that demonstrates polymorphism
14 def animal_sound ( animal ) :
15 print ( animal . make_sound () )
16
17 # Create instances of Dog and Cat
18 dog = Dog ()
19 cat = Cat ()
20
21 # Call the function with different types of animals
22 animal_sound ( dog ) # Output : Woof !
23 animal_sound ( cat ) # Output : Meow !
It enhances flexibility and the ability to use a single interface to represent different
underlying data types.
Modularity and Maintainability: OOP encourages a modular approach to pro-
gramming, where code is organized into classes and objects.
This modularity makes it easier to manage, maintain, and update code, as changes
can be made to individual classes without affecting the entire system.
Reusability: With OOP, classes and objects can be reused across different pro-
grams or within the same program.
It saves time and effort, as code that has already been tested
Minimalistic and Lightweight: Flask comes with a simple core and allows you to add
extensions as needed. This makes it lightweight and easy to use, with fewer dependencies
and a smaller footprint compared to more extensive frameworks.
Flexibility: Flask doesn’t enforce a specific project structure or require specific compo-
nents beyond those that are essential. This gives developers the freedom to organize their
code and project in the way they prefer.
Extensibility: Flask supports a wide range of extensions that add additional function-
ality, such as handling databases (SQLAlchemy), user authentication (Flask-Login), form
handling (Flask-WTF), and more. These extensions are typically easy to integrate.
9
2.4 Embedded Systems
An embedded system is a micro-controller or micro-processor based system which is de-
signed to perform a specific task. Its components are software and hardware. [1] Some
examples of embedded systems are a washing machine and air conditioner. The terms
microprocessor and microcontroller are defined below.
Microprosessor
A microprocessor is an integrated circuit (IC) that contains all the functions of a Central
Processing Unit (CPU).They can be used to do many complex tasks. They need other
components to complete some tasks or processes. These other parts are connected with
the processor using external connections.
Microcontroller
An embedded system is designed to perform a specific taskor a set of tasks until end of
life of the embedding device. The purpose of an embedded system is not intended to
be changed by the end user. Typically a redesign of an embedded system is necessary
if it must be used for another purpose. Thus an embedded system is a single-purpose
information processing system in contrast to computer which are commonly categorized
as general-purpose information processing. [1]
Tightly constrained
All computing systems have constraints on design metrics, but those on an embedded
system can be especially tight. Design metrics is a measure of an implementation’s
features such as its cost, size, power, and performance.An embedded system must be able
to work with limited resources (as required by the application).Unused resources are just
uselessly increasing the form size, the weight and the costs of the final product.
Many embedded systems must continually react to changes in the system’s environment
and must compute certain results in real time without any delay
10
Figure 2.1: Basic structure of an embedded system [1]
Sensor
Measures the physical quantity and converts it to an electrical signal which can be read
by an observer. A sensor stores the measured quantity to the memory.
A-D Converter
An analog-to-digital converter converts the analog signal sent by the sensor into a digital
signal.
Processor (CPU)
A processor can be thought of as the brain of the device. Processors process the data to
measure the output and store it to the memory.
D-A Converter
A digital-to-analog converter converts the digital data fed by the processor to analog data
Actuator
An actuator converts electrical signals into another (i.e. not-electrical) form of energy.
Digital Temperature and Humidity Sensor (DHT). It uses a capacitive humidity sensor
and a thermistor to measure the surrounding air, and spits out a digital signal on the
data pin.
UltraSonic Sensor
An ultrasonic sensor is an instrument that measures the distance to an object using ultra-
sonic sound waves. An ultrasonic sensor uses a transducer to send and receive ultrasonic
pulses that relay back information about an object’s proximity.
11
PIR Sensor
A passive infrared (PIR) sensor (Fig. 5) is an electronic sensor that measures infrared
(IR) light radiating from objects in its field of view. They’re most frequently utilized in
PIR-based motion detectors.
Rain Sensor
The Soil Moisture Sensor uses capacitance to measure dielectric permittivity of the sur-
rounding medium. In soil, dielectric permittivity is a function of the water content. The
sensor creates a voltage proportional to the dielectric permittivity, and therefore the water
content of the soil.
Soil temperature sensor is a device used to measure and monitor soil temperature.
MQ-135 sensor
The MQ-135 Gas sensor can detect gases like Ammonia (NH3), sulfur (S), Benzene
(C6H6), CO2, and other harmful gases and smoke.
LDR sensor
The Light Dependent Resistor (LDR). Its resistance changes as the amount of light falling
on it changes. The resistance of the LDR decreases with an increase in light intensity.
Servo Motor
A servo motor is defined as an electric motor that allows for precise control of angular
or linear position, speed, and torque. It consists of a suitable motor coupled to a sensor
for position feedback and a controller that regulates the motor’s movement according to
a desired setpoint.
LCD Screen
The LCD (Liquid Crystal Display) is an actuator it is a type of display that uses the
liquid crystals for its operation.
Buzzer
A buzzer is an actuator that is used for generating sound. It is commonly used in security
systems.
12
2.4.4 Embedded System Development Boards
A development board is a printed circuit board (PCB) that has a computer’s microchip
or microcontroller built in. It gives software and hardware developers a platform for
prototyping, developing, and testing apps or systems. These boards come with memory,
input/output ports, debugging facilities, and expansion options already built in. This
makes for a flexible, integrated testing environment.
Figure 2.2: The Arduino Uno R3 development board. Note Pins 0-13 are te digital In-
put/Output (I/O) pins
2.4.6 ESP32
The ESP32 is a versatile and widely-used microcontroller and Wi-Fi/Bluetooth system-
on-chip (SoC) produced by Espressif Systems. A SoC, is essentially an integrated circuit
that takes a single platform and integrates an entire electronic system onto it, for an
specific application. Contrary to a simple microcontroller (like Atmega328P Arduino
Uno), that offers several general usage peripherals instead of a specific set of tools for
one application. In the case of ESP32, this was designed to be an IoT SoC with already
integrated Wifi, Bluetooth, and Cryptographic hardware acceleration to allow the user to
access the internet. [5] Figure 2.3 below that specifies all its peripherals:
13
Figure 2.3: Peripherals of the ESP32
2.5 IoT
What is the IoT?
The Internet of Things (IoT) refers to a network of physical devices, vehicles, appliances,
and other physical objects that are embedded with sensors, software, and network con-
14
nectivity, allowing them to collect and share data.
IoT devices—also known as “smart objects”—can range from simple “smart home” de-
vices like smart thermostats, to wearables like smartwatches and RFID-enabled clothing,
to complex industrial machinery and transportation systems.
IoT enables these smart devices to communicate with each other and with other internet-
enabled devices. Like smartphones and gateways, creating a vast network of intercon-
nected devices that can exchange data and perform various tasks autonomously. This
can include:
Monitoring environmental conditions in farms
Managing traffic patterns with smart cars and other smart automotive devices
Controlling machines and processes in factories
Tracking inventory and shipments in warehouses
In an enterprise context, IoT devices are used to monitor a wide range of parameters such
as temperature, humidity, air quality, energy consumption, and machine performance.
This data can be analyzed in real time to identify patterns, trends, and anomalies that
can help businesses optimize their operations and improve their bottom line.
IoT is important for business for several reasons. Here are the core benefits of IoT:
Improved efficiency: By using IoT devices to automate and optimize processes,
businesses can improve efficiency and productivity. For example, IoT sensors can be
used to monitor equipment performance and detect or even resolve potential issues
before they cause downtime, reducing maintenance costs and improving uptime.
Data-driven decision-making: IoT devices generate vast amounts of data that
can be used to make better-informed business decisions and new business models.
By analyzing this data, businesses can gain insights into customer behavior, mar-
ket trends, and operational performance, allowing them to make more informed
decisions about strategy, product development, and resource allocation.
Cost-savings: By reducing manual processes and automating repetitive tasks, IoT
can help businesses reduce costs and improve profitability. For example, IoT devices
can be used to monitor energy usage and optimize consumption, reducing energy
costs and improving sustainability.
Enhanced customer experience: By using IoT technology to gather data about
customer behavior, businesses can create more personalized and engaging expe-
riences for their customers. For example, retailers can use IoT sensors to track
customer movements in stores and deliver personalized offers based on their behav-
ior.
15
as they allow machines and devices to interact with the physical world. Automa-
tion is possible when sensors and actuators work to resolve issues without human
intervention.
MicroControllers: See section 2.4
Connectivity technologies: To transmit IoT data from sensors and actuators
to the cloud, IoT devices need to be connected to the internet. There are several
connectivity technologies that are used in IoT, including wifi, Bluetooth, cellular,
Zigbee, and LoRaWAN.
Cloud computing: The cloud is where the vast amounts of data that is generated
by IoT devices are stored, processed, and analyzed. Cloud computing platforms
provide the infrastructure and tools that are needed to store and analyze this data,
as well as to build and deploy IoT applications examples include ThingsSpeak ,
Firebase real time database.
Big data analytics: To make sense of the vast amounts of data generated by
IoT devices, businesses need to use advanced analytics tools to extract insights
and identify patterns. These tools can include machine learning algorithms, data
visualization tools and predictive analytics models.
Security and privacy technologies: As IoT deployments become more widespread,
IoT security and privacy become increasingly important. Technologies such as en-
cryption, access controls and intrusion detection systems are used to protect IoT
devices and the data they generate from cyberthreats.
16
2.6.2 Data Validation and Cleaning
In order to answer the research question we must have a data set. Data preparation
accounts for about 80% of the work of data scientists. Data cleaning involves identifying
any issues with our data and confirming our qualitative understanding of the data. In
this step we check for
Missing Data Is there missing data? Is it missing systematically? This can be
resolve by dropping missing observations, populating missing values with average
of available data or using data imputation techniques.
Time Series Validation If we have observations over time, we need to do time
series validation. We ask question like: Is the data for the correct time range? Are
there unusual spikes in the data over time? If the spike is isolated it is probably
unexpected, we may want to remove the corrupted data. For example, if for one
month sales are recorded in Uganda Shillings rather than US dollars, it would inflate
sales figures. We should do some data cleaning by converting to $ or perhaps remove
this month. Note, sometimes there are natural anomalies in data that should be
investigated first.
Data Type Are all variables the right type? Is a date treated like a date. Many
functions in Python are type specific, which means we need to make sure all of our
fields are being treated as the correct type:
Data Range Are all values in the expected range? For example, Are all loan amounts
greater than 0?
2.6.4 Modeling
Once we have a research question we can begin the modeling step. Machine Learning
happens in this phase. All models have 3 key components: a task, a performance measure
17
and a learning methodology. [7]
Task
A ML task is formed from the research question and a set of relevant historical records
also known as a dataset. The columns in the dataset are known as features while the
rows are observations. A ML task has explanatory features and an outcome feature. For
example if we want to determine whether a person will buy a car or not, the explanatory
features could be income and location while outcome feature would be ’Yes’ or ’No’.
A ML task also has a model function f(x) + e = Y* where x is the explanatory feature
, e is the irreducible error and Y* is the predicted outcome feature. The function f(x)
tries to map Y* as close the true Y as possible. The f(x) depends on the ML algorithm
we choose as well as the datatype we want to predict and the learning methodology. For
the supervised learning methodology algorithms fall into two main categories namely;
regression and classification. Regression is used when we want to predict a numerical
value and classification when we want to predict whether something belongs to a category.
Examples of regression algorithms are linear regression and polynomial regression while
for classification algorithms we have random forest and xgboost.
Learning Methdology
Performance Measure
Loss functions are used to measure the performance of a model. A loss function quantifies
the difference between the true Y and the predicted Y*. The goal of the model is to
minimize the lose function as much as possible. The loss function used depends on the
type of task .
For regression tasks we have
Absolute Error:Also called L1 loss, this minimizes the sum of absolute errors
between
Pn True Y and predicted Y*. It is given as
S = i=1 |yi − f (xi )|
Least Squares Error:Also called L2 loss, this minimizes the square of the error
between
P True Y and predicted Y*. It is given as
S = ni=1 |(yi − f (xi ))2 |
Mean Square Error(MSE): Takes the mean of the L2 loss over all observations.
M SE = mean(S)
Root Mean Squared Error(RMSE):Takes the square root of the mean of the
L2 loss. p
RM SE = (mean(S))
For classification tasks we have
18
Log Loss: Log loss evaluates the probability of belonging in a class. For every
predictionPnthe model makes, we can measure the logarithmic loss. It is given by
1
L = − n i=1 [yi log(y∗i ) + (1 − log(yi ) log(1 − y∗i )]
The smaller the log loss, the smaller the uncertainty, the better the model.A perfect
classifier would have log loss = 0.
Hinge Loss: This is the logical extension of the regression loss function, absolute
loss.
Absoluteloss = y − y∗, where y and y* are integers.
Hingeloss = max(0, 1 − (y∗)(y)) where Y can equal -1 (no) or 1 ( yes) for each
class. For each observation, if Y* == Y (both are 1 or both are -1), hinge loss = 0.
If Y =/= Y*, hinge loss increases. The cumulated hinge loss is therefore the upper
bound of the number of mistakes made by the classifier.
Log Loss leads to more exact probabilities, but at the cost of accuracy while hinge
loss leads to better accuracy,but at the cost of exact probabilities.
For a problem for example where we are trying to assess patient health, we know
that false positives (the model predicts you do have malaria, but you actually don’t)
are safer and generally more preferable than false negatives (the model predicts you
don’t have malaria, but you actually do.) Therefore it is probably safer to evaluate
our output as a probability of whether or not you have malaria. We will use log
loss. [7]
Solar panels, or photovoltaic (PV) modules, are the heart of a solar PV system. They
convert sunlight directly into electrical energy using semiconductor materials, typically
silicon. Each panel consists of multiple solar cells connected in series or parallel, gener-
ating direct current (DC) electricity that powers the system.
Inverters
Inverters are critical for converting the DC electricity produced by the solar panels into
alternating current (AC) electricity, which is the standard form used in most home and
commercial electrical systems. Types of inverters include string inverters, microinverters,
and power optimizers, each suited to different system configurations and requirements.
19
Batteries
Batteries store surplus electricity generated by the solar panels, providing power when
sunlight is not available, such as at night or during cloudy days. They ensure a continu-
ous power supply and include options like lead-acid and lithium-ion batteries, each with
specific capacities and lifespans.
Charge Controllers
Charge controllers manage the voltage and current from the solar panels to the batteries,
preventing overcharging and excessive discharging. They are crucial for maintaining bat-
tery health and performance by ensuring that the batteries receive the correct amount of
power.
Mounting Systems
Mounting systems secure the solar panels to rooftops or ground structures. They include
racks, brackets, and supports that position the panels at the optimal angle and orientation
for maximum sunlight exposure. Proper installation of mounting systems is essential for
the system’s efficiency and durability.
Monitoring Systems
Monitoring systems provide real-time data on the performance of the solar PV system,
including energy production, consumption, and system health. They help in detecting
issues early, optimizing system performance, and ensuring that the system operates effi-
ciently. Monitoring can be achieved through dedicated hardware or software applications.
20
3 WORK DONE
This chapter elaborates on the work done during the industrial training at netlabsUG!
Implementation of LMS
We took advantage of the mutable data structures of dictionary and list. Each book was
stored as a dictionary with the keys;-Author,Title,ISBN,Availability. The library catalog
was a list of dictionaries. We used the append and remove methods of the list to add or
remove books as shown in fig 3.1. We used the iterable sequence feature of python lists
to iterate and find a book according to a given key see fig 3.2.
21
We used the file management feature of python to persist the catalog data in the form of
a JSON file as shown in fig 3.3
Finally when all features and error handling had been coded into the application a main
loop where users can interact with the system, choosing options to add books, drop books,
borrow or return books, and search the catalog as shown in fig 3.4.
Testing
When we tested the application. It run as expected and gave satisfactory results as shown
in fig 3.5 and 3.6.
Figure 3.6: Persisted data in JSON file. The new record is highlighted.
22
3.1.2 University Management System (UMS)
The UMS was a lager application compared to the LMS it had the following features.
User Interface:
– Dynamic Text-Based Interface
Course Management Features:
– Add New Course
– Remove Course
– Update Course
– Search Course
– View All Courses
Student Management Features:
– Add New Student
– Remove Student
– Update Student
– Search Student
– View All Students
Enrollment Management Features:
– Enroll Student in Course
– Drop Student from Course
– View Enrollments
Data Storage:
– Dictionaries
Functions and Modular Programming:
– Modular Code
Error Handling:
– Comprehensive Error Handling
Data Persistence:
– Saving and Loading Data
Implementation
I implemented it in the same way as the LMS.I used dictionaries to store courses, students,
and enrollments then stored each dictionary in a list. For Data persistence JSON files
were used.
Testing
23
Figure 3.7: UMS Menu
Conclusion
I came to the conclusion that python is indeed a robust yet simple programming language
that can be used to build complete applications with a few lines of code.
24
Implementation
I defined several classes that represent the key entities in the system: Book and Library.
Book Class
Library Class
The Library class manages the collection of books in the library and handles user inter-
actions.
Attributes:
– catalog: A dictionary of Book objects, keyed by their ISBN.
Methods:
– add book(book): Adds a new book to the catalog.
– drop book(isbn): Removes a book from the catalog by its ISBN.
– borrow book(isbn): Allows a user to borrow a book, marking it as unavail-
able.
– return book(isbn): Allows a user to return a book, marking it as available.
– search books(query, attribute): Searches for books by a specific attribute
(e.g., author, title, isbn).
25
– save catalog(): Saves the catalog data to persistent storage (e.g., JSON file).
– load catalog(): Loads the catalog data from persistent storage.
Data Persistence
The Library class includes methods (save catalog() and load catalog()) for sav-
ing the catalog to a JSON file and loading it back. This ensures that the data persists
between sessions.
Testing
The application worked like the one in section 3.1.1. The only difference was the imple-
mentation.
Implementation
26
SocialMediaPlatform Class: Manages users, posts, likes, and comments. Includes
methods for creating and managing content and interactions.
Testing
Conclusion
Implementation in OOP makes a sofware more scalable, maintainable, and easier to man-
age because of polymorphism,encapsulation and inheritance.
27
and the cathode is connected to the ground of the Arduino. Th code in the Arduino IDE
is uploaded onto the micro -controller . The code periodically sends a digital HIGH to
pin. Then a LOW after seconds . This causes the LED to blink.
The LED cathodes are connected to a common ground however each anode is connected
to a different pin on the Arduino board. The code uploaded onto the micro-controller
systematically sends a HIGHs and LOWs to each output pin causing the LEDs to Light
on and off in order mimicking a traffic light system.
The code uploaded onto the micro-controller takes the sensor reading and calculates a
distance in cm. If the value calculated is below a threshold , 20cm in this case, the LED
28
will blink as a warning. The blinking LED logic is the same as that in section 3.3.1
Adding a Buzzer
We built onto this circuit by adding a buzzer to output a sound once the calculated value
was below the 20 cm threshold.
A person approaching the door would read a message on the LCD requesting for a pulse
reading. Once the oxygen level was found to be at an optimal level of 95% or above the
servo motor would be activated to open the door. If oxygen level was found to be less
than 95% an ’access denied’ message would be displayed on the screen.
29
Figure 3.16: ESP32 circuit with DHT sensor.
Figure 3.17: Humidity and Temperature data collecteted from circuit in fig 3.16 recorded
on the ThingsSpeak IoT platform.
30
Figure 3.19: PCB design for circuit in fig 3.16.
Then we used a linear regression model to determine the loan amount a person in a
specific country and business sector could take as shown in fig. 3.21 and 3.22. The RMSE
falls within a good range of 0.2 - 0.5. Therefore the model performed quite well.
31
Figure 3.22: Scatter plot and residuals distribution of predictions.
I deployed the linear regression model to a web app using the Flask framework as shown
in fig 3.23.
Figure 3.23: Loans prediction form.The user enters the required field and the app predicts
a loan amount.
32
3.7 Solar PV Systems Design and Maintenance
netLabsUG! partnered with CREEC to give us a 5 day training on solar PV systems
design and maintenance. Topics covered included components of a solar pv system, solar
irradiation , design and sizing. We also had practical sessions on the topics learned as
shown in figs 3.24,3.25 and 3.26.
33
3.8 CapStone Project
To conclude our sessions we were given a project to create a prototype for an e-farm
code named TerraNova. The E-farm was to have the following features; microclimate
characterization, pest surveillance, irrigation management and enhanced security. To
achieve these objectives, we designed an advanced system integrating ESP32 microcon-
troller boards, soil moisture, rain, temperature, air quality, PIR, ultrasonic and light
intensity sensors, Machine Learning (ML) algorithms, a web application for real-time
visualizations, Bluetooth for remote control, and actuators.
34
Figure 3.27: system architecture for e farm prototype.
2. Irrigation Management
35
Figure 3.28: Module for micro-climate and pest surveillance with the MQ-135 gas sensor
that captures ammonia and carbon dioxide levels which are indicators of pest
activity and a DHT sensor for ambient temperature and humidity levels.
3. Night Security
4. Power Management
We configured each sensor node to utilize sleep modes to reduce power consumption
when not actively collecting data or communicating.
36
Figure 3.29: Code Block in Arduino IDE to implement a central gateway using ESPNOW
communication protocol.
We preprocessed the provided dataset, ensuring data integrity and handling any
missing values or outliers. We also selected relevant features for ML model training.
37
2. Exploratory Data Analysis
3. Model Training
We converted the trained ML model to a format compatible with the ESP32 and
deployed it on the ESP32 to enable on-device predictions.
38
Figure 3.32: The web application.
We integrated the web application with the real-time database to fetch and display
the latest sensor data and ML model predictions.
39
Figure 3.35: Th Firebase database.
We ensured the web application had a responsive layout compatible with various
devices (e.g., smartphones, tablets, and computers) and optimized the user interface
for a seamless and intuitive user experience.
40
4 OBSERVATIONS,
CHALLENGES,
RECOMMENDATIONS AND
CONCLUSIONS
4.1 Observations
My experience learning python was quite eye opening. I found it simple and yet powerful.
Having proficiency in other programming languages , python was never my go to choice
for any project. However this internship has given me an appreciation and understanding
of the popularity of python. The many libraries available make it a good option for quick
application development.
Learning embedded systems further opened my eyes to the limitless possibilities of craft-
ing solutions with technology. I appreciated the simplicity and usefulness of IoT to solve
real world problems. I was fascinated by the interaction of software and hardware to
automate processes and get work done.
Machine learning was another interesting area. I realized that data can be used to answer
questions and make tailor made solutions for the same problem. Furthermore it can be
used to obtain insights in many areas like commerce, medicine and much more. I will
definitely be exploring more in the area of data science.
The solar training at CREEC gave me an appreciation of the technical skills required
for setting up and managing solar pv systems. I was impressed by the potential of solar
power to contribute to a sustainable future, and this training has motivated me to explore
further opportunities in the renewable energy sector.
4.2 Challenges
The only challenge I faced during this internship was its intensity. Keeping up with the
many assignments and readings to further expand on what we were given during the
sessions required effort and commitment but it was very worth while.
4.3 Recommendations
I have no recommendations, as I found the internship program at netLabs!UG to be
satisfactory. My expectations were not just met but exceeded in every way.
41
4.4 Conclusions
In conclusion, this internship has been an invaluable experience. The challenges and in-
tensity were demanding, but they provided a rich opportunity for growth and learning.
The hands-on experience with Python, embedded systems, machine learning and solar
technology has broadened my technical skills and deepened my appreciation for these
fields. I have proudly added this new set of skills to my curriculum vitae.
42
REFERENCES
[1] W. Okello, “Embedded systems handout,netlabsug,” 2024.
[2] T. KadduMukasa, “Python programming handout, netlabsug!” 2024.
[3] I. Kamusiime, “Oop programming handout, netlabsug!” 2024.
[4] Arduino-Docs. (2024) Uno r3. [Online]. Available: https://docs.arduino.cc/hardware/
uno-rev3/
[5] Nick. (2024) The esp32 chip explained: Advantages and applications. [Online]. Avail-
able: https://www.deepseadev.com/en/blog/esp32-chip-explained-and-advantages/
[6] Data-Analytics. (2015) Introduction to machine learning. [Online]. Available:
https://github.com/DeltaAnalytics/machine learning for good
[7] ——. (2015) Machine learning deepdive. [Online]. Available: https://github.com/
DeltaAnalytics/machine learning for good
43
APPENDICES
Appendix A: Certification
44
Figure 3: Graduation ceremony at netLabsUG!.
45
46
47