Intern 122 Report
Intern 122 Report
CHAPTER 1
ABOUT THE COMPANY
1.1 Introduction
Our Mission is to be an ultimate solution provider with a reputation for expertise, quality, and
cost effective in the world of automation and to advocate sustainable environmental protection
1
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Our Vision is to provide training and implement services with edge of competitive in quality &
price to our valued customers in the ground of sustainability. We promote reputed multi brand
residential, commercial and Industrial automation products. Our focus and growth will be on the
technological outsourcing in the field of PLC controls, BMS, HVAC controls and other related
sub systems in the Middle East and Indian subcontinent.
1.1.4 Objectives
1. Increase the technical knowledge and real time industrial exposure of the students during
the commencement of Industrial Training
2. Maximize students employability and increase the rate of placement
3. Branding of College &wider recognition by Industry and Corporate
4. Higher Ranking for the College in Surveys
5. Possibility of establishing the Centre of Excellence by the Industry
2
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
6. Certified and Industry oriented Technical Skills & Personality Development Training
under one window saving cost and Time
7. Live Projects and Practice on Real Systems and Instrument
People-oriented: We offer our people the opportunity to accelerate more rapidly than is possible
elsewhere. We will continue to drive the greater dimension length to identify and recruit the very
best person for every position. We perceive the importance of individual creativity, but we know
that a team effort produces the best results. The dedication of our people to the company and the
intense efforts they give to their work is vital to our continued success. Advancement depends
solely on ability, performance and contribution to the firm’s success with no discrimination of
race, colour, age, gender.
Client-focused: We are big enough to solve our clients’ problems, yet substantial enough to
sustain the loyalty, intimacy and culture that we all treasure and which contributes greatly to our
success. Our client’s interest always comes first. Our experience shows that if we treat our
clients well, our own success will pursue. We always seek aggressively to widen up, our client
relationships but we will never put down our competitors in this pursuit. Extensive Integrity in
everything we do Integrity and honesty are at the heart of our business. We expect our people to
maintain high ethical standards in everything they do, both in their work for the company and in
their personal lives. We regularly receive confidential information as part of our normal client
relationships. To breach a confidence or to use confidential information improperly or carelessly
is unthinkable. We protect the company’s intellectual property as though it were our own
personal property.
Innovative: Our assets are our people, technology, intellectual capital, culture of innovation and
reputation. If any of this is ever lost, the last is the most difficult to regain. We covet our culture
of innovation and as such we stress creativity and imagination in all our work. We are and will
continue to be thought leaders in our chosen industries. We take great honor in the professional
3
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
To adhere to our quality policy, we use the following as our guidelines in daily operation:
Total commitment towards customer satisfaction through service excellence.
Strive for quality excellence in offered solutions and products.
Offer timely and cost-effective solutions.
Constant up-gradation of skills and technologies.
Sensitivity to the needs of our customers, associates and society.
4
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
We specialized in System integration, training and strategic outsourcing, bringing together the
expertise and capabilities of Technologies to help our clients achieve their organizational goals.
In simple terms, we find out what our clients want and use our people and technology to help
them get it as efficiently as possible.
Whether that is Industrial automation, HAS, BMS, or SCADA solutions, then, we’re the
company you should be talking to.
Residential: Home automation (HAS), Energy and Utility and central monitoring &
Controls.
Commercial: Lighting control system (LCS), Building automation (BMS), CCTV, FAS,
Utility& energy management (EMS), car park and CO-Monitoring, hotel room
management system
Health care: Lighting control system (LCS), Building automation (BMS), Utility, energy
management (EMS), nurse call system and any sub system Integration.
Educational: PLC, DCS, SCADA, VFD, HMI, HVAC controls, BMS, Lighting control
system (LCS), energy management (EMS).
Industrial: PLC, DCS, SCADA, VFD, HMI BMS & EMS.
Integration Services include:
5
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
implementing the newest technology, innovative solutions, and high-quality service we provide
our customers with:
6
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
7
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
8
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
CHAPTER 2
ABOUT THE DEPARTMENT
9
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
System is a way of working, organizing, or performing one or many tasks according to a fixed
set of rules, program or plan. In other words, an arrangement in which all units assemble and
work together according to a program or plan. An embedded system is a system that has software
embedded into hardware, which makes a system dedicated for an application (s) or specific part
of an application or product or part of a larger system. It processes a fixed set of pre-programmed
instructions to control electromechanical equipment which may be part of an even larger system
(not a computer with keyboard, display, etc.).
A general-purpose definition of embedded systems is that they are devices used to control,
monitor or assist the operation of equipment, machinery or plant. “Embedded” reflects the fact
that they are an integral part of the system. In many cases, their “embeddedness” may be such
that their presence is far from obvious to the casual observer.
10
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Courses are designed by professional instructors in partnership with industry experts, product
engineers, technical support engineers, and product development teams. Using proven best
practices gained through decades of building controls experience, we provide practical, results-
oriented training tailored to your job.
Overview Of BMS:
The objective of Building Management Systems (BMS system) is to manage & control the sub-
systems within a building to ensure a pleasant, controlled and safe environment. A BMS can
control some of the following building equipment’s or operation like: HVAC, CCTV, Access
Control, Fire and Intruder Alarms, Lighting and even Power Consumption.
Description:
11
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
The primary and overall objective of this course is to give a hands-on experience of Operations
& Maintenance
Description:
Today’s highly increasing competitiveness over the industry demands high quality and most
consistent products with a competitive price. To address this challenge number of industries
considering various new product designs and integrated manufacturing techniques in parallel
with the use of automated devices.
Automation takes a step further mechanization that uses a particular machinery mechanism aided
human operators for performing a task. Mechanization is the manual operation of a task using
powered machinery that depends on human decision making.
One of the remarkable and influential moves for getting the solutions of above-mentioned
challenge is the industrial automation. Industrial Automation facilitates to increase the product
quality, reliability and production rate while reducing production and design cost by adopting
new, innovative, and integrated technologies and services.
12
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Description: Today’s highly increasing competitiveness over the industry demands high quality
and most consistent products with a competitive price. To address this challenge number of
industries considering various new product designs and integrated manufacturing techniques in
parallel with the use of automated devices.
Automation takes a step further mechanization that uses a particular machinery mechanism aided
human operators for performing a task. Mechanization is the manual operation of a task using
powered machinery that depends on human decision making.
One of the remarkable and influential moves for getting the solutions of above-mentioned
challenge is the industrial automation. Industrial Automation facilitates to increase the product
quality, reliability and production rate while reducing production and design cost by adopting
new, innovative, and integrated technologies and services.
This course provides managers, process control engineers, and operators with a solid background
around the basics of OPC the specifications, the applications, and their use cases. OPC
technology is used in a wide variety of industries such as oil & gas extraction and refining,
mining; pharmaceutical, food processing, discrete manufacturing, building automation, and
more. Professionals working either directly or in support of the process control environment will
benefit from this course.
Description:
Today’s highly increasing competitiveness over the industry demands high quality and most
13
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Consistent products with a competitive price. To address this challenge number of industries
considering various new product designs and integrated manufacturing techniques in parallel
with the use of automated devices.
Automation takes a step further mechanization that uses a particular machinery mechanism aided
human operators for performing a task. Mechanization is the manual operation of a task using
powered machinery that depends on human decision making.
The application of technology that enables computer software to partially or fully automate
human activities which are manual, repetitive and rule-based.
RPA gives a company the ability to map out a business process that is definable, repeatable and
rules-based and assign a software “robot” to manage the execution of that process.
Courses are designed by professional instructors in partnership with industry experts, product
engineers, technical support engineers, and product development teams. Using proven best
practices gained through decades of building controls experience, we provide practical, results-
oriented training tailored to your job.
Robotic process automation (RPA) is the application of technology that allows employees in a
company to configure computer software or a “robot” to capture and interpret existing
applications for processing a transaction, manipulating data, triggering responses and
communicating with other digital systems.
14
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Talking about embedded systems, it gets the spotlight due to its application-orientated outcomes
and focusing areas of development.
Collectively, 82% have seen the rise in revenue and market share prices by 81% by
implementing the trends of IoT.
After the implementation, IoT has enabled over 55% of businesses to decrease their operating
costs by 21%. As a result, 39% of IoT adopters say IoT allows greater flexibility when
supporting their custom.
15
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
CHAPTER 3
TASKS PERFORMED
3.1 Lecture-Discussion
An embedded system is a computer system designed to perform a specific task, with dedicated
hardware and software, embedded in a larger device or system. These systems are designed to be
highly reliable, often with real-time constraints and low power consumption. They can be found
in a wide range of applications, from simple household appliances to complex industrial
automation systems, medical equipment, and automotive control systems.
Embedded systems typically consist of a microcontroller or microprocessor, memory,
input/output (I/O) interfaces, and other peripheral devices. The software is usually written in
low-level programming languages, such as assembly language or C, to maximize performance
and minimize memory usage.
The development process for embedded systems can be challenging, as designers must balance
the system's performance requirements with the limitations of the hardware and the available
resources. The system's reliability, safety, and security are also critical factors that must be
considered.
Embedded systems play an essential role in our modern world, providing the intelligence and
control necessary for many of the devices and systems we rely on every day.
Embedded systems are used in a wide variety of industries and applications, including:
Consumer electronics, Automotive, Industrial automation, medical devices, Aerospace.
The development of embedded systems involves a range of disciplines, including electrical
engineering, computer engineering, software engineering, and mechanical engineering.
16
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Designers must carefully consider the requirements of the system, including power consumption,
processing speed, memory size, and input/output interfaces, in order to create an efficient and
effective solution.
Embedded systems are widely used in a variety of applications across many industries. Some
examples of applications of embedded systems include:
Automotive industry: Embedded systems are used in cars for engine management, safety
systems, infotainment systems, and other functions.
Home automation: Smart home devices such as thermostats, security systems, and smart
lighting systems use embedded systems for control and automation.
Medical devices: Embedded systems are used in medical equipment such as heart
monitors, pacemakers, and insulin pumps.
Industrial automation: Embedded systems are used in industrial automation systems to
control and monitor machinery, assembly lines, and other systems.
Aerospace: Embedded systems are used in aircraft and spacecraft for navigation,
communication, and control.
Consumer electronics: Devices such as smartphones, digital cameras, and smart TVs all
use embedded systems.
Robotics: Embedded systems are used in robotics for control and automation, allowing
robots to perform complex tasks.
Military and defense: Embedded systems are used in military and defense applications,
such as control systems for unmanned vehicles and weapons systems.
17
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Energy management: Embedded systems are used in smart grids to monitor and control
the distribution of energy.
Agricultural industry: Embedded systems are used in precision farming systems for
monitoring and controlling irrigation, fertilization, and other processes.
3.1.2 Introduction to IoT
IoT, or the Internet of Things, refers to the interconnection of physical devices, vehicles,
buildings, and other items embedded with sensors, software, and network connectivity. This
allows these devices to collect and exchange data, providing useful information and enabling
new applications and services.
The concept of IoT has been around for several decades, but recent advancements in technology
such as low-cost sensors, wireless connectivity, and cloud computing have made it more
practical and accessible. With IoT, devices can communicate with each other and with humans,
making it possible to monitor and control a wide range of systems and processes in real-time.
IoT has numerous applications across many industries, including smart homes, wearables,
healthcare, transportation, agriculture, and manufacturing. IoT can also be used to optimize
energy usage, improve public safety, enhance customer experiences, and enable new business
models.
However, IoT also presents some challenges, such as security and privacy concerns,
interoperability, and data management. As IoT continues to evolve, it will require a
multidisciplinary approach involving technology, policy, and society to ensure its full potential is
realized while minimizing any negative impacts.
The Internet of Things (IoT), also sometimes referred to as the Internet of Everything (IoE),
consists of all the web-enabled devices that collect, send and act on data they acquire from their
surrounding environments using embedded sensors, processors, and communication hardware.
These devices, often called "connected" or "smart" devices, can sometimes talk to other related
devices, a process called machine-to-machine (M2M) communication, and act on the
information they get from one another. Humans can interact with the gadgets to set them up, give
them instructions or access the data, but the devices do most of the work on their own without
human intervention. Their existence has been made possible by all the tiny mobile components
18
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
that are available these days, as well as the always- online nature of our home and business
networks.
A) Applications of IoT
IoT (Internet of Things) has many applications across various industries and fields. Some
common applications of IoT include:
Smart Home: IoT technology can be used to control and automate various devices and
appliances in a home, such as lights, thermostats, security systems, and entertainment
systems.
Healthcare: IoT devices such as wearables, sensors, and monitors can be used to collect
and analyze patient data, improve patient care and outcomes, and support remote patient
monitoring.
Agriculture: IoT technology can be used in agriculture to monitor crop growth, soil
moisture levels, and weather conditions, which can help farmers optimize crop yield and
minimize waste.
Manufacturing: IoT devices can be used to monitor and optimize factory operations,
track inventory, and improve supply chain management.
Transportation: IoT technology can be used in transportation to track vehicle location,
monitor driver behavior, and improve traffic flow.
Energy Management: IoT devices can be used to monitor and control energy usage in
homes and buildings, helping to reduce energy waste and lower utility costs.
Smart Cities: IoT technology can be used to manage and optimize city infrastructure,
including traffic lights, waste management, and public transportation. Overall, the
applications of IoT are diverse and constantly evolving as new technologies emerge and
businesses and organizations find new ways to leverage the power of connected devices
and data.
19
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
20
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
21
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
22
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
23
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Write the Code: In the Arduino IDE, write your code using the Arduino programming
language. You can use the examples provided in the IDE or write your own code.
Verify and Upload the Code: After writing the code, click on the "Verify" button to
compile the code and check for errors. If there are no errors, click on the "Upload" button
to upload the code to the microcontroller on the Arduino Uno. You will see the progress
in the status bar at the bottom of the IDE.
Test the Program: Once the code is uploaded, you can test your program by connecting
your sensors, actuators, or other devices to the appropriate pins on the Arduino Uno.
Then, open the Serial Monitor in the Arduino IDE to view the output of your program.
3.1.4 ESP32
24
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
ESP32 is a popular microcontroller board based on the ESP32 system-on-chip (SoC) from
Espressif Systems. It is a powerful and versatile board that is widely used in the Internet of
Things (IoT) applications due to its high processing power, low power consumption, built-in Wi-
Fi and Bluetooth connectivity, and support for a wide range of peripherals.
Dual-core processor: the ESP32 features two Tensilica Xtensa LX6 32-bit
microprocessor running at up to 240 MHz.
Wi-Fi and Bluetooth connectivity: The ESP32 features built-in Wi-Fi and Bluetooth
connectivity, making it easy to connect to the internet and other devices.
Low power consumption: The ESP32 is designed to consume very little power, making it
suitable for battery-powered applications.
GPIO pins: The ESP32 has many General-Purpose Input/output (GPIO) pins that can be
used to interface with a wide range of sensors, actuators, and other components.
Analog-to-digital converter (ADC): The ESP32 has a built-in ADC that can be used to
measure analog signals from sensors.
Pulse-width modulation (PWM): The ESP32 has built-in PWM generators that can be
used to control the brightness of LEDs, the speed of motors, and other parameters.
I2C, SPI, and UART interfaces: The ESP32 supports popular communication protocols
such as I2C, SPI, and UART, making it easy to interface with other devices.
The ESP32 can be programmed using the Arduino IDE or using Espressif’s native development
environment, ESP-IDF. It is widely used in a variety of applications, including home automation,
industrial automation, robotics, and smart energy.
25
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
ESP32 SoC: The ESP32 system-on-chip (SoC) is the main component of the board. It
contains two Tensilica Xtensa LX6 32-bit microprocessors running at up to 240 MHz,
along with built-in Wi-Fi, Bluetooth, and other peripherals.
Flash memory: The ESP32 comes with up to 16 MB of flash memory for program
storage and data logging.
RAM: The ESP32 has up to 520 KB of SRAM for program execution and data storage.
GPIO pins: The ESP32 has up to 36 GPIO pins that can be used for digital input/output,
analog input, PWM, and other purposes.
ADC: The ESP32 has a 12-bit SAR ADC that can measure up to 18 channels with a
resolution of up to 4096 steps.
DAC: The ESP32 has two 8-bit DACs that can be used to generate analog output signals.
Communication interfaces: The ESP32 supports various communication interfaces,
including SPI, I2C, UART, and CAN.
Wi-Fi: The ESP32 supports 802.11 b/g/n Wi-Fi with a built-in antenna.
Bluetooth: The ESP32 supports Bluetooth Low Energy (BLE) with a built-in antenna.
Power supply: The ESP32 can be powered using a USB cable or an external power
supply with a voltage range of 5V to 12V.
Dimensions: The ESP32 board is typically about 2.7 inches (68.6 mm) long and 1.7
inches (43.2 mm) wide.
B) ESP32 Pinout
26
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
VIN: This pin is used to supply power to the board. It can accept a voltage range of 5V to
12V, which is regulated down to 3.3V by the board's voltage regulator.
GND: These pins are connected to ground.
IO34 - IO39: These pins are general purpose input/output (GPIO) pins that can be used
for a variety of purposes, such as digital input/output, analog input, PWM, and more.
EN: This pin is used to enable or disable the ESP32. When this pin is pulled high
(connected to 3.3V), the ESP32 is enabled and can run. When it is pulled low or left
floating, the ESP32 is disabled.
IO21 - IO27: These pins are also GPIO pins, and can be used for various purposes.
IO5 and IO4: These pins are used for I2C communication, which is a popular protocol for
connecting sensors and other devices to microcontrollers.
IO23, IO19, and IO18: These pins are used for SPI communication, which is another
common protocol for connecting devices to microcontrollers.
RX0 and TX0: These pins are used for serial communication, which is a common way to
communicate with the ESP32 from a computer or other device.
C) How to program ESP32
Install the Arduino IDE: The Arduino IDE is a popular software tool that can be used to
program the ESP32. You can download it from the official Arduino website and install it
on your computer.
Install the ESP32 board definitions: In order to program the ESP32 with the Arduino
IDE, you will need to install the board definitions. You can do this by following the steps
outlined in the official ESP32 installation guide.
Connect the ESP32 to your computer: You will need to connect the ESP32 to your
computer using a USB cable. Make sure that the correct driver is installed on your
computer so that it can recognize the ESP32.
Choose the correct board and port in the Arduino IDE: Once you have installed the
27
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
board definitions and connected the ESP32 to your computer, you will need to select the
correct board and serial port in the Arduino IDE. You can do this by going to the Tools
menu and selecting the appropriate options.
Write and upload your code: Finally, you can write your code in the Arduino IDE and
upload it to the ESP32 by clicking on the Upload button. The code will be compiled and
uploaded to the ESP32, where it will be executed.
Why Wokwi?
Wi-fi simulation - Connect your simulated project to the internet. You can use MQTT,
HTTP, NTP, and many other network protocols.
Virtual Logic Analyzer - Capture digital signals in your simulation (e.g. UART, I2C,
SPI) and analyze them on your computer.
Advanced debugging with GDB - Powerful Arduino and Raspberry Pi Pico debugger
28
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
29
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
The ESP32 is an advanced Iot microcontroller board possessing Wi-Fi and Bluetooth Low
Energy capabilities, as well as limited compatibility with the Arduino Core. This is the first
module in a series of tutorials regarding the use of the ESP32 Development Board, from its
equivalent Arduino projects to advanced IoT projects.
The 'Blinking an LED' project uses the ESP32 Development Board will be used to blink an LED
at a specific timed interval, infinitely. It is the essential fundamental tutorial for any
microcontroller board, as it is the hardware equivalent of the classic "Hello World" tutorial!!!
#define LED 2
void setup() {
pinMode(LED, OUTPUT);
}
void loop () {
digitalWrite (LED, HIGH);
delay(500);
digitalWrite (LED, LOW);
delay(500);
}
30
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
This project employs the ESP32 as the control device, which connects to an existing Wi-Fi
network and creates a Web Server. When a device connects to this web server, the ESP32 will
read the temperature and relative humidity from the DHT11/DHT22 sensor and send it to the
device’s web browser with a nice interface.
#include "DHTesp.h"
DHTesp dhtSensor;
void setup() {
Serial.begin(115200);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
void loop() {
Serial.println("---");
delay(1000);
3. Arduino Keypad
31
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Simple keypads and keyboards without a dedicated controller typically work in an easy-to-
understand way. You can divide the keypad into rows and columns.
Note how the buttons sit exactly where the rows and columns meet. The Arduino, or any other
microcontroller, sends a quick pulse to each line, one row at a time. In this article, the Arduino
pulls the input lines low for a short period. It then checks whether any of the columns transitions
to a low state as well. If that happens, the Arduino registers a button press. Suppose that a user
presses the five-key on the keypad. The Arduino pulls each of the yellow input lines low. When
it reaches the second yellow line, it detects that reading the second column returns a low state.
That happens because someone pushes a button. Each button connects a row and a column, just
like an ordinary switch.
#include <Keypad.h>
32
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
char keys[ROWS][COLS] = {
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '*', '0', '#', 'D' }
};
uint8_t colPins[COLS] = { 5, 4, 3, 2 }; // Pins connected to C1, C2, C3, C4
uint8_t rowPins[ROWS] = { 9, 8, 7, 6 }; // Pins connected to R1, R2, R3, R4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
}
void loop() {
char key = keypad.getKey();
if (key != NO_KEY) {
Serial.println(key);
}
}
4. Flame sensor on the ESP32
33
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Flame Sensor with ESP32 is a type of flame detection system that uses an ESP32 microcontroller
to process and analyze data from sensors, and to communicate with other devices using Wi-Fi.
The ESP32 can be used to connect the system to a network, allowing it to be remotely monitored
and controlled.
34
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Gas sensor is used to detect the presence of gas in a specific area. These sensors can be
connected to the internet, allowing for remote monitoring and alerts to be sent to a control center
or to a specific person’s device. The system can also be set up to automatically shut off gas
valves or perform other safety actions in the event of a leak.
35
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
MQTT Box is a helper program to develop and load test MQTT based clients, brokers, devices,
cloud, and apps. Every aspect of MQTTBox is specifically designed to maximize development
and testing productivity. Together, with MQTT clients and load testing tools integrated, its
powerful enough to supercharge your MQTT workflow.
A) Usage/Features
MQTT Clients
Add multiple MQTT clients with TCP and WebSocket’s connection support
Connect with wide range of MQTT client connection settings
Publish/Subscribe to multiple topics
Supports Single Level (+) and Multilevel (#) subscription to topics
Copy/Republish payload
History of published/subscribed messages for each topic
Auto connect clients to brokers
Supports QoS 0,1,2
MQTT Load
to increase load
Load test by publishing messages with QoS 0,1,2
36
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
A) Navigation
Below screenshot shows navigation between MQTT clients and MQTT Load test cases.
37
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Fig: 3.11 Navigation between MQTT clients and MQTT Load test cases
B) MQTT Client
You can add multiple MQTT clients each with multiple publishers and subscribers.
38
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Fig: 3.12 MQTT clients each with multiple publishers and subscribers
View live data on MQTT Load dashboard when test in progress. You can start, stop or restart
39
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
load test along with viewing graphs and data for each or all instances.
App Inventor is a visual, blocks-based programming language and online platform for creating
mobile apps for Android devices. It was developed by MIT’s Media Lab and is now maintained
by the Massachusetts Institute of Technology (MIT). It allows users with little or no
programming experience to create their own mobile apps by dragging and dropping visual blocks
that represent programming concepts. App Inventor is also open-source, which means that
anyone can access, modify, and distribute the software. It is intended to help educators and
students learn programming and is widely used in classrooms and educational institutions.
It is possible to create an SMS application using App Inventor. To do this, you would first
need to design the user interface of the SMS application using the built-in components such as
Buttons, Textboxes, and PhoneNumberPicker. You would then need to create event handlers for
the various buttons and components using blocks. To create the interface, you can use a Phone
Number Picker component, which allows users to select a recipient from their device’s contact
40
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
list, a Textbox for the message and a Button to trigger the sending of the message. You can also
add additional components such as a Label to show the character count, or a button to clear the
message. Once the interface is set, you can proceed to set up the event handlers to make the SMS
application functional. For example, when the user presses the “Send” button, an event handler
would be triggered that would gather the information entered in the Textbox and
PhoneNumberPicker component, and use the built-in SMS component to send the message to the
selected recipient.
Additionally, the user will be prompted with a confirmation message before sending the SMS,
this is a security measure to prevent accidental sending of messages.
We will create an application named ‘SMS’ with App Inventor that sends an SMS from a mobile
application to a phone number.
41
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
To program the application, App Inventor proposes to use The Space Blocks which allows to
create a program in the form of a block diagram. Very simple to use but requiring some
programming logic.
Here is the SMS program realized in the Blocks area of the Inventor App:
Fig 3.15: SMS program realized in blocks area of the inventor app
3.3 Project
To create a device that can track the price of Bitcoin in real-time and display it on an ESP32
board. The device should be able to connect to the internet using Wi-Fi and fetch the latest
Bitcoin price data from an online API. The device should be able to display the current Bitcoin
price on a screen attached to the ESP32 board. The user should be able to configure the device to
update the Bitcoin price at a specific interval. The device should also be able to alert the user
when the Bitcoin price crosses a certain threshold set by the user.
42
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
4. Connect to the internet: Connect the ESP32 board to the internet using Wi-Fi. This will
allow the device to fetch the latest Bitcoin price data from an online API.
5. Fetch the Bitcoin price data: Use an online Bitcoin API to fetch the latest Bitcoin price
data. The API should be able to provide the data in a format that can be easily parsed by
the ESP32 board.
6. Display the Bitcoin price: Display the Bitcoin price on the screen attached to the ESP32
board. The screen can be an OLED or LCD display, and the price can be displayed in text
or using a graphical representation
7. Configure the update interval: Allow the user to configure the device to update the
Bitcoin price at a specific interval. This can be done using a button or a menu system.
8. Set price alerts: Allow the user to set price alerts, so that they can be notified when the
Bitcoin price crosses a certain threshold set by the user. This can be done using an alarm
or notification system.
9. Test and refine: Test the device thoroughly to ensure that it works as expected. Refine the
code and design as necessary to improve the performance and user experience.
10. Deploy and maintain: Deploy the device and provide instructions on how to use it.
Maintain the device by updating the software and firmware as necessary to keep it up-to-
date with the latest Bitcoin price data and any changes in the API.
3.3.1 Methodology:
Block Diagram
43
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Choose a Bitcoin API: The first step is to choose a Bitcoin API that provides real-time
data on Bitcoin prices. You can use APIs such as Coinbase, Kraken, or Bitstamp.
Connect ESP32 to Wi-Fi: Connect the ESP32 to Wi-Fi, so it can access the Internet and
fetch the Bitcoin data from the API. You can use the Arduino IDE to program the ESP32
to connect to Wi-Fi.
Fetch Bitcoin data: Use the API to fetch the Bitcoin data, such as the current prices, and
other relevant information.
Display the data: You can use an OLED display or a simple LCD screen to display the
Bitcoin data fetched by the ESP32. You can also use LEDs or buzzers to create visual or
audio alerts based on certain price thresholds.
Implement error handling: In case the API connection fails or the Wi-Fi connection
drops, implement error handling to ensure the ESP32 can recover and continue to fetch
data.
Secure the connection: To ensure the security of the Bitcoin tracker, you can use
SSL/TLS to encrypt the communication between the ESP32 and the Bitcoin API.
Overall, building a Bitcoin tracker using an ESP32 requires knowledge of programming, Wi-Fi
connectivity, and working with APIs. However, it can be a great way to learn about IoT devices
and their applications.
44
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
The ESP32 supports many peripherals such as: capacitive touch, ADC, DAC, I2C, SPI, UART,
I2S, PWM. It is appropriate for Internet of Things Projects and enables Bluetooth
communications for Smartphone applications.
This key studio ESP32 core board is a Mini development board based on the ESP-WROOM-32
module. The board has brought out most I/O ports to pin headers of 2.54mm pitch. These
provide an easy way of connecting peripherals according to your own needs. When it comes to
developing and debugging with the development board, the both side standard pin headers can
make your operation simpler and handier. The ESP-WROOM-32 module is the industry's
45
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
leading integrated Wi-Fi + Bluetooth solution with less than 10 external components. It
integrates antenna switch, RF balun, power amplifiers, low noise amplifiers, filters and power
management modules. At the same time, it also integrates with TSMC's low-power 40nm
technology, so that power performance and RF performance.
A) Technical Details
2. OLED
I2C OLED refers to an OLED display that communicates using the I2C protocol. OLED stands
for Organic Light-Emitting Diode, which is a type of display technology that does not require a
backlight to produce light. I2C, on the other hand, is a communication protocol that allows
multiple devices to communicate with each other using a single set of wires.
When an OLED display is connected to a microcontroller or a computer using the I2C protocol,
it can receive commands and data to display images and text. I2C OLED displays are popular in
many embedded systems and hobbyist projects because of their small size, low power
consumption, and ease of use.
46
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
I2C OLED displays come in different sizes and resolutions, and can display different colors
depending on the model. They are commonly used in wearable devices, IoT devices, and other
projects that require a small and low-power display.
47
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
3. Resistors
A 560-ohm resistor is an electronic component that provides 560 ohms of resistance to the flow
of electric current. It is a passive component that is commonly used in electronic circuits to limit
the current flowing through LEDs or to set the bias of transistors.
A 560-ohm resistor is a relatively low value resistor and can be used in circuits with a voltage
range of typically 5V or less. It is available in a variety of package sizes and types, including
axial, surface mount, carbon film, and metal film.
When selecting a resistor for a specific application, it's important to consider factors such as the
power rating, tolerance, and temperature coefficient. The power rating of a 560 ohm resistor
determines how much power it can safely dissipate without overheating, while the tolerance
determines how close the actual resistance value is to the stated value. The temperature
coefficient indicates how the resistance of the resistor will change with temperature changes in
the environment.
48
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
A) Technical specifications
• Resistance value: 560 ohms (±5% tolerance is common, but other tolerances are
available)
• Power rating: typically, 1/4 Watt, but other power ratings may be available
• Maximum working voltage: depends on the power rating and environment, but typically
around 200V or less
• Temperature coefficient: the resistance value of a resistor changes with temperature, and
the temperature coefficient (usually expressed in ppm/°C) indicates how much it will
change over a given temperature range.
• Operating temperature range: depends on the type of resistor, but most used resistors
have an operating temperature range of -55°C to +125°C.
4) LED
A 5mm LED (Light Emitting Diode) is a type of LED that has a diameter of 5mm. LEDs are
semiconductor devices that emit light when an electric current is passed through them in the
forward direction. They are commonly used in a wide range of electronic applications such as
indicators, displays, and lighting.
5mm LEDs are available in various colors such as red, green, blue, yellow, white, and multi-
color. They have a voltage rating of around 1.8 to 3.5 volts and can be operated at current levels
ranging from a few milliamps to tens of milliamps.
They are also available in different brightness levels, and their brightness is measured in
millicandela (mcd) or lumens (lm) depending on the application. High-brightness 5mm LEDs are
commonly used for lighting applications, while lower brightness ones are used as indicators and
49
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Diameter: 5mm
Operating Voltage: 1.8V to 3.5V (typical)
Operating Current: 10mA to 30mA (typical)
Power Consumption: 50mW to 100mW (typical)
Luminous Flux: 2lm to 10lm (typical)
Viewing Angle: 30 degrees to 120 degrees (typical)
Operating Temperature: -40°C to 85°C
Storage Temperature: -40°C to 100°C
Lifetime: 50,000 hours (typical)
50
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
The Arduino IDE includes a text editor for writing code, a compiler that converts the code into
machine-readable instructions, and a bootloader that allows the code to be uploaded onto the
Arduino board. It also includes a serial monitor that allows users to communicate with the board
and receive input from sensors or other devices.
The Arduino IDE is free and open-source, and its code is available on GitHub for developers to
contribute to and modify. It also has a large community of users who share projects, tutorials,
and support each other through forums and other online resources.
A) Technical specifications
The Arduino IDE is a software platform used for programming and developing applications for
Arduino boards, and as such, it does not have technical specifications in the traditional sense.
However, here are some general specifications of the Arduino IDE:
51
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Compiler: AVR-GCC
License: Open-source (GNU General Public License)
Integrated Libraries: Standard Arduino libraries and third-party libraries
Development Tools: Text editor, serial monitor, and board manager
The requirements for running the Arduino IDE can vary depending on the specific operating
system and version. For example, the minimum system requirements for running Arduino IDE
on a Windows PC are:
Windows 7 or later
2 GB RAM
1024 x 768 screen resolution
2 GB hard disk space
52
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Connect the SDA & SCL Pin of OLED Display to D21 & D22 of ESP32 Module. Connect the
red & green LED to D18 & D19 respectively via 200-ohm resistor. Power the OLED Display
using the 3.3V & GND pin of ESP32. The red LED here indicates the price of Bitcoin is going
down while the green LED indicates the rise in Bitcoin price.
3.4 RESULTS
53
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
The Bitcoin Price Tracker is designed using the ESP32 development board, which has built-in
WiFi. It connects to your WiFi network and fetches the updated Bitcoin price through the
CoinDesk every 15 minutes. Along with the Bitcoin price, the device also displays the
percentage change from yesterday’s closing price. It also lights up either a red or green LED
depending on whether the price has increased or decreased.
After uploading the code, the ESP32 Module will try connecting to the WiFi Network
using the Network credentials provided in the code. Once it gets connected, it will try to
fetch the data using the given API & will display parameters on Serial Monitor.
On the other hand, the OLED will boot up with Bitcoin Logo initially.
54
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Once the device connects to the WiFi Network it will display the current Bitcoin price
along with the change in Bitcoin value since yesterday date. If the bitcoin price is
decreasing the Red LED will turn ON.
55
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Once the device connects to the WiFi Network it will display the current Bitcoin price
along with the change in Bitcoin value since yesterday date. If the bitcoin price is
decreasing the Red LED will turn ON.
In case, if the Bitcoin price value is increasing the green LED will turn ON.
56
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
CHAPTER 4
REFLECTION NOTES
4.1 Experience
57
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
I have carried out my internship work in Technologics global private limited for the duration of 4
weeks. The first day of the internship training program they gave a brief introduction about
Technologics global, company profile, key persons in the organization, vision and mission of
company and services provided.
In first week, they gave introduction about IoT, they taught pros and cons of IoT, we learned the
electronic components, they helped to connect circuits. Time to time practical assignments were
provided which helped me to practice in home. Revision time and query sessions were also
provided which helped me in clearing previous doubts.
Small challenges were given at the end of the day to strengthen practical knowledge. The task
involved program solving, gathering information about the individual component, its working
specification, features, usage cost advantages, disadvantages, applications and so on.
The guide at Technologics global also helped to self-analyze the concept and the work to get
required outputs by giving valuable information about the system. They made sure that I
understood the concept by giving various assignments.
Two main things that we have learned are importance of time management skills and self-
motivation. At last, this internship has a new insight and motivation to pursue a carrier in this
domain.
In this internship we came to know how to choose a specific technique we also learnt applying
accumulated knowledge and skills in particular concept and ESP32 to develop our project.
Internships are generally thought of to be reserved for college students looking to gain
experience in a particular field. However, a wide array of people can benefit from
Training Internships in order to receive real world experience and develop their skills.
58
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
An objective for this position should emphasize the skills you already possess in the area
and your interest in learning more.
Internships are utilized in a number of different career fields, including architecture,
engineering, healthcare, economics, advertising and many more.
Some internships are used to allow individuals to perform scientific research while others
are specifically designed to allow people to gain first-hand experience working.
Utilizing internships is a great way to build your resume and develop skills that can be
emphasized in your resume for future jobs. When you are applying for a Training
Internship, make sure to highlight any special skills or talents that can make you stand
apart from the rest of the applicants so that you have an improved chance of landing the
position.
Embedded System Design: One of the main technical outcomes of my internship was the
development of my skills in embedded system design. I learned how to identify the hardware and
software requirements of a given system, and how to select the appropriate components and
modules based on the system specifications. I also gained experience in designing, testing, and
debugging embedded systems. IoT Integration: Another technical outcome of my internship was
the development of my skills in IoT integration. I learned how to integrate different sensors and
actuators with cloud-based Embedded and IoT. I also gained experience in developing
dashboards and visualizations to monitor and analyze the data generated by the sensors, and how
to use machine learning algorithms to derive insights and predictions from the data.
59
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Project Management: Finally, my embedded systems and IoT internship allowed me to develop
my project management skills. I learned how to plan, execute, and monitor projects using
different project management tools and methodologies. I gained experience in setting project
goals and milestones, estimating project timelines and resources, and managing project risks and
issues. I also learned how to communicate effectively with our guide, team members, and
management, and how to present project progress and results using different communication
channels such as reports, presentations, and demos.
Verbal and Written Communication: During my embedded systems and IoT internship, I
improved my verbal and written communication skills by regularly communicating with my
guide and team mates. I was responsible for documenting my progress. I received positive
feedback on my communication skills, and I learned how to effectively convey technical
concepts to both technical and non-technical audiences. Personal Development: Through my
embedded systems and IoT internship, I developed personally by overcoming challenges and
pushing myself out of my comfort zone. I worked on projects that were outside my previous
experience and required me to learn new skills and technologies. I also learned how to work
effectively in a team, manage my time and priorities, and take initiative to solve problems.
Time Management: I improved my time management skills during my embedded systems and
IoT internship by managing multiple projects simultaneously and meeting tight deadlines. I
learned how to prioritize my tasks, break them down into manageable chunks, and allocate my
Embedded and IoT time effectively. I also learned how to adapt to changing requirements and
60
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
deadlines, and communicate proactively with my supervisors when I needed additional support
or resources.
Problem-Solving Skills: One of the key technical and non-technical outcomes of my embedded
systems and IoT internship was the development of my problem-solving skills. I encountered
various technical challenges throughout my projects, such as connectivity issues, hardware and
software conflicts, and debugging errors. I learned how to approach problems systematically,
analyze the root cause, and identify the best solution. I also developed my creativity and critical
thinking skills by exploring different alternatives and evaluating their feasibility and impact.
Overall, my embedded systems and IoT internship was a valuable learning experience that
allowed me to develop my technical, communication, personal, and professional skills.
CHAPTER 5
61
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
CONCLUSION
5.1 Conclusion
The project “Bitcoin Tracker using ESP32” can be a fascinating and rewarding project for those
interested in IoT and cryptocurrency. With ESP32's capabilities, it is possible to create a device
that can fetch real-time Bitcoin prices and display them on an OLED screen or send them to a
web server for remote monitoring. However, it is important to note that the value of Bitcoin can
be highly volatile, so it's important to keep this in mind when creating a Bitcoin tracker.
Additionally, it's important to follow best practices for securing your Bitcoin tracker to protect
your device and data. Overall, building a Bitcoin tracker using ESP32 can be a great way to learn
about both IoT and cryptocurrency while creating a useful tool for tracking Bitcoin prices.
62
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Mobile App Integration: A mobile application can be developed to connect to the ESP32-
based Bitcoin tracker, allowing users to monitor Bitcoin prices and manage their portfolio
from their mobile devices.
REFERENCES
63
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
1. Iftikhar, M. A., Khalid, S., Shahzad, W., Rehman, S., & Masood, M. (2020). IoT-based
ECG monitoring system: Challenges, applications and solutions. Journal of Ambient
Intelligence and Humanized Computing, 11(6), 2509-2535.
2. Kang, J., Choi, J., & Lee, Y. (2018). An IoT-based electrocardiogram monitoring system
for smart healthcare. Journal of Medical Systems, 42(11), 219.
3. Li, X., Yang, J., Zhang, L., & Fang, Z. (2017). An IoT-based ECG monitoring system for
smart healthcare. In 2017 IEEE International Conference on Smart Computing
(SMARTCOMP) (pp. 1-6). IEEE.
4. Chauhan, A., & Prasad, N. R. (2019). Internet of Things (IoT) enabled ECG monitoring
system: A review. In 2019 International Conference on Communication, Computing and
Electronics Systems (ICCCES) (pp. 741-745). IEEE.
5. Saavedra, G., Garcia-Sanchez, A. J., & Garcia-Sanchez, F. (2021). A novel IoT-based
ECG monitoring system for telemedicine. Sensors, 21(5), 1615.
6. Mahmud, M. N., Nafis, S. M., & Karim, A. (2018). A smart IoT-based wearable ECG
monitoring system. In 2018 IEEE International Conference on Informatics, Electronics &
Vision (ICIEV) (pp. 1-5). IEEE.
7. Rehman, S., Iftikhar, M. A., Khalid, S., Masood, M., & Khan, A. W. (2020). An IoT-
based ECG monitoring system for smart healthcare. Journal of Ambient Intelligence and
Humanized Computing, 11(6), 2537-2552.
8. Karim, A., & Mahmud, M. N. (2019). Design and implementation of an IoT based ECG
monitoring system using Arduino. In 2019 IEEE International Conference on Electrical,
Computer and Communication Engineering (ECCE) (pp. 1-4). IEEE.
9. Jain, A., & Gupta, N. (2021). IoT-based remote ECG monitoring system. In Internet of
Things and Artificial Intelligence: Challenges and Opportunities (pp. 215-229). Springer.
10. Lu, C., Xu, X., Zhou, X., & Xu, X. (2020). A wearable IoT-based ECG monitoring
system for remote health monitoring. In 2020 IEEE 17th International Conference on
Networking, Sensing and Control (ICNSC) (pp. 595-599). IEEE.
64
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
APPENDIX-A
SOURCE CODE
65
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
#include <WiFi.h>
#include <Wire.h>
#include <HTTPClient.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <ArduinoJson.h>
#define SCREEN_WIDTH 128 //Define the OLED display
width and height
#define SCREEN_HEIGHT 64
#define OLED_RESET -1 // Reset pin # (or -1 if sharing
Arduino reset pin)
#define SCREEN_ADDRESS 0x3C //I2C address for display
#define upLED 18
#define downLED 19
Adafruit_SSD1306 display
(SCREEN_WIDTH,SCREEN_HEIGHT,&Wire,OLED_RESET); //Create the display object
const char* ssid = "************";
const char* password = "**********";
const int httpsPort = 443; //Bitcoin price API powered by
CoinDesk - https://www.coindesk.com/price/bitcoin
const String url = "http://api.coindesk.com/v1/bpi/currentprice/BTC.json";
const String historyURL = "http://api.coindesk.com/v1/bpi/historical/close.json";
const String cryptoCode = "BTC";
WiFiClient client; //Create a new WiFi client
HTTPClient http;
66
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
67
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x3f, 0xc0, 0xc0, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x00, 0x01, 0xc0, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x00, 0x00, 0xf0, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x00, 0x00, 0x38, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x3f, 0xe0, 0x18, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x30, 0xf8, 0x0c, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x18, 0x30, 0x1c, 0x0c, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x18, 0x30, 0x0c, 0x0c, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x18, 0x30, 0x04, 0x0c, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x18, 0x30, 0x0c, 0x0c, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x18, 0x30, 0x0c, 0x0c, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x18, 0x30, 0x38, 0x0c, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0xf0, 0x3f, 0xf0, 0x08, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1c, 0x01, 0xe0, 0x1f, 0x00, 0x18, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x00, 0x00, 0x00, 0x30, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0x03, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0xfe, 0x3c, 0x7e, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x02, 0x3c, 0x40, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x02, 0x24, 0x40, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x02, 0x24, 0x40, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x02, 0x24, 0x40, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x02, 0x24, 0x40, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x03, 0xe7, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup()
{
Serial.begin(115200); //Start the serial monitor
68
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi...");
while (WiFi.status() != WL_CONNECTED) //Connect to the WiFi
network
{
delay(500);
69
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Serial.print(".");
}
Serial.println();
http.begin(url);
int httpCode = http.GET(); //Get crypto price from API
StaticJsonDocument<2000> doc;
DeserializationError error = deserializeJson(doc, http.getString());
70
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Serial.print("Getting history...");
StaticJsonDocument<2000> historyDoc;
http.begin(historyURL); //Get historical crypto price from API
int historyHttpCode = http.GET();
DeserializationError historyError = deserializeJson(historyDoc, http.getString());
Serial.println(historyHttpCode);
JsonObject bpi = historyDoc["bpi"].as<JsonObject>();
double yesterdayPrice;
for (JsonPair kv : bpi) {
yesterdayPrice = kv.value().as<double>(); //Store yesterday's crypto
} price
71
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
Serial.println(BTCUSDPrice.toDouble());
72
Dept. of ECE H.K.B.K.C.E
Embedded Systems and IoT
header
display.setTextSize(2);
printCenter("$" + BTCUSDPrice, 0, 20); //Display the current
price
void printCenter(const String buf, int x, int y) //Function to centre the current
price in the display width
{
int16_t x1, y1;
uint16_t w, h;
display.getTextBounds(buf, x, y, &x1, &y1, &w, &h); //Calculate string width
display.setCursor((x - w / 2) + (128 / 2), y); //Set cursor to print string in centre
display.print(buf); //Display string
}
73
Dept. of ECE H.K.B.K.C.E