Iot (210670107034) Practical

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Experiment No: 1

(1) Define different types of Arduino Boards.

Arduino UNO R3

Arduino Uno is the most popular and widely used development board. It is powered by an ATMega328P microcontroller. It
is the most popular choice among the community because it’s, cheap, easy to learn and use, and also a variety of premade
modules are available for this which makes it easier for developing new projects or prototypes. It consists of 14Digital I/O out
of which 6 pins are 8bit PWM pins, 6 pins are10-bit Analog inputs, and basic communication ports like SPI, I2C, and UART.

Now, there are many different types of Arduino UNO boards available across the global market, but most of these boards
are the clone or copy version of the original UNO board that you see above. Hence the color or the appearance of the board
might be different than what is shown above.

Arduino Nano

Arduino Nano is a small breadboard-friendly version of Arduino UNO. It has more or less functionality of the Arduino UNO
but in a small form factor. The only major differences from UNO are the lack of a DC power jack, the usage of a Mini USB
port instead of a USB B port, and the USB-TTL converter chip. Nano uses an FT232, a dedicated USB-UART bridge chip
from FTDI instead of an ATMega16U2. It is also a very popular choice among the developers just like UNO because of its
small size and cheap price.

Arduino PRO Mini

Pro mini is actually a cut-down version of Nano. It has most of the functionalities similar to Arduino Nano but it lacks the
onboard USB -TTL bridge and the USB port. Instead, it has a header, in which the UART pins are brought out. We can use
these pins to program the Pro mini using an external USB-UART module. This board is specially meant for applications
where the space is limited. Pro mini is available in two versions, 3.3V, and 5v versions. In the 3.3V version, the CPU speed
is limited to 8MHz because of certain limitations of ATMega328 for better stability.

Bhavsar Darshan(210670107015)
Arduino Leonardo

Arduino Leonardo is powered by an ATmega32U4 chip rather than the ATMega328P chip which is used in all the
previously mentioned boards. It has more IO pins (20) and more PWM (7) and analog input (12) pins. One other major
difference is that the ATMega32U4 has built-in USB communication eliminating the need for a second processor or a
dedicated USB to UART bridge chip. This allows the board to connect to a computer as a Human Interface Device (HID) or
as a Virtual (CDC) serial / COM port. We use this Virtual COM port along with the bootloader to program the Leonardo.

Arduino Micro

Just like Arduino Nano is a UNO in a small form factor, Arduino Micro is actually a Leonardo in a small form-
factor breadboard-friendly sized board. Its functionalities are the same as the Arduino Leonardo. The only difference is
the lack of a DC input jack. Similarly, Arduino Micro can also act as an HID or Virtual COM port device.

Arduino Nano Every

Arduino Nano Every is a new generation board in a small form factor. As we already discussed Arduino Nano is the
preferred board for many projects requiring a small and cheap solution. We could call the Arduino Nano Every,
an upgraded Arduino Nano with lot more features. Nano Every is powered by a more powerful processor ATMega4809.
It has 50% more program memory and a 200% bigger RAM which will enable us to muse this board for bigger programs.
The castellated holes allow us to use the Nano Every on a PCB without the need for the header pins.
Arduino Mega2560 Rev3

Arduino Mega 2560 is the biggest of all the boards we have discussed so far. It is designed for applications where a lot of I/O
or peripherals are needed. It is powered by a bigger and more capable processor the ATMega2560. This board has the greatest
number of I/O than most other boards, 54 I/O pins (of which 15 can be used as PWM outputs), 16 analog inputs, and 4 UARTs.
It has more flash storage and SRAM than most other basic Arduino boards. It is most popular with the opensource CNC and 3D
printer community as well as the opensource PLC community.

Arduino UNO R3

Arduino Uno is the most popular and widely used development board. It is powered by an ATMega328P microcontroller. It
is the most popular choice among the community because it’s, cheap, easy to learn and use, and also a variety of premade
modules are available for this which makes it easier for developing new projects or prototypes. It consists of 14Digital I/O out
of which 6 pins are 8bit PWM pins, 6 pins are10-bit Analog inputs, and basic communication ports like SPI, I2C, and UART.

Now, there are many different types of Arduino UNO boards available across the global market, but most of these boards
are the clone or copy version of the original UNO board that you see above. Hence the color or the appearance of the board
might be different than what is shown above.

Arduino Nano

Arduino Nano is a small breadboard-friendly version of Arduino UNO. It has more or less functionality of the Arduino UNO
but in a small form factor. The only major differences from UNO are the lack of a DC power jack, the usage of a Mini USB
port instead of a USB B port, and the USB-TTL converter chip. Nano uses an FT232, a dedicated USB-UART bridge chip
from FTDI instead of an ATMega16U2. It is also a very popular choice among the developers just like UNO because of its
small size and cheap price.

Bhavsar Darshan(210670107015)
Arduino PRO Mini

Pro mini is actually a cut-down version of Nano. It has most of the functionalities similar to Arduino Nano but it lacks the
onboard USB -TTL bridge and the USB port. Instead, it has a header, in which the UART pins are brought out. We can use
these pins to program the Pro mini using an external USB-UART module. This board is specially meant for applications
where the space is limited. Pro mini is available in two versions, 3.3V, and 5v versions. In the 3.3V version, the CPU speed
is limited to 8MHz because of certain limitations of ATMega328 for better stability.

Arduino Leonardo

Arduino Leonardo is powered by an ATmega32U4 chip rather than the ATMega328P chip which is used in all the
previously mentioned boards. It has more IO pins (20) and more PWM (7) and analog input (12) pins. One other major
difference is that the ATMega32U4 has built-in USB communication eliminating the need for a second processor or a
dedicated USB to UART bridge chip. This allows the board to connect to a computer as a Human Interface Device (HID) or
as a Virtual (CDC) serial / COM port. We use this Virtual COM port along with the bootloader to program the Leonardo.

Arduino Micro

Just like Arduino Nano is a UNO in a small form factor, Arduino Micro is actually a Leonardo in a small form-
factor breadboard-friendly sized board. Its functionalities are the same as the Arduino Leonardo. The only difference is
the lack of a DC input jack. Similarly, Arduino Micro can also act as an HID or Virtual COM port device.

Darshan(210670107015)
Arduino Nano Every

Arduino Nano Every is a new generation board in a small form factor. As we already discussed Arduino Nano is the
preferred board for many projects requiring a small and cheap solution. We could call the Arduino Nano Every,
an upgraded Arduino Nano with lot more features. Nano Every is powered by a more powerful processor ATMega4809.
It has 50% more program memory and a 200% bigger RAM which will enable us to muse this board for bigger programs.
The castellated holes allow us to use the Nano Every on a PCB without the need for the header pins.

Arduino Mega2560 Rev3

Arduino Mega 2560 is the biggest of all the boards we have discussed so far. It is designed for applications where a lot of I/O
or peripherals are needed. It is powered by a bigger and more capable processor the ATMega2560. This board has the greatest
number of I/O than most other boards, 54 I/O pins (of which 15 can be used as PWM outputs), 16 analog inputs, and 4 UARTs.
It has more flash storage and SRAM than most other basic Arduino boards. It is most popular with the opensource CNC and 3D
printer community as well as the opensource PLC community.

Darshan(210670107015)
(2) Define types of Cables.

1. Ethernet Cable

Ethernet cables are key to networking, in that they enable high-speed internet connectivity and data
transmission, generally over short range. These cables consist of twisted pairs of copper (or fiber-optic
couplings over long range). They provide reliable wired connections between computers, routers, switches, and
other network devices, generally within a node and rarely (now) between nodes. They are made to various
standards (Cat5e, Cat6, and Cat7) for incremental levels of data speed, cross talk, and signal integrity. Ethernet
cables are known for their stability, low latency, and resistance to interference, making them ideal for high-
speed data. They are the cornerstone of wired (non-optical) networking solutions, offering connection simplicity
and long-established low-cost precision. Figure 1 below shows details of an Ethernet cable:

2. HDMI Cable

HDMI (High-Definition Multimedia Interface) cables are central to the provision of high-quality audio and
video signals between source and display devices. These are a near-universal standardized interface to TVs,
monitors, and gaming consoles. HDMI cables support high-definition resolutions (4K, and even 8K) and
integrate audio information, eliminating the need for separate audio cables. They offer a reliable and versatile
solution for delivering sharp visuals and immersive (5+ channel) audio experiences, making them the choice for
home entertainment and professional audiovisual setups. Figure 2 below shows the typical form of an HDMI
cable:

HDMI cable. Image Credit: Shutterstock.com/Tungphoto

3. USB Cable

USB (Universal Serial Bus) cables are ubiquitous in digital applications, both mobile and installed. They have
become the most common connection method for low to moderate data rates, and lower-power devices. These

Darshan(210670107015)
cables are designed for data transfer and power delivery between computers, smartphones, tablets, cameras,
printers, etc. USB interconnects exist in a wide range of forms, including: USB-A, USB-B, USB-C, and micro
USB, each designed for specific device and connectivity needs as iterations in a rapidly developing sector. They
enable convenient, robust, moderate-rate data transfers, device charging, and peripheral connections across a
vast array of devices and systems. Figure 3 below shows connector details of some standard USB types:

4. VGA Cable

VGA (Video Graphics Array) cables were the primary mode for video connectivity for decades, as the near-
universal standard for connecting computers to monitors and projectors. They typically feature a 15-pin
connector and transmit video signals in resolutions up to 640 x 480 or 800 x 600 pixels. However, with the
advancement of digital technology, the analog VGA system has rapidly become uncommon, lacking support for
high-definition video. Still, VGA cables are found in legacy equipment. In current systems, digital provisions
such as HDMI and DisplayPort have virtually replaced VGA. Figure 4 below shows an example of a VGA
cable:

5. DVI Cable

DVI (Digital Visual Interface) cables offer video-interconnect that formerly held a pivotal role in high-quality
video transmission, supplanting VGA progressively. For a long time, dual-capability devices were the norm.
DVI exists in several variants, including: DVI-D (digital-only), DVI-I (integrated digital and analog), and DVI-
A (analog-only). DVI cables were widely used for connecting computer monitors, projectors, and HDTVs,
delivering sharp and detailed video signals in various resolutions, including Full HD (1080p). Its application has
virtually ended, in favor of more capable interfaces like HDMI and DisplayPort. DVI remains relevant in some
applications, especially for legacy devices, but it’s gradually being retired. Figure 5 below shows an example of
a DVI cable:

Darshan(210670107015)
(3) Install Arduino IDE in your system
Windows:
Download the Arduino IDE: Go to the Arduino website and download the Windows installer for the
Arduino IDE.

Run the Installer: Once the download is complete, run the installer. Follow the on-screen instructions
to complete the installation process.

Launch Arduino IDE: After installation, you can launch the Arduino IDE from the Start menu or
desktop shortcut.

macOS:
Download the Arduino IDE: Visit the Arduino website and download the macOS version of the
Arduino IDE.

Open the Disk Image: Locate the downloaded file (usually in the Downloads folder) and open it. Drag
the Arduino application into your Applications folder.

Launch Arduino IDE: Open the Applications folder and double-click on the Arduino application to
launch the IDE.

Linux:
Install from Package Manager (Recommended): Many Linux distributions offer the Arduino IDE in
their package repositories. You can install it using your distribution's package manager. For example,
on Ubuntu, you can use the following command:

sql
Copy code
sudo apt-get update
sudo apt-get install arduino
Download from Arduino Website: Alternatively, you can download the Linux version of the Arduino
IDE from the Arduino website. Choose the appropriate Linux package (32-bit or 64-bit) and extract
the downloaded file.

Run the Install Script: Navigate to the extracted folder and run the install.sh script as root:

bash
Copy code
cd <extracted_folder>
sudo ./install.sh
Launch Arduino IDE: Once installed, you can launch the Arduino IDE from the applications menu or
by typing arduino in the terminal.

After following these steps, you should have the Arduino IDE installed and ready to use on your
system. Let me know if you encounter any issues or need further assistance!

Darshan(210670107015)
(4) Explain Hardware and Software requirement for installation of Arduino
Hardware Requirements:
Computer: You'll need a computer to write, compile, and upload code to your Arduino board.
Arduino IDE (Integrated Development Environment) supports Windows, macOS, and Linux
operating systems.

Arduino Board: Choose the Arduino board that suits your project requirements. Common
options include Arduino Uno, Nano, Mega, etc.

USB Cable: Most Arduino boards can be connected to your computer via a USB cable. Make
sure you have the appropriate USB cable for your Arduino board.

Power Source (Optional): Depending on your project's requirements, you may need a power
source for your Arduino board. This could be a USB connection from your computer, a
battery pack, or an external power adapter.

Software Requirements:
Arduino IDE: This is the software used to write, compile, and upload code to Arduino boards.
It's available for free on the Arduino website and supports Windows, macOS, and Linux.

Device Drivers (if necessary): Depending on your operating system, you may need to install
drivers for the Arduino board to communicate with your computer. Usually, the Arduino IDE
includes drivers for most Arduino boards, but you may need to install them separately if your
OS doesn't recognize the board.

Installation Steps:
Download Arduino IDE: Visit the Arduino website and download the appropriate version of
the Arduino IDE for your operating system.

Install Arduino IDE: Follow the installation instructions provided for your operating system to
install the Arduino IDE on your computer.

Connect Arduino Board: Connect your Arduino board to your computer using a USB cable.

Install Device Drivers (if necessary): If your operating system requires drivers for the Arduino
board, follow the instructions provided to install them.

Launch Arduino IDE: Open the Arduino IDE that you installed on your computer.

Select Board and Port: In the Arduino IDE, go to Tools > Board and select the appropriate
Arduino board you're using. Then, go to Tools > Port and select the port to which your
Arduino board is connected.

Test Connection: To ensure that everything is set up correctly, you can upload a simple sketch
(e.g., Blink) to your Arduino board. If the upload is successful and the LED on your Arduino
blinks as expected, then your installation is complete.

Darshan(210670107015)
Experiment No: 2
(1) Try to implement with different types of LED

Code:-
// C++ code

//

void setup()

pinMode(LED_BUILTIN, OUTPUT);

void loop()

digitalWrite(LED_BUILTIN, HIGH);

delay(1000); // Wait for 1000 millisecond(s)

digitalWrite(LED_BUILTIN, LOW);

delay(1000); // Wait for 1000 millisecond(s)

Darshan(210670107015)
(2) Implement it with different type of Ardunio board and check the output
Code:-
#include <Servo.h>

int pos = 0;

Servo servo_9;

void setup()

servo_9.attach(9, 500, 2500);

void loop()

// sweep the servo from 0 to 180 degrees in steps

// of 1 degrees

for (pos = 0; pos <= 180; pos += 1) {

// tell servo to go to position in variable 'pos'

servo_9.write(pos);

// wait 15 ms for servo to reach the position

delay(15); // Wait for 15 millisecond(s)

for (pos = 180; pos >= 0; pos -= 1) {

// tell servo to go to position in variable 'pos'

servo_9.write(pos);

// wait 15 ms for servo to reach the position

delay(15); // Wait for 15 millisecond(s)

Darshan(210670107015)
Experiment No 3:-

Output:
Before Button Pressed: The LED will initially be OFF.
After Button Pressed: The LED state will toggle to ON if it was OFF, and it will
toggle to OFF if it was ON. It will continue to toggle its state with each
subsequent button press.

Darshan(210670107015)
Experiment No: 4

#include <iostream>

double celsiusToKelvin(double celsius) {

return celsius + 273.15;

int main() {

int numTemperatures;

std::cout << "Enter the number of temperatures to convert: ";

std::cin >> numTemperatures;

for (int i = 0; i < numTemperatures; ++i) {

double celsiusTemperature;

std::cout << "Enter temperature in Celsius: ";

std::cin >> celsiusTemperature;

double kelvinTemperature = celsiusToKelvin(celsiusTemperature);

std::cout << "Temperature in Kelvin: " << kelvinTemperature << " K" << std::endl;

return 0;

Result:-
input a temperature of 25 degrees Celsius
Enter the number of temperatures to convert: 1

Enter temperature in Celsius: 25

Temperature in Kelvin: 298.15 K

devani jay(210670107034)
Experiment No 5:-

1) When the value is Outside the Shadow (Open Space):

In an open space without any obstruction, the ultrasonic sensor will detect the distance to the
nearest object.
You'll observe accurate distance readings in the serial monitor.

2) When the value is Low in the Shadow:

In a shadowed area with low light, the ultrasonic sensor may struggle to detect objects
accurately due to decreased visibility.
You may observe fluctuating or inconsistent distance readings in the serial monitor.

3) When the value is High in the Shadow:

In a shadowed area with high light intensity, the ultrasonic sensor may still perform well, but
reflections and interference from surrounding objects or surfaces may affect its accuracy.
You may observe occasional variations or inaccuracies in the distance readings in the serial
monitor.

Darshan(210670107015)
Experiment No:6

1) Low Reading (Dark Environment):

In a dark environment, the resistance of the photoresistor will be high, resulting


in a low analog reading.
You'll observe a higher analog value (e.g., around 900-1023) in the serial
monitor, indicating low light intensity.

2) High Reading (Bright Environment):

In a bright environment, the resistance of the photoresistor will be low, resulting


in a high analog reading.
You'll observe a lower analog value (e.g., around 0-100) in the serial monitor,
indicating high light intensity.

devani jay(210670107034)
Experiment No:7

Result:
The NeoPixel ring will cycle through the defined colors (red, orange, yellow, green, dark
green, cyan, blue, magenta, purple) in a loop.
Each LED in the ring will illuminate with a different color in sequence, with a delay between
each color change determined by the delayval variable (currently set to 50 milliseconds).
After cycling through all the defined colors, it will start again from the beginning of the
sequence.
The brightness of the NeoPixel ring is set to 100 (out of 255) using
pixels.setBrightness(100);.

The loop will continue indefinitely, cycling through the colors until the Arduino is powered
off or the code is modified
.
Criteria:
1) Outside the Shadow:
The NeoPixel ring will cycle through the colors consistently regardless of lighting
conditions.
2) Low in the Shadow:
If the NeoPixel ring is in a shadowed area with low light, it will still cycle through the colors
as programmed
3) High in the Shadow:
Similarly, if the NeoPixel ring is in a shadowed area with high light intensity, it will still
cycle through the colors as programmed.

Darshan(210670107015)
Experiment No: 8
Code:-
Shorter On and Off Times:
void loop() { digitalWrite(13, HIGH);
Turn on the laser delay(500);
Wait for 0.5 second digitalWrite(13, LOW);
Turn off the laser delay(500);
Wait for 0.5 second }

Result: The laser will blink at a faster rate, staying on for 0.5 seconds and off for
0.5 seconds.

Darshan(210670107015)
Experiment No: 9

(1) Compare the Arduino and Rapberry Pi

Benchmark Arduino Raspberry Pi


It allows you to control the It allows you to compute data, generate valuable
What does it do? electronic parts attached to a outputs, and control components in a system based on
system’s circuit board. the results of its computation.
Yes. Both its hardware design and No. Both its hardware design and software are closed
Is it open-source?
software are open source. source.
Control unit is from
Atmega family ARM family
which family?
It is based on Microcontroller Microprocessor
Logic level 5V 3V
The structure of
hardware and Simple Complex
software is
RAM usage It uses less RAM (approx 2 kB) It uses more RAM (approx 1 GB)
The processor runs at
16 MHz 1.4 GHz
the speed of
CPU architecture 8 bit 64 bit
Cost It is cheaper than Raspberry Pi. It is more expensive than Arduino.
I/O current drive
High Low
strength is
Does it support
No Yes
Bluetooth and WiFi?
Traffic light countdown timers,
Applications Robot Controllers, Stop motion cameras, etc.
Weighing machines, etc.

Darshan(210670107015)
(2) Define the advantages and disadvantages of Raspberry Pi.

Advantage
1) Affordable: Raspberry Pi boards are relatively inexpensive, making them accessible to hobbyists,
students, and educators.
2) Versatile: Raspberry Pi boards can be used for a wide range of applications, including education,
home automation, media centers, gaming, robotics, and more.
3) Highly Customizable: Raspberry Pi's open-source nature allows users to customize and extend its
functionality using add-on boards (HATs), sensors, peripherals, and software.
4) Rich Connectivity: Raspberry Pi boards come with built-in support for various connectivity options,
including Wi-Fi, Bluetooth, Ethernet, USB, HDMI, GPIO pins, and camera interfaces.
5) Community Support: There is a large and active community of Raspberry Pi enthusiasts,
developers, and educators who contribute to forums, tutorials, projects, and open-source software

Disadvantages:
1) Limited Processing Power: Raspberry Pi boards are not as powerful as traditional desktop
computers or laptops, which may limit their performance for certain tasks, such as intensive gaming
or multimedia editing.
2) Limited RAM: Raspberry Pi boards typically come with limited RAM, which can affect their
multitasking capabilities and performance when running multiple applications simultaneously.
3) Learning Curve: Raspberry Pi requires some familiarity with Linux and software development,
which may have a steeper learning curve for beginners who are not accustomed to working with
command-line interfaces or programming.
4) Peripheral Compatibility: Some peripherals and accessories may not be directly compatible with
Raspberry Pi boards, requiring additional adapters or drivers to work properly.
5) Not Battery-Powered: Raspberry Pi boards require external power sources, which may limit their
portability compared to battery-powered devices like Arduino or microcontroller-based systems.
6) Security Concerns: Like any internet-connected device, Raspberry Pi boards may be vulnerable to
security threats if not properly configured or secured, especially when used in networked applications
or IoT (Internet of Things) projects.

Darshan(210670107015)
Experiment No:- 10

(1) Installation of Raspberry Pi by yourself and complete the configuration to develop and
deploy any application.
1. Hardware Setup:
Get a Raspberry Pi board (e.g., Raspberry Pi 4 Model B).
Obtain a microSD card (16GB or higher recommended) and a microSD card reader.
Connect peripherals: HDMI monitor, USB keyboard, USB mouse, and power supply (USB-C for
Raspberry Pi 4).
Insert the microSD card into the Raspberry Pi.

2. Operating System Installation:


Download the Raspberry Pi OS (formerly Raspbian) from the official website.
Use a tool like Etcher to flash the OS image onto the microSD card.

Eject the microSD card from your computer and insert it into the Raspberry Pi.
3. Initial Boot and Configuration:
Power on the Raspberry Pi.
Follow the on-screen prompts to set up the basic configuration (e.g., language, timezone, password).
Connect to a Wi-Fi network if necessary.
Once booted, open the terminal.
4. Update and Upgrade:
Run the following commands to update the package lists and upgrade installed packages:

bash
sudo apt update
sudo apt upgrade
5. Development Tools Installation:
Depending on your project needs, install the necessary development tools (e.g., Python, Node.js, Git):

bash

sudo apt install python3 python3-pip nodejs npm git


6. Additional Configuration:
Configure any additional settings based on your project requirements, such as enabling SSH, setting
up a static IP address, etc.
7. Application Development:

Darshan(210670107015)
You can now start developing your application using your preferred programming language and
frameworks.
Use the built-in GPIO pins for hardware interfacing if required.

8. Deployment:
Once your application is ready, you can deploy it on the Raspberry Pi.
If it's a web application, you might want to set up a web server like Apache or Nginx.
Ensure that your Raspberry Pi is accessible on the network if needed.
9. Monitoring and Maintenance:
Regularly update and maintain your Raspberry Pi by installing updates and monitoring its
performance.
Set up remote access tools like SSH for easier management.

10. Enjoy!
Enjoy using your Raspberry Pi for development and deployment purposes!

devani jay(210670107034)

You might also like