0% found this document useful (0 votes)
28 views56 pages

Net Labs UGReport

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views56 pages

Net Labs UGReport

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

COLLEGE OF ENGINEERING, DESIGN, ART AND TECHNOLOGY

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

INDUSTRIAL TRAINING REPORT

TRAINING PERIOD : 4TH JUNE 2024 - 2ND AUGUST 2024

NAMUBIRU CONSTANCE
21/U/22161/PS

BACHELOR OF SCIENCE IN ELECTRICAL ENGINEERING

Supervisor: Ms. Agatha Turyagyenda

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

4 OBSERVATIONS, CHALLENGES, RECOMMENDATIONS AND CON-


CLUSIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.1 Observations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.2 Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.3 Recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.4 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

REFERENCES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

APPENDICES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

V
List of Acronyms

DHT Digital Humidity and Temperature

GP I/O General Purpose Input Output

IC Intergrated Circuit

IDE Intergrated Development Enviroment

IoT Internet of Things

I/O Input Output

JSON JavaScript Object Notation

LCD Liquid Crystal Display

LMS Library Management System

ML Machine Learning

OOP Object Oriented Programming

PCB Printed Circuit Board

PIR Passive Infrared

UMS University Management System

VI
List of Figures

1.1 Company organogram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.1 Basic structure of an embedded system [1] . . . . . . . . . . . . . . . . . . 11


2.2 The Arduino Uno R3 development board. Note Pins 0-13 are te digital
Input/Output (I/O) pins . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3 Peripherals of the ESP32 . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.4 Arduino IDE interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.5 Steps involved in machine learning. . . . . . . . . . . . . . . . . . . . . . . 16

3.1 Code block to add a book to library . . . . . . . . . . . . . . . . . . . . . . 21


3.2 Code block to search for a book in the library . . . . . . . . . . . . . . . . 21
3.3 Code block to read and write to JSON file. . . . . . . . . . . . . . . . . . . 22
3.4 Code block for interactive menu. . . . . . . . . . . . . . . . . . . . . . . . . 22
3.5 Running the the LMS application. . . . . . . . . . . . . . . . . . . . . . . . 22
3.6 Persisted data in JSON file. The new record is highlighted. . . . . . . . . . 22
3.7 UMS Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.8 Veiwing available courses on UMS. . . . . . . . . . . . . . . . . . . . . . . 24
3.9 Searching for a student by Major. . . . . . . . . . . . . . . . . . . . . . . . 24
3.10 Code block implementing book class. . . . . . . . . . . . . . . . . . . . . . 25
3.11 Code block implementing library class. . . . . . . . . . . . . . . . . . . . . 26
3.12 social media platform application. . . . . . . . . . . . . . . . . . . . . . . . 27
3.13 Traffic light circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.14 Proximity sensor circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.15 Door access circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.16 ESP32 circuit with DHT sensor. . . . . . . . . . . . . . . . . . . . . . . . . 30
3.17 Humidity and Temperature data collecteted from circuit in fig 3.16 recorded
on the ThingsSpeak IoT platform. . . . . . . . . . . . . . . . . . . . . . . . 30
3.18 Schematic for circuit in fig 3.16. . . . . . . . . . . . . . . . . . . . . . . . . 30
3.19 PCB design for circuit in fig 3.16. . . . . . . . . . . . . . . . . . . . . . . . 31
3.20 RMSE for the model result. . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.21 RMSE for the model result. . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.22 Scatter plot and residuals distribution of predictions. . . . . . . . . . . . . 32
3.23 Loans prediction form.The user enters the required field and the app pre-
dicts a loan amount. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.24 In class session. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.25 Tour of solar pv system at CREEC. . . . . . . . . . . . . . . . . . . . . . . 33
3.26 Practical session. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.27 system architecture for e farm prototype. . . . . . . . . . . . . . . . . . . . 35
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. 36

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

1 Certificate awarding ceremony at CREEC. . . . . . . . . . . . . . . . . . . 44


2 Receiving my certificate for solar systems design and maintenance. . . . . . 44
3 Graduation ceremony at netLabsUG!. . . . . . . . . . . . . . . . . . . . . . 45
4 Receiving my certificate for the internship at netLabsUG!. . . . . . . . . . 45

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.1 Background of the Internship


The College of Engineering, Design, Art, and Technology at Makerere University man-
dates its second and third-year students to engage in an internship training period within
companies related to their field of study. The goal is to equip students with valuable skills
and experiences that will enhance their professional development.
By the conclusion of the internship period, it is expected that students will have acquired
the following skills:
ˆ Effective Communication:
Students should be adept at communicating efficiently with their colleagues and
supervisors about the activities they have been engaged in during their internship.
Clear and concise communication is essential for sharing progress, seeking guidance,
and collaborating effectively within the workplace.
ˆ Ethical Work Practices:
Students are expected to display and practice high standards of work ethics. This
involves conducting themselves professionally, adhering to company policies, demon-
strating integrity, and maintaining a responsible and accountable approach to their
tasks.
ˆ Organizational Skills:
Students should develop and showcase strong organizational skills, both individually
and within a group context. This includes efficient time management, prioritization
of tasks, and contributing to the overall effectiveness and productivity of the team.
ˆ Creativity and Innovation:
Interns are encouraged to apply creative thinking and innovative problem-solving
approaches to real-life projects. This fosters an environment of continuous im-
provement and allows students to contribute fresh perspectives and ideas to the
workplace.
ˆ Independent Work and Self-Supervision:
The internship experience aims to cultivate the ability of students to work inde-
pendently or with minimal supervision. This involves taking ownership of their

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 netLabsUG! Company Details


1.2.1 Nature of the Business
netLabs!UG is a research Centre of Excellence(CoE) in telecommunications and network-
ing technologies who had its origins in the Community Wireless Resource Centre(CWRC),
Department of Electrical and Computer Engineering, College of Engineering Design, Art
and Technology(CEDAT) at Makerere University. netLabs!UG is an alternative Research
and Development(R&D) model which will strive to achieve a balanced critical mass of
basic research, applied research and commercialization.
ˆ Network design and implementation
ˆ Software development and testing
ˆ IT consulting and training
ˆ Research and innovation in ICT

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

Figure 1.1: Company organogram.

1.3 Objectives of the Internship


The main objective of the internship was to develop an IoT(Internet of Things) solution to
solve a real world problem. This involved utilizing a range of technologies namely;python
programming language,an embedded system, flask web application framework, machine
learning with python , sensors and actuators. We also attended a 5 day solar pv systems
design and maintenance training at CREEC, Makerere University.
The internship program was always onsite and included theoretical classes,in class prac-
tical training and take home assignments.

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.

2.1 Python Programming Language


2.1.1 Syntax
Python’s syntax emphasizes simplicity and readability by using indentation to define code
blocks, which enhances code clarity and reduces syntactical noise compared to languages
that use braces {}. [2] For example:
1 if x > 5:
2 print ( " x is greater than 5 " )
3 else :
4 print ( " x is not greater than 5 " )
5

2.1.2 Variables and Simple Data Types


Simple data types in python include string , int , float,boolean and complex. A variable
is like a container that holds a value, which can be of different types.Variables in Python
are dynamically typed, allowing flexibility in programming and making it easier to write
and maintain code. However this requires careful variable management For example:
1 age = 25 # int
2 age = 0.2 # now has changed to float
3 name = " John Doe " # string
4 isactive = True # boolean
5 voltage = 2 + j5 # complex
6

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

6 # immutable type : tuple


7 cars = [ ’ Mazda ’ , ’ Honda ’ , ’ Toyota ’]
8 # cars [0] = ’ Mercedes ’ # TypeError : ’ tuple ’ object does not support
item assignment
9

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.5 Control Flow


Control flow structures like if, elif, else statements and loops (for, while) enable
developers to control the execution flow based on conditions and iterate through data
structures efficiently. This capability is crucial for implementing algorithms and handling
various scenarios in programs. For example:
1 for i in range (1 , 6) :
2 if i % 2 == 0:
3 print ( f " { i } is even " )
4 else :
5 print ( f " { i } is odd " )
6

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

2.1.7 Modules and Packages


Python’s modular design with modules and packages allows developers to organize code
into reusable components. This modularity promotes code organization, enhances col-
laboration among team members, and supports scalable application development. For
example:
1 # Example of using modules and packages
2 # Assuming mymodule . py contains a function greet ()
3 import mymodule
4

5 message = mymodule . greet ( " Bob " )


6 print ( message ) # Output : Hello , Bob !
7

2.1.8 Input and Output


Input and output functions (input() and print()) in Python enable interaction with
users and facilitate displaying information, making Python suitable for developing inter-
active applications and user interfaces. For example:
1 # Example of input and output
2 name = input ( " Enter your name : " )
3 print ( f " Hello , { name }! " )
4

2.1.9 Exception Handling


Exception handling (try, except, finally) in Python allows developers to gracefully
manage errors and exceptions, ensuring that programs continue to run smoothly even
when unexpected issues arise. For example:
1 # Example of exception handling
2 try :
3 result = 10 / 0 # Raises Ze roDivi sionEr ror
4 except Ze roDivi sionEr ror as e :
5 print ( " Error : " , e )
6 else :
7 print ( " Result : " , result )
8 finally :
9 print ( " Execution completed . " )
10

2.1.10 File Handling


Python’s file handling capabilities (open(), read(), write(), close()) provide robust
support for working with files, facilitating data storage, retrieval, and manipulation op-
erations in applications. For example:

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

2.2 Object Oriented Programming (OOP)


Python is an object oriented programming language. Object-Oriented Programming
(OOP) is a programming paradigm based on the concept of ”objects,” which can contain
data and code that manipulates the data.

2.2.1 Classes: The Blueprints


In OOP, a class is a template that defines the structure and behavior of objects. It serves
as a blueprint, outlining the properties (attributes) and actions (methods) that an object
can possess. [3]
1 # Example of a class
2 class Person :
3 def __init__ ( self , name , age )
4 self . name = name
5 self . age = age
6

ˆ 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

7 new_person = Person ( ’ John Doe ’ , 28) # object of class Person


8 print ( f ’ This is { newperson . name } , he is { new_person . age } years old ’)
9 # output
10 # This is John Doe , he is 28 yrs old

2.2.3 Attributes and Methods


Attributes are the data or properties associated with an object, while methods are the
functions that define the object’s behavior. Together, they encapsulate the object’s state
and actions.

2.2.4 Advantages of OOP


Object-Oriented Programming (OOP) offers several advantages over procedural program-
ming, primarily due to its structure and way of managing data and behavior. Below are
some key advantages of OOP:
ˆ Encapsulation: This is the bundling of data (attributes) and methods (functions)
that operate on the data into a single unit, called a class. This helps protect the
data from outside interference and misuse.
It improves security and modularity, allowing changes to be made to one part of
the code without affecting others.
ˆ Abstraction: This allows the programmer to hide complex implementation details
and show only the necessary features of an object.
It reduces complexity and allows the programmer to focus on interactions at a higher
level, rather than worrying about the internal workings.
ˆ Inheritance: This allows a new class (child class) to inherit attributes and methods
from an existing class (parent class).
It promotes code reuse, reduces redundancy, and enables a hierarchical classification,
which makes it easier to manage and extend code.
ˆ Polymorphism: This allows methods to be used in different ways depending on
the objects they are called on, typically through method overloading or overriding.

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

2.3 Flask Web Framework


Flask is a lightweight and flexible web framework for Python that is designed to help de-
velopers build web applications quickly and easily. It is considered a ”micro” framework
because it provides the basic tools needed to build a web application without the com-
plexity of a larger framework like Django. Here are some key features and characteristics
of Flask:

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

A microcontroller is an IC that contains a CPU, Memory, I/O peripherals all integrated


into one chip. They are designed to do a specific task or any assigned task in loops. You
need some special tools to upload the program on the controller chips. Once the code is
uploaded on the chip we don’t need to upload it once again on the chip unless and until
we want our microcontroller to do another task.

2.4.1 Characteristics of an Embedded System


Single-functioned

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.

Reactive and Real time

Many embedded systems must continually react to changes in the system’s environment
and must compute certain results in real time without any delay

2.4.2 Basic Structure of an Embedded System


Figure 2.1 below shows the basic structure od an embedded system

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.

2.4.3 Sensor and Actuator Examples


DHT

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

A rain sensor or rain switch is a switching device activated by rainfall.

Soil Moisture 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

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.

2.4.5 Arduino UNO R3


Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital
input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16
MHz ceramic resonator, a USB connection, a power jack, an ICSP header and a reset
button. It contains everything needed to support the microcontroller; simply connect it
to a computer with a USB cable or power it with a AC-to-DC adapter or battery. [4]

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

The ESP32 board has 36 General Purpose I/O (GPIO) pins.

2.4.7 Arduino IDE


The Arduino Integrated Development Environment Arduino IDE) is an open-source soft-
ware, which is used to write and upload code to the Arduino boards. [4]

Figure 2.4: Arduino IDE interface

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.

Why is IoT important?

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.

The technologies that make IoT possible

Several technologies come together to make IoT possible.


ˆ Sensors and actuators: Sensors are devices that can detect changes in the en-
vironment, such as temperature, humidity, light, motion, or pressure. Actuators
are devices that can cause physical changes in the environment, such as opening
or closing a valve or turning on a motor. These devices are at the heart of IoT,

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.

2.6 Machine Learning with Python


We call something machine learning when instead of telling a computer to do something,
we allow a computer to come up with its own solution based upon the data it is given.
It is a subset of AI that allows machines to learn from raw data. Machine learning is
interdisciplinary. It involves Computer science , statistics and mathematics. It uses data
to help us answer questions. [6] Figure 2.5 shows the steps involved in a machine learning
process.

Figure 2.5: Steps involved in machine learning.

2.6.1 Research Question


A research question is the question we want our model to answer. Examples of research
questions are
ˆ Does this patient have malaria?
ˆ Can we monitor illegal deforestation by detecting chainsaw noises in audio streamed
from rain forests ?
We may have a question in mind before we look at the data, but we will often use our
exploration of the data to develop or refine our research question.

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.3 Exploratory Data Analysis


The goal of exploratory analysis is to better understand your data. Exploratory analysis
can reveal data limitations, what features are important, and inform what methods you
use in answering your research question. This is an indispensable first step in any data
analysis. [6] We explore the data to see what models are suitable and what patterns we can
identify. The process varies depending on the data, your style, and time constraints,but
typically exploration includes:
ˆ Histogram: A histogram shows the frequency distribution of a continuous feature.
ˆ Scatter plots: Scatter plots visualize relationships between any two features as
points on a graph.
ˆ Correlation tables: Correlation is a useful measure of the strength of a relation-
ship between two variables. It ranges from -1.00 to 1.00. 1.00 indicating a strong
correlation.
ˆ Summary statistics: Mean, median, frequency are useful summary statistics that
let you know what is in your data.
ˆ Box plots: Box-plots are a useful visual depiction of certain summary statistics.
Recalling from section 2.5.2 We may have a question in mind before we look at the data,
but our exploration of the data often develops or refines our research question.

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

The two learning methodologies in ML are supervised and unsupervised. During my


internship we focused on the former.
ˆ Supervised The outcome feature is recorded within the data. For every x there is
a Y. The goal is to predict Y using x.
ˆ Unsupervised The outcome feature is not recorded within the data. For every x
there is no Y. The goal is not to predict Y using x but to evaluate x.

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 vs Hinge Loss

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]

2.7 Solar PV Systems


A Solar PV (Photovoltaic) System is a technology that converts sunlight into electrical
energy using the photovoltaic effect. This system is commonly used to generate clean,
renewable energy for various applications, ranging from residential and commercial build-
ings to large-scale solar power plants.

2.7.1 Components of a Solar PV System:


Solar Panels

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.

2.7.2 Solar Irradiation


Solar irradiation refers to the amount of solar power received per unit area at a specific
location on Earth. It is a measure of the intensity of sunlight that reaches a given surface
and is usually expressed in watts per square meter (W/m²). Solar irradiation can vary
based on factors such as geographic location, time of day, season, and weather conditions.
Understanding solar irradiation is crucial for designing and optimizing solar PV systems,
as it helps determine the potential energy output and efficiency of solar panels. Higher
solar irradiation means more sunlight is available for conversion into electrical energy,
improving the performance of solar energy systems.

2.7.3 Design and Sizing


Design and sizing of a Solar PV system involves determining the appropriate configura-
tion and capacity of the system’s components to meet specific energy needs efficiently.
This process includes calculating the number of solar panels, battery storage capacity,
and inverter size based on energy consumption, solar resource availability, and system
requirements. The goal is to ensure the system can generate and supply the required
amount of electricity effectively and reliably.

20
3 WORK DONE
This chapter elaborates on the work done during the industrial training at netlabsUG!

3.1 Introduction to Programming with Python


We were taken through a number of sessions to teach us about syntax in python ,variables,
simple data types, data structures , operators , control flow, functions, modules and
packages , input and output,exception handling and file handling. At the completion of
te sessions we were given two projects. the first was to build a library management system
in python in groups of two and the second was to build a university management system
in python individually.

3.1.1 Library Management System (LMS)


The LMS we built had the following features;add books to the library catalog, drop
books from the catalog, borrow a book, return a book , update availability of a book
when borrowed to ’unavailable’ or ’available’ when returned , search for a book using one
of the properties ; author, title,ISBN, data persistence.

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.

Figure 3.1: Code block to add a book to library

Figure 3.2: Code block to search for a book in the library

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

Figure 3.3: Code block to read and write to JSON file.

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.

Figure 3.4: Code block for interactive menu.

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.5: Running the the LMS application.

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

The application run as expected as show in Figures 3.7,3.8,and 3.9.

23
Figure 3.7: UMS Menu

Figure 3.8: Veiwing available courses on UMS.

Figure 3.9: Searching for a student by Major.

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.

3.2 Introduction to OOP in Python


After completing the above basic python projects we were taken a step further into
OOP programming with python. The learning sessions included the following concepts;
classes,attributes,class methods,inheritance, polymorphism, abstraction, access modifiers
and decorators. We were then given group assignments on two projects.An LMS and a
social media platform.

3.2.1 LMS using OOP


The LMS had the same features as the one described in section 3.1.1.

24
Implementation

I defined several classes that represent the key entities in the system: Book and Library.
Book Class

The Book class represents a book in the library.


ˆ Attributes:
– isbn: The unique ISBN of the book.
– title: The title of the book.
– author: The author of the book.
– availability: A boolean attribute indicating if the book is available for
borrowing (True for available, False for unavailable).
ˆ Methods:
– borrow(): Sets the availability to False.
– return book(): Sets the availability to True.
– str (): Provides a string representation of the book details.

Figure 3.10: Code block implementing 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.

Figure 3.11: Code block implementing library class.

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.

3.2.2 Social Media Platform


We were tasked to create a comprehensive social media platform in Python that manages
users, posts, likes, and comments.

Implementation

I created five classes: User, Post, Comment, Like, and SocialMediaPlatform.

Class Descriptions and Methods:


ˆ User Class: Represents a user with attributes like username and a list of posts
created by the user. Includes methods to create posts and interact with other users’
posts.
ˆ Post Class: Represents a post with attributes such as content, author, likes, and
comments. Includes methods to add likes and comments.
ˆ Comment Class: Represents a comment on a post, with attributes for the content,
author, and post it belongs to.
ˆ Like Class: Represents a like on a post, with attributes for the user who liked the
post and the post it belongs to.

26
ˆ SocialMediaPlatform Class: Manages users, posts, likes, and comments. Includes
methods for creating and managing content and interactions.

Testing

The application worked as expected as shown in fig 3.12

Figure 3.12: social media platform application.

Conclusion

Implementation in OOP makes a sofware more scalable, maintainable, and easier to man-
age because of polymorphism,encapsulation and inheritance.

3.3 Introduction to Embedded Systems with


Arduino UNO
We had an instructor take us through the basics of embedded systems. The topics taught
were what are embedded systems, examples, characteristics , basic structure, micro-
controllers vs microprocessors, actuators, sensors, Arduino Uno development board,Arduino
IDE. The classes we both theoretical and practical with some take home projects.We
started with basic circuits and moved on to more complex circuits as enumerated in the
following sections.

3.3.1 Blinking LED Circuit


We used the Arduino UNO board and Arduino IDE to construct a circuit with an au-
tomatically blinking LED. The LED’s anode is connected to the Aruino Digital I/O pin

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.

3.3.2 Traffic Light Circuit


This circuit builds onto the cicuit in section 3.3.1. It uses three LEDs as shown in fig
3.13.

Figure 3.13: Traffic light circuit.

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.

3.3.3 Proximity Sensor Circuit


For this circuit we used an UltraSonic sensor and a LED as shown in fig 3.14

Figure 3.14: Proximity sensor circuit.

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.

3.3.4 Door Access Circuit


For this circuit we used a pulse oximeter , an LCD and a servo motor as shown in fig
3.15.

Figure 3.15: Door access circuit.

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.

3.4 Introduction to IoT with ESP32


We learnt about IoT with the ESP32. Topics included connecting it as a web server,
workstation, Bluetooth connectivity, uploading sensor readings to ThingSpeak IoT plat-
form, up loading data to Firebase real time database, using the ESPNOW protocol to
communicate between multiple ESP32s.

3.4.1 DHT Circuit to Upload Data to the ThingSpeak IoT


Plaform
We buit a circuit to capture ambien temperature and humidity readings and upload them
to the ThingsSpeak IoT platform as shown in figs 3.16 and 3.17.

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.

3.5 Introduction to PCB Design


Our instructor took us through a series of video tutorials on PCB design with KiCAD.
we then designed a PCB for the circuit in fig 3.16 as shown in the figs 3.18 and 3.19

Figure 3.18: Schematic for circuit in fig 3.16.

30
Figure 3.19: PCB design for circuit in fig 3.16.

3.6 Introduction to Machine Learning


The sessions for machine learning included Forming a research question, data validation
and cleaning , Exploratory Data Analysis , Modeling and performance measurement. We
used a sample loans dataset with the xgboost classifier to predict whether a person has a
bank account or not. Fig 3.20 shows the confusion matrix for the xgboost classifier with
0 meaning No and 1 meaning Yes. The model performs well on predicting class 0 and
performs poorly on predicting class 1.

Figure 3.20: RMSE for the model result.

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.

Figure 3.21: RMSE for the model result.

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.

Figure 3.24: In class session.

Figure 3.25: Tour of solar pv system at CREEC.

Figure 3.26: Practical session.

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.

3.8.1 Embedded System Design


With the knowledge obtained from the embedded systems module, we set up microcon-
troller circuits using the following key components:
ˆ ESP32 Development Boards
ˆ Resistive Soil Moisture Sensor Modules
ˆ Submersible Digital Temperature Sensors
ˆ DHT Sensors
ˆ Rain Sensors
ˆ MQ-135 Gas Sensors
ˆ PIR Sensors
ˆ Ultrasonic Sensors
ˆ LDR Light Dependent Resistor GL5506s
ˆ LCD Modules
ˆ Water Pumps
ˆ LEDs
ˆ Buzzers
Fig. 3.27 show the system architecture that we designed.

34
Figure 3.27: system architecture for e farm prototype.

1. Microclimate Characterization and Pest Surveillance

ˆ We configured an ESP32 microcontroller board to collect ambient temperature,


humidity, and air quality readings using DHT and MQ-135 sensors, respectively.
ˆ We displayed incoming sensor readings on an LCD module.
ˆ We sent alert notifications to the farm administrator in case of an increase in pests
and undesirable climatic patterns alongside proposed recommendations see fig 3.28.

2. Irrigation Management

ˆ We configured an ESP32 microcontroller board to collect soil moisture, soil temper-


ature, rain, and light intensity readings using Resistive Soil Moisture Sensor Module,
Submersible Digital Temperature Sensor, Rain sensor, and LDR Light Dependent
Resistor GL5506, respectively.
ˆ We displayed incoming sensor readings on an LCD module.
ˆ We developed logic on the ESP32 to autonomously control the actuators (water
pump and irrigation valves) based on the ML model’s irrigation predictions. see fig
3.30.
ˆ We configured a push button to manually override the ML-based control.

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

ˆ We configured an ESP32 microcontroller board to collect motion, distance, and light


intensity readings using PIR sensor, Ultrasonic sensors, and LDR Light Dependent
Resistor GL5506, respectively.
ˆ We ensured that security lights automatically turned on during nighttime.
ˆ We displayed incoming sensor readings on an LCD module.
ˆ We sounded an audio alarm and sent alert notifications to the farm administrator
in case of detected intruders.

4. Power Management

ˆ We configured each sensor node to utilize sleep modes to reduce power consumption
when not actively collecting data or communicating.

5. Central Gateway Configuration and Cloud Data Logging

ˆ We configured an ESP32 microcontroller board as a central gateway to receive data


from all the sensor nodes.
ˆ We set up communication with a real-time database, namely Firebase, to log sensor
data from all the nodes see fig 3.29.

36
Figure 3.29: Code Block in Arduino IDE to implement a central gateway using ESPNOW
communication protocol.

6. Remote Control and Monitoring

ˆ We implemented Bluetooth communication on the ESP32 to enable remote control


capabilities and allow authorized users to adjust irrigation schedules and settings
via Bluetooth-enabled devices.
ˆ We set up a synchronous web server to manually control the security lights of the
farm.
ˆ We configured an asynchronous web server to display current readings from all
sensor nodes to any device on the same network as the central gateway.

Figure 3.30: e-farm prototype showing the irrigation module.

3.8.2 Machine Learning Model Development


With the knowledge acquired from the Python module, we developed an ML model to
predict optimal irrigation timings using a custom dataset that was provided.

1. Data Preprocessing and Feature Selection

ˆ 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

ˆ We analyzed the dataset to identify patterns, trends, and relationships between


different features. This analysis provided insights that helped in understanding the
factors affecting irrigation needs and improving the model’s performance.

Figure 3.31: Sample EDA of crops dataset.

3. Model Training

ˆ We trained an ML model using the Random Forest algorithm to predict optimal


irrigation timings based on historical sensor data and crop requirements.

4. Model Integration and Deployment

ˆ We converted the trained ML model to a format compatible with the ESP32 and
deployed it on the ESP32 to enable on-device predictions.

3.8.3 Web Application


With the knowledge obtained from the Python module, we developed a web application
using the Flask framework.

Real-Time Visualization and ML Model Deployment

ˆ We developed a user-friendly web application and implemented functionalities to


visualize real-time sensor data and ML model predictions on the web application.
ˆ The developed ML model was also deployed on the web application as an alternative.

38
Figure 3.32: The web application.

User Authentication and Authorization

ˆ We implemented secure user authentication and authorization mechanisms to ensure


only authorized users could access the web application.

Figure 3.33: User authentication page.

Data Interaction with Real-Time Database

ˆ We integrated the web application with the real-time database to fetch and display
the latest sensor data and ML model predictions.

Figure 3.34: Code block to interact with Firebase.

39
Figure 3.35: Th Firebase database.

Responsive Design and User Experience

ˆ 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.

Web Application Hosting

ˆ We hosted the web application at the following address https://terranova-v1-3.onrender.com


to ensure availability and scalability.

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.

I am truly grateful to netLabsUG! for giving me this opportunity.

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

Figure 1: Certificate awarding ceremony at CREEC.

Figure 2: Receiving my certificate for solar systems design and maintenance.

44
Figure 3: Graduation ceremony at netLabsUG!.

Figure 4: Receiving my certificate for the internship at netLabsUG!.

45
46
47

You might also like