EXPERIMENT NO : 1
Subject : Internet Of Things
Topic: Understanding Arduino Uno
 Batch: B2       Subject Teacher:
                 Anil Sir
   Name:         SPN:
                          Arduino Uno
       What is an Arduino?
 Arduino is an open-source electronics platform based
on easy-to-use hardware and software.
Arduino boards can interface with a wide range of
sensors, such as temperature sensors, humidity sensors,
motion detectors, light sensors, and more. These sensors
collect data from the physical world and provide
valuable information for IoT applications.
 Arduino Uno uses “ATMega328P” microcontroller as its
brain.
                              Arduino
         Structure of Arduino Uno
                              Uno
USB - B Socket:- The USB socket on the UNO has two
  functions. One is for communication, to connect with the
  computer through a USB port, and also to load the firmware
  into the Arduino with the help of the bootloader. The
  second is to power the Arduino. You can use the USB port
  to power the Uno directly from any USB port.
ISCP Pins :- In the UNO you can f ind two 6 pin
  connectors. One is near the USB – TTL Chip and the other
  one is at the end of the board. These pins are used to
  program those two microcontrollers. The USB – TTL chip on
  this board is an ATMgega16U. The connector marked as 1
  is used to program the USB-TTL f irmware into this chip. And
  the connector marked as 2 is used to burn the bootloader
  into the ATMega328 microcontroller.
Reset Button :-As the name indicates this tactile switch is
 used to reset the ATMega328 microcontroller. It’s connected
 to the PC6/Reset pin, which is pulled up through a 10K.
                                                   ArduinoUn
                                                   o
USB-TTL Interface Chip :-To communicate with the computer, the Arduino relies on a USB-TTL interface. In UNO, ATMega16U with
 custom f irmware act as a USB – TTL interface chip.
Crystal Oscillator/ Ceramic resonator:- For a microcontroller to work it needs a clock source. The clock circuit
 determines the speed with which the microcontroller operates. The ATMega series microcontrollers can use two types of clock
 sources The ATMega series microcontrollers can use two types of clock sources. But the drawback of using the internal oscillator is .
 That is where the second option comes into place, i.e., using an external clock generator. that its maximum frequency is limited The f irst
 one is a 16MHz crystal oscillator used for the ATMega16U2 chip and the second one is a 16MHz resonator used for the ATMega328P
 microcontroller.
Power Path control:-If you inspect a UNO, you can f ind an LM358. It’s used as a comparator to control the input power path.
Voltage Regulator:-The ATMega328 and ATmega16U2 have a maximum input voltage of around 5V and most modules or accessories work
 on either 5V or 3.3V. The Arduino can accept 7-12V through the Vin pin or the DC barrel jack. So, to step it down, there are two regulators
 onboard. One is a 5V regulator (marked as 1) for the microcontrollers and the other one is a 3.3V regulator which is used to provide 3.3V
 through 3.3V pin.
                                                  Arduino
                                                  Uno
DC Barrel Jack :-The DC barrel jack is used to supply power to the UNO. We can supply 7-12V through it and hence we can use a 12V DC
  adapter or 9V DC adapter on this Jack to power the Arduino board.
Digital and Analog I/O :-The Arduino UNO has 14 digital I/O pins and 6 Analog inputs. The digital I/O pins are 5V logic level and you can
  also use the Analog pins as digital I/O too. Arduino UNO supports 6 channel 10 bit ADC inputs through A0-A5, which can be
  sampled and analyzed using UNO.
Status LEDs and Inbuilt LED:-Uno has 4 LEDs onboard. One is used as a power indicator and two are used to show the activity of the
  Rx and Tx pin. The other one is tied to the Digital pin 13, which can be used to test the Arduino board or simply as an indicator.
ATMega328P - The Brain :- Last but not least is the main component on the Arduino board - the ATMega328P Microcontroller.
  UNO uses a 28Pin DIP version of ATMega328P. Atmega328P is pre-programmed with a bootloader that allows you to
  directly upload the program to Arduino through USB without the need for an external programmer.
                                              Arduino
                                              Uno
             Block Diagram / Architecture
1.   Name:    Block[Watchdog      Timer,   Watchdog     Oscillator,   Power
     Supervision]
2.   Name: Block[, debug WIRE, Program Logic]
3.   Name : Block[8-Bit T/C 0,2,16-Bit T/C 1, A/D Convertor]
4.   Name : Block[Port D, Port B, Port C, External Pins of the architecture]
5.   Name [Analog Comparator, Internal Bandgap, Data Bus]
6.   Name : Block[USART 0, SPI, TWI]
7.   Name : Block[Flash, SRAM,EEPROM, AVR CPU]
8.   Name : : Oscillator Circuit/Clock Generator, On-Board
9.   Specif ications of Arduino uno
                          Features of Arduino Uno
The Arduino Uno is a popular microcontroller board based on the ATmega328P. It is widely used for electronics
projects and prototyping due to its simplicity and versatility. Here are its key features:
Hardware Specifications
   1. Microcontroller: ATmega328P.
   2. Operating Voltage: 5V.
   3. Input Voltage (recommended): 7-12V.
   4. Input Voltage (limit): 6-20V.
   5. Digital I/O Pins: 14 (of which 6 provide PWM output).
   6. Analog Input Pins: 6.
   7. DC Current per I/O Pin: 20 mA.
   8. Flash Memory: 32 KB (ATmega328P).0.5 KB used by the bootloader.
   9. SRAM: 2 KB (ATmega328P).
   10. EEPROM: 1 KB (ATmega328P).
   11. Clock Speed: 16 MHz.
   12. USB Port: For programming and communication.
   13. Reset Button: To restart the program running on the board.
   14. Power Jack: For external power supply (via a barrel jack).
   15. ICSP Header: For direct programming of the microcontroller.
   16. LED (Pin 13): Built-in LED for testing and debugging.
Connectivity
USB interface for uploading code and communication with a computer.
Serial communication (UART) via pins 0 (RX) and 1 (TX).
Programming
Programmable via the Arduino IDE, which supports C and C++.
Bootloader for easy USB-based programming without external hardware.
Other Features
Compact Size : Easy to integrate into projects (dimensions: 68.6 mm × 53.4 mm).
Compatible Shields : Wide variety of expansion boards (shields) for added functionality
 (e.g., motor control,sensors, Wi-Fi, Bluetooth).
Community Support : Extensive online resources, tutorials, and an active community.
The Arduino Uno is beginner-friendly and suitable for various projects, including robotics, IoT and
sensor-based applications.
                    Arduino Uno
    Name
•   Power Supervision (POR/BOD & RESET):Power-On Reset (POR):
    Ensures the microcontroller starts executing instructions only after the
    supply voltage reaches a safe level. Brown-Out Detection (BOD):
    Protects the system from low-voltage conditions by resetting the
    microcontroller. RESET Logic: Handles external or internal reset events.
    Watchdog Timer : The Watchdog Timer operates
•   independently of the CPU to monitor system operation: If the system
    becomes unresponsive, the Watchdog Timer forces a reset.
    Applications periodically clear the timer to prevent resets. Watchdog
    Oscillator: A dedicated low-power clock source for the Watchdog Timer.
•   Ensures the timer operates even if the main clock fails.
                                                                  Back >>
                    Arduino Uno
    Name
•   Debug WIRE: The debug WIRE is a debugging interface provided by Atmel
    (now part of Microchip) for AVR microcontrollers, such as the ATmega328P.
    It is a lightweight, low-pin-count alternative to traditional debugging
    protocols like JTAG and is specif ically designed for smaller
    microcontrollers with limited pin availability
    Program Logic: Handles f lash memory programming via in- system
•   programming (ISP) interfaces. Allows the user to program or
    reprogram the device without removing it from the circuit.
                                                                 Back >>
                    Arduino Uno
    Name
•   8-bit T/C (T/C0 & T/C2) :Operates with an 8-bit resolution (counts
    from 0 to 255).Can be used for : Generating time delays . Counting
    external events. Generating PWM (Pulse Width Modulation) signals.
    16-bit Timer/Counter (T/C 1):Operates with a 16-bit resolution (counts
•   from 0 to 65,535).Offers higher accuracy and longer timing intervals.
    Features include input capture, output compare, and PWM modes.
    Analog-to-Digital Converter (ADC):Converts analog input signals
    (e.g., voltage from a sensor) into digital values for processing.
•   Features multiple channels to support multiple input signals. Can
    use an internal or external reference voltage for accuracy.
                                                               Back >>
                     Arduino Uno
    Name
•   I/O Ports(PORTD, PORTB, PORTC):General Purpose
    Input/Output (GPIO):Conf igurable as input or output. Can
    source or sink current for driving LEDs, reading switches, etc. Pin
    Functions: Multiplexed to support additional features like ADC, SPI,
    USART, or PWM outputs.
•   External Connections:
•   AVCC: Power supply for analog circuitry (ADC, analog         comparator).
    AREF: Analog reference voltage for ADC.
•   XTAL1/XTAL2: Pins for connecting external crystal oscillators for precise
•   timing.
    RESET Pin: Allows an external reset signal to restart the
•
    microcontroller.
    ADC Pins: Dedicated pins for reading analog input signals.
•
                                                                     Back >>
                    Arduino Uno
   Name
• Analog Comparator: Compares two analog voltages and           generates
  a digital output.
• Useful for: Detecting voltage thresholds. Zero-crossing      detection in
  AC signals.
• Internal Bandgap Reference: A precise internal voltage source. Used by
  the ADC to provide a stable reference voltage for
  accurate conversions. Used by the BOD module to determine low-
  voltage conditions.
• Data Bus: The backbone of the microcontroller, interconnecting the CPU,
  memory, and peripherals. Ensures ef ficient and fast
  data transfer across the system.
                                                                  Back >>
                    Arduino Uno
   Name
• SPI (Serial Peripheral Interface): A synchronous serial
  communication protocol. Operates in master/slave mode, ideal for high-
  speed communication with devices like memory chips, sensors, or other
  microcontrollers.
• USART (Universal Synchronous/Asynchronous Receiver
  Transmitter):Provides serial communication capability for data exchange
  with PCs or other devices . Supports both synchronous (requires a clock
  signal) and asynchronous (e.g., UART) modes.
• TWI (Two-Wire Interface):Implements the I2C protocol. Allows multiple
  devices to communicate overjust two lines (SCL and
  SDA).Used in systems with multiple peripherals like sensors and displays.
                                                                   Back >>
                   Arduino Uno
    Name
• AVR CPU: Executes the program and manages all the
  operations. This CPU uses the Flash & SRAM to store the output and
  access the memory stored for execution.
• Flash [Memory]: Flash is atype of memory which is used to store
  Program data. The Flash memory capacity is 32Kbytes. The f lash
  memory has an endurance of 10,000 writes/erase       cycle
  SRAM[Memory]: SRAM stands for Static Random Access
• Memory. It used to store data that is needs to be accessed by the CPU.
  EEPROM: It stands for Electrically Erasable Programmable ROM. It is used
  to store memory when the board is powered off.
•
                                                                Back >>
                    Arduino Uno
   Name
• Oscillator Circuits/Clock Generation: The clock system
  provides timing for the entire microcontroller. Types include:
• Internal RC Oscillator: A low-cost, self-contained clock source. Offers
  moderate accuracy.
• External Crystal Oscillator: Requires a crystal or resonator connected
  to the XTAL1/XTAL2 pins. Provides high precision, suitable for time-
  critical applications.
• PLL (Phase-Locked Loop): Some AVRs include a PLL for             generating
  higher clock frequencies.
                                                                    Back >>
                                           Arduino
                                           Uno
    Know about
ATMEGA328P
ATMEGA328P is a 28-Pin Microcontroller which is used to handle Read and
  Write data to & from any Sensor or Module.
This IC is the Brains of the Arduino Uno, We can also use such IC on its own.
  Which can make your projects compact and The Arduino Uno Board reuseable.
This IC is developed by ATMEL company. It is a 8-bit RISC processor with a
  Harward Processor.
             Arduino Uno
Pinouts / Pin Diagram
                                                  Arduino Uno
                                               Pin function of
                                          ATMEGA328P
             Port D Alt. Fun.
1.   PD0(RXD) [Pin-2]: It is a USART for Receiving. {Input}
2. PD1(TXD) [Pin-3]: It is a USART for Transmission. {Output}
3. PD2(INT0) [Pin-4]: It is used an external interrupt. {Input 0}
4. PD3(OC2B/INT1) [Pin-5]: It is used as an external interrupt{Input 1} and as a
    Timer/Counter ‘2’ {output} compare/match register B {output}.
5. PD4(XCK/T0) [Pin-6]: Used as a External Clock for USART
    {Output/Input}, Timer/Counter 0 external counter {Input}
6. PD5(OC0B/T1) [Pin-11]: Timer/Counter 1 external counter {Input}, it is
    also a Timer/Counter ‘0’ {output} compare/match register B {output}.
7. PD6(OC0A/AIN0) [Pin-12]: It is used as a Counter ‘0’ {output}
     compare/match register A {output}.
8. PD7(AIN1) [Pin-13]:AIN1 it is a Analog Comparator {Negative Input}
                                            Arduino Uno
                                      Pin function of ATMEGA328P
           Port B Alternate Functions:
1. PB0(CLKO/ICP1) [Pin-14]: CLKO is a divided system clock            {Output},ICP1 is a
    Timer/Counter1 {Input} capture input.
2. PB1(OC1A) [Pin-15]: It is a Timer/Counter ‘1’ {Output}           Compare/match ‘A’
    Output.
3. PB2(OC1B/SS) [Pin-16]:OC1B is a Timer/Counter ‘1’ {Output}        Compare/match ‘A’
    Output, SS is a SPI Master-Slave Select.
4. PB3(M0SI/OC2A) [Pin-17]: MOSI is a SPI bus master output/slave
     input.
5. PB4(MISO) [Pin-18]: MISO is a SPI Bus master input/slave
    output.
6. PB5(SCK) [Pin-19]: SPI Bus Master Clock Input
7. PB6(TOSC1) [Pin-9]: Timer Oscillator Pin1
8. PB7(TOSC2) [Pin-10]: Timer Oscillator Pin2
                                                      Arduino Uno
                                                    General Function of the
                                        Pins
1. Power (Pin 7 & 20): Vcc is the input DC Voltage Pin, AVcc is used to provide
     power to the ADC Circuit.
2. GND (Pin 8 & 22): Ground.
3. PC6 / Reset (Pin 1): PC6 / Reset is used as a Reset input.
4.   PD[0-7] (Pins: 2-6,11-13): It is used as a Digital I/O Pin.
5.   PB[0-5] (Pins:14-19) : It is used as a Digital I/O Pin.
6.   PC[0-5] (Pins:23-28): It is used as a Analog I/O Pin.
7. PB6&PB7 (XTAL1 & XTAL2): It used to connect an external          oscillator.
8. AREF (Pins: 21) : Its used as a Analog reference.
            Port C Alternate Functions:
1. PC4(SDA) [Pin-27]: This pin is a 2-wire Serial Bus Clock Line
              2. PC5(SCL) [Pin-28]: This pin is a 2-wire Serial Bus Data Line {Input/Output}
Pin No.   Pin name       Description     Secondary Function
1         PC6 (RESET)    Pin6 of PORTC   Pin by default is used as RESET pin. PC6 can only
                                         be
                                         used as I/O pin when RSTDISBL Fuse is programmed.
2         PD0 (RXD)      Pin0 of PORTD   RXD (Data Input Pin for USART)
                                         USART Serial Communication Interface
                                         [Can be used for programming]
3         PD1 (TXD)      Pin1 of PORTD   TXD (Data Output Pin for USART)
                                         USART Serial Communication Interface
                                         [Can be used for programming]
                                         INT2( External Interrupt 2 Input)
4         PD2 (INT0)     Pin2 of PORTD   External Interrupt source 0
5         PD3            Pin3 of PORTD   External Interrupt source1
          (INT1/OC2B)
                                         OC2B(PWM - Timer/Counter2 Output Compare
                                         Match B Output)
6         PD4 (XCK/T0)   Pin4 of PORTD T0( Timer0 External Counter Input)
                                         XCK ( USART External Clock I/O)
7         VCC                            Connected to positive voltage
8    GND                             Connected to ground
9    PB6             Pin6 of PORTB XTAL1 (Chip Clock Oscillator pin 1 or External clock
     (XTAL1/TOSC1)                   input)
                                     TOSC1 (Timer Oscillator pin 1)
10   PB7             Pin7 of PORTB XTAL2 (Chip Clock Oscillator pin 2)
     (XTAL2/TOSC2)                   TOSC2 (Timer Oscillator pin 2)
11   PD5             Pin5 of PORTD   T1(Timer1 External Counter Input)
     (T1/OC0B)
                                     OC0B(PWM - Timer/Counter0 Output Compare
                                     Match B Output)
12   PD6             Pin6 of PORTD AIN0(Analog Comparator Positive I/P)
     (AIN0/OC0A)
                                     OC0A(PWM - Timer/Counter0 Output Compare
                                     Match A Output)
13   PD7 (AIN1)      Pin7 of PORTD AIN1(Analog Comparator Negative I/P)
14   PB0             Pin0 of PORTB   ICP1(Timer/Counter1 Input Capture Pin)
     (ICP1/CLKO)
                                     CLKO (Divided System Clock. The divided system
                                     clock can be output on the PB0 pin)
15   PB1 (OC1A)      Pin1 of PORTB OC1A (Timer/Counter1 Output Compare Match A
                                     Output)
16   PB2 (SS/OC1B)   Pin2 of PORTB SS (SPI Slave Select Input). This pin is low when
                                     controller acts as slave.
                                     [Serial Peripheral Interface (SPI) for programming]
                                     OC1B (Timer/Counter1 Output Compare Match B
                                     Output)
17   PB3             Pin3 of PORTB   MOSI (Master Output Slave Input). When controller
     (MOSI/OC2A)                     acts as slave, the data is received by this pin. [Serial
                                     Peripheral Interface (SPI) for programming]
                                     OC2    (Timer/Counter2      Output   Compare    Match
                                     Output)
18   PB4 (MISO)      Pin4 of PORTB   MISO (Master Input Slave Output). When controller
                                     acts as slave, the data is sent to master by this
                                     controller through this pin.
                                     [Serial Peripheral Interface (SPI) for programming]
19   PB5 (SCK)       Pin5 of PORTB SCK (SPI Bus Serial Clock). This is the clock
                                   shared
                                     between this controller and other system for accurate
                                     data transfer.
                                     [Serial Peripheral Interface (SPI) for programming]
20   AVCC                            Power for Internal ADC Converter
21   AREF                            Analog Reference Pin for ADC
22   GND                          GROUND
23   PC0 (ADC0)   Pin0 of PORTC   ADC0 (ADC Input Channel 0)
24   PC1 (ADC1)   Pin1 of PORTC ADC1 (ADC Input Channel 1)
25   PC2 (ADC2)   Pin2 of PORTC   ADC2 (ADC Input Channel 2)
26   PC3 (ADC3)   Pin3 of PORTC   ADC3 (ADC Input Channel 3)
27   PC4          Pin4 of PORTC ADC4 (ADC Input Channel 4)
     (ADC4/SDA)
                                  SDA (Two-wire Serial Bus Data Input/output Line)
28   PC5          Pin5 of PORTC ADC5 (ADC Input Channel 5)
     (ADC5/SCL)
                                  SCL (Two-wire Serial Bus Clock Line)
---
Let me know if you'd like to focus on any specific
block!
                    Here's a detailed explanation of each block in the
                    ATmega328 block diagram and its function:
                    ---
  Function: The central processing unit executes instructions, performs arithmetic
  and logic operations, and controls the flow of data between other blocks.
                    ---
Function: Stores the program code. It is non-volatile, meaning the data persists even
after power loss. The capacity is 32KB.
Function: Temporary storage for variables and data used during program
execution. The capacity
                 ---    is 2KB
Function: Stores user data that needs to persist after power off. The capacity is 1KB.
                            ---
  Function: Provides the timing reference for all internal operations. It supports external and
  internal clock sources, including a 16MHz crystal oscillator.
                            ---
 Function: Ensures proper operation of the microcontroller by managing power
 supply, enabling reset, and protecting against low-voltage conditions using Brown -Out
 Detection (BOD).
                            ---
Function: Monitors the system for unresponsiveness and resets the microcontroller if
necessary to ensure
                --- reliability.
Function: Interfaces the microcontroller with external devices like LEDs, switches, or sensors.
The pins can be configured as input or output.
                  ---
                  ---
  Function: Provide timing functions, delay generation, event
  counting, and Pulse Width Modulation (PWM) signals.
  TC0: 8-bit timer.
  TC1: 16-bit timer.
  TC2: 8-bit timer.
Function: Converts analog signals (from sensors) into digital data with
10-bit resolution. It supports up to 8 input channels.
                      ---
Function: Handles serial communication with external devices or
computers, such as sending and receiving data asynchronously.
                 ---
Function: Facilitates high-speed synchronous data communication
with peripherals like sensors, displays, or memory.
                 ---
     -Two wire    Interface
Function: Allows low-speed communication with multiple
peripherals using just two wires (SDA and SCL).
                 ---
Function: Detects external events, such as button
presses, and triggers immediate execution of an
interrupt service routine.
              ---
Function: Compares two analog voltages and
outputs a digital signal based on the comparison.
              ---
Function: Provides reference voltages for the ADC, brown-out detection, and other internal modules.
1. ADC Reference Voltage: Analog-to-Digital Converters (ADCs) require a reference voltage to
     accurately convert analog signals to digital values.
•       Internal references provide a stable and precise voltage source to ensure consistent and
     reliable ADC performance.
2. Brown-Out Detection (BOD): BOD circuits monitor the supply voltage and ensure the system
     operates correctly- -within
                          -      specified voltage ranges.
•       Internal references help by providing a fixed threshold voltage against which the supply
     voltage is compared.
3. Oscillator and Other Modules: Certain modules, such as internal oscillators or power- on-reset
   circuits, use internal reference voltages for calculation and reliable operation.
    Function: Enables on-chip debugging and programming through a single wire interface.
    •On-Chip Debugging: DebugWire allows developers to perform real-time debugging on
    AVR microcontrollers, enabling features like breakpoints, step-through code execution,
    and memory inspection.
    • Programming Interface: In addition to debugging, DebugWire can program the micro-
    controller’s flash memory and EEPROM, reducing the need for a separate programming
    interface.
    • Single-Wire Operation: The protocol communicates over the RESET pin, minimizing the
    number of required pins and simplifying PCB design.
                         Arduino Uno
                            Specif ications of Arduino uno
               Microcontroller                             ATmega328
Clock Speed                                 16MHz
Operating Voltage                           5V
Maximum supply Voltage (not                 20V
recommended)
Supply Voltage (recommended)                7-12V
Analog Input Pins                           6
Digital Input/Output Pins                   14
DC Current per Input/Output Pin             40mA
DC Current in 3.3V Pin                      50mA
SRAM                                        2KB
EEPROM                                      1KB
Flash Memory                                32KB of which 0.5KB used by boot loader
                                                                                      Back >>
        Features of
        ATmega328p
   • Processor 8-bit AVR microcontroller.
   • Input output pins 23 programmable.
   •Operating voltage typically 5 volt volts.
   •Vcc in pin number 7.
   •Ground pin pin 8 and 22 reset pin -pin 1.
1) Flash memory: 32KB of flash memory for storing program Eg - it store the instructions give by the Mt
2) SRAM: 2KB OF SRAM for Storing data (cache memory)
3) EEPROM: 1KB OP EEPROM for storing data that needs to be Retained Even when the power is turn off
4) ADC: 10-bit analog-to-digital converter reading analog signals (1024)
5) Interrupt system: External and internal interrupts for responding to events.
6) Power saving modes: Several power saving modes for reducing power consumption when the
microcontroller is not in use.
7) PUM: 6-channel pulse-width modulation for controlling the speed of motors and other devices.
8) USARI: Universal synchronous/ asynchronous receiver/transmitter for serial communication.
9) SPI: Serial peripheral interface for high-speed communication with other devices.
10) IQC: Inter-integrated circuit interface for low-speed communication with other devices.
11) Timer/counters: Three 16-bit timer/ counters for timing events and generating interrupts
These features make the ATmega328 a versatile
and powerful microcontroller that can be used for a
wide variety of applications, such as:
1)Robotics: Controlling robots and other automated
devices.
2)Home automation: Controlling lights, appliances,
and other devices in the home.
3)Data logging: Collecting and storing data from
sensors.
4)Prototyping: Creating and testing new electronic
devices.
5)Educational projects: Learning about electronics
and programming.