Unit 4 PPT Ipu
Unit 4 PPT Ipu
Internet of Things
Unit 4
on to (HIGH or LOW).
• Analog pins: For reading varying voltages (e.g., sensors).
Arduino • Programming via Arduino IDE: Users write code (sketches) and
upload it to the Arduino board using the Arduino Integrated
Development Environment (IDE).
Overview • Overview: The most popular and widely used Arduino board.
• Key Features:
of Arduino •
•
Microcontroller: ATmega328P
Digital I/O Pins: 14 (6 PWM pins)
Board
• Analog Input Pins: 6
• Operating Voltage: 5V
• Flash Memory: 32 KB
Types • Use Cases: Ideal for beginners and general-purpose projects like
LED control, motors, and basic sensors.
• Advantages: Easy to use, great community support, large
availability of shields.
of Arduino •
•
Microcontroller: ATmega2560
Digital I/O Pins: 54 (15 PWM pins)
Board •
•
Analog Input Pins: 16
Operating Voltage: 5V
Types
• Flash Memory: 256 KB
• Use Cases: Perfect for large-scale projects like robotics, home
automation, or projects requiring many sensors or actuators.
• Advantages: More pins and memory, ideal for complex or
multitasking projects.
of Arduino •
•
Microcontroller: ATmega328P
Digital I/O Pins: 14 (6 PWM pins)
Board •
•
Analog Input Pins: 8
Operating Voltage: 5V
Types
• Flash Memory: 32 KB
• Use Cases: Best for projects with space constraints (e.g., wearable
electronics, small robots).
• Advantages: Small form factor, ideal for breadboard use, similar
capabilities to Arduino Uno.
Arduino Due
Overview: A more advanced board based on a 32-bit ARM microcontroller, offering more computing power.
Key Features:
• Microcontroller: ATSAM3X8E (ARM Cortex-M3)
• Digital I/O Pins: 54 (12 PWM pins)
• Analog Input Pins: 12
• Operating Voltage: 3.3V (Different from most Arduino boards, which use 5V)
• Flash Memory: 512 KB
Use Cases: Suitable for high-performance applications like signal processing, audio processing, or
interfacing with advanced sensors.
Advantages: 32-bit architecture, higher processing speed, large memory, and more I/O pins.
• Arduino Leonardo
• Overview: Similar to the Arduino Uno, but with the ability to emulate a mouse
or keyboard.
• Key Features:
• Microcontroller: ATmega32u4
• Digital I/O Pins: 20 (7 PWM pins)
• Analog Input Pins: 12
• Operating Voltage: 5V
• Flash Memory: 32 KB
• Use Cases: Useful for projects that require direct communication with a
computer, such as creating custom keyboards or mouse emulators.
• Advantages: Built-in USB communication, easy-to-use for human-interface
projects.
25/02/2025 ECE Department 12
Overview of Arduino Board Types
• Microcontroller
• Definition: The microcontroller is the "brain" of the Arduino board, executing the
program written by the user.
• Common Microcontrollers:
• ATmega328P (Arduino Uno, Nano)
• ATmega2560 (Arduino Mega 2560)
• ATSAM3X8E (Arduino Due)
• ESP8266/ESP32 (Arduino MKR, NodeMCU for Wi-Fi projects)
• Function:
• Executes the code in the setup() and loop() functions.
• Controls inputs (from sensors) and outputs (to actuators).
• Role: Manages all the logic and calculations for the project.
• I/O Pins
• Digital I/O Pins:
• Digital Input/Output: Can be configured to read or send binary signals (HIGH/LOW).
• Examples: Turning LEDs on/off, reading button presses, controlling motors.
• Pin Count: Varies by board, e.g., 14 on Arduino Uno, 54 on Mega 2560.
• Analog Pins:
• Analog Input: Used to read varying voltage signals, such as from a temperature sensor.
• Example: Reading values from sensors that provide a range of data (e.g., temperature,
humidity).
• Pin Count: Typically 6–16, depending on the board.
• PWM (Pulse Width Modulation) Pins:
• Function: Allows analog-like output using a digital signal. Can control the brightness of
LEDs or the speed of motors.
• Pins on Uno: 6 pins support PWM.
• Communication Interfaces
• USB Interface:
• Function: Used to upload code to the Arduino and for serial communication between the Arduino and your
computer.
• USB-to-Serial Converter: On boards like the Uno, the USB port is connected to a serial-to-USB converter
(e.g., ATmega16U2).
• Serial Communication (UART):
• Function: Allows communication between the Arduino and other devices via serial protocols (RS232 or TTL).
• Used for: Debugging, sending/receiving data from sensors, or communicating with other microcontrollers.
• I2C (Inter-Integrated Circuit):
• Function: A protocol for connecting multiple devices (like sensors) over just two wires: SDA (data) and SCL
(clock).
• Advantages: Simple wiring for multiple devices, used for connecting sensors, displays, etc.
• SPI (Serial Peripheral Interface):
• Function: A protocol used for faster communication between the Arduino and external devices (e.g., SD card
modules, displays).
• Pins: Uses 4 pins—MISO, MOSI, SCK, and SS.
Reset Button:
• Function: Resets the Arduino, restarting the execution of the code.
• Use: Useful when troubleshooting or when you need to restart your
project.
ICSP (In-Circuit Serial Programming) Header:
• Function: Provides a method to program the microcontroller directly
through an external programmer (useful for advanced users).
• When to Use: For situations where the bootloader is damaged or
when uploading custom firmware.
USB: Used for communication with a computer for programming and serial
communication.
• USB Communication
• Purpose: The USB interface on Arduino is used for two main functions:
• Programming: Uploading Arduino sketches (programs) to the board from the
Arduino IDE.
• Serial Communication: Sending and receiving data between Arduino and the
computer for debugging or interacting with external programs.
• How It Works:
• Arduino boards like the Uno and Mega use a USB-to-serial converter (e.g.,
ATmega16U2) to establish communication with the computer.
• Serial Monitor: A feature in the Arduino IDE that allows you to view or send
data between the Arduino and your computer in real-time.
• Common Use Cases:
• Sending sensor data to the computer.
• Receiving commands from a PC or other devices.
25/02/2025 ECE Department 22
Introduction to Communication Interfaces
• Definition: SPI is a high-speed communication protocol used for data exchange between an Arduino and external peripherals like SD cards, displays, or
sensors.
• How It Works:
• MOSI (Master Out Slave In): Sends data from Arduino (master) to external device (slave).
• MISO (Master In Slave Out): Sends data from external device (slave) to Arduino (master).
• SCK (Serial Clock): Synchronizes the communication.
• SS (Slave Select): Selects the slave device for communication.
• Pins on Arduino:
• MOSI: Pin 11 (Uno), Pin 51 (Mega)
• MISO: Pin 12 (Uno), Pin 50 (Mega)
• SCK: Pin 13 (Uno), Pin 52 (Mega)
• SS: Pin 10 (Uno), Pin 53 (Mega)
• Advantages:
• Faster than I2C for high-speed data transfer.
• Good for applications requiring high-speed communication (e.g., SD cards, LCD screens).
Key Features:
• Code Editor: Write and edit Arduino sketches (programs).
• Compiler: Translates the code into machine language for the Arduino
microcontroller.
• Uploader: Sends the compiled code to the connected Arduino board.
• Serial Monitor: Used for debugging and viewing real-time data from the
Arduino.
25/02/2025 ECE Department 28
Introduction to Arduino IDE
• Installing the Arduino IDE
• Steps to Install:
• Download: Visit the official Arduino website and download the IDE
for Windows, macOS, or Linux.
• Install: Follow the installation prompts.
• Set up: After installation, connect your Arduino board to the
computer via USB.
• Requirements: Ensure your computer has the necessary drivers
installed (the IDE typically handles this automatically).
• Alternative: Use Arduino Web Editor (cloud-based) for programming
without installing software locally.
• Sketch: The term used for a program written in the Arduino IDE.
• Structure:
• setup() Function: Runs once when the Arduino is powered on or reset. Used for initialization (e.g., setting pin modes).
• loop() Function: Repeatedly runs after the setup function. This is where the main program logic resides (e.g., reading sensors, controlling outputs).
• Example Sketch:
• void setup() {
• }
• void loop() {
• }
Libraries: Arduino sketches can include libraries for additional functionality (e.g., controlling displays, sensors).
Serial Monitor:
• Purpose: Allows communication between the Arduino and the computer. It is essential for
debugging and displaying output from the Arduino.
• Access: Open the Serial Monitor via the button in the top-right corner of the IDE or by
selecting Tools > Serial Monitor.
• Settings: Set the baud rate (usually 9600 or 115200) to match the communication speed
between the Arduino and the IDE.
Keep Code Simple: Start with basic sketches and build complexity gradually.
Use Comments: Comment your code for clarity and to make it easier for others
(or yourself) to understand.
Debug with Serial Monitor: Use serial output for debugging and tracking
variable values.
Save Frequently: Save your sketches often to avoid losing work.
Explore Libraries: Take advantage of the many libraries available for sensors,
motors, and displays to speed up your development process.
• Open the downloaded installer (.exe file) to start the installation process.
• Follow the on-screen instructions:
• Choose the installation directory (default is usually fine).
• Select the option to install the USB driver if prompted (needed for communicating with your
Arduino board).
Step 3: Finish Installation
• Launch the IDE from the Start menu (Windows), Applications folder (macOS), or app
launcher (Linux).
Step 2: Connect Your Arduino Board
• Connect your Arduino board (e.g., Arduino Uno) to your computer using a USB cable.
• The Arduino IDE should automatically recognize the board.
• Tools > Board: Select the correct Arduino model (e.g., Arduino Uno, Arduino Mega).
• Tools > Port: Select the serial port where your Arduino board is connected.
• Go to File > Examples > Basics and select the Blink example.
• After uploading, the on-board LED (connected to pin 13 on most boards) should blink
on and off.
• This confirms the IDE is installed and the board is correctly connected.
• Check if the Arduino USB drivers are installed (install via the Arduino IDE installer).
• Verify the Arduino board is properly connected to the computer.
• Ensure you have permission to execute the Arduino IDE by using chmod to change file
permissions.
• On Linux, add your user to the dialout group for serial port access:bash
• Copy code
• sudo usermod -aG dialout $USER
• Then log out and log back in.
IDE Crashes:
• Check for missing dependencies or system updates, and try reinstalling the IDE.
Why Update?: The Arduino IDE receives regular updates for bug fixes, new
features, and board support.
How to Update:
• For Windows/macOS: Download and install the latest version from the official website (it will
overwrite the previous version).
• For Linux: Download and extract the latest tarball and follow the installation steps again.
Automatic Updates: For the Arduino Web Editor, updates are handled
automatically.
Verify Button:
• Icon: Checkmark.
• Function: Compiles the code and checks for syntax or logical errors. Errors and warnings will appear in the console.
Upload Button:
New/Save/Open Buttons:
• Board Selection: Choose the appropriate Arduino model under Tools > Board (e.g., Arduino
Uno, Arduino Mega).
• Port Selection: Choose the correct serial port under Tools > Port to which your Arduino is
connected.
Console:
• Displays feedback during code compilation and uploading. Shows errors, warnings, and progress.
• Can also display output from Serial.print() functions used in the sketch for debugging.
• Libraries: Access pre-written code to work with sensors, displays, motors, etc. (under Sketch >
Include Library).
• Examples: The IDE provides example sketches for common tasks like blinking LEDs, reading
sensors, etc. (under File > Examples).
Overview of a Sketch:
• Integer Types:
• int: Stores integer values (whole numbers), typically within the range of -32,768 to 32,767.
• Example: int buttonState = 0;
• long: Stores larger integer values, ranging from -2,147,483,648 to 2,147,483,647.
• Example: long counter = 100000L;
• Boolean Type:
• bool: Stores binary values (true or false).
• Example: bool isLightOn = true;
• Character Type:
• char: Stores a single character, enclosed in single quotes (e.g., 'A', '1').
• Example: char grade = 'A';
• Definition:
• An Arduino emulator is a software tool that simulates the behavior of an Arduino board on a computer, allowing you to write, test, and debug Arduino programs without needing actual hardware.
• Cost-effective: Saves on the cost of physical hardware for testing and learning.
• Convenience: Provides a way to experiment with code, especially when hardware components (e.g., sensors, motors) are unavailable or not connected.
• Educational: Ideal for beginners to practice coding and testing Arduino projects in a virtual environment before moving to real-world applications.
• Key Features:
• Virtual Board Simulation: Simulates the behavior of Arduino boards, including pin configuration, input/output operations, and digital/analog signals.
• Code Testing: Allows you to write and test code, upload it to the emulator, and check for errors.
• Debugging Tools: Some emulators include debugging features like breakpoints, variable watching, and code tracing.
• Tinkercad: A free, web-based tool by Autodesk for designing and simulating circuits with Arduino.
• Fritzing: Offers circuit design and Arduino simulation, useful for beginners.
• Limitations:
• Hardware Interactions: Emulators may not perfectly replicate all hardware interactions, especially with advanced sensors or real-time events.
• Limited Real-World Testing: Emulators can't fully replicate the physical world, so real hardware testing is necessary for complete validation.
• Proteus
• Description: A professional-grade simulation software used for both hardware and software simulation.
• Key Features:
• Supports Arduino programming and integrates with physical circuits.
• Can simulate analog and digital circuits, including microcontrollers.
• Includes advanced debugging tools and virtual instruments like oscilloscopes and logic analyzers.
• Pros:
• Suitable for both simple and complex projects.
• Offers full microcontroller simulation, including code and hardware interaction.
• Cons:
• Requires a paid license.
• Interface may be more complex for beginners.
• Fritzing
• Description: A tool that helps design circuits and simulate Arduino projects with easy-to-understand
visuals.
• Key Features:
• Offers both circuit design and basic simulation.
• Supports multiple Arduino boards and various components.
• Provides breadboard views for easy visualizing of circuits.
• Pros:
• Great for beginners and those learning circuit design.
• Open-source and free.
• Cons:
• Limited simulation capabilities compared to other tools like Proteus.
• SimulIDE
• Description: A simple, open-source emulator for Arduino and other electronics
projects.
• Key Features:
• Real-time simulation of circuits and Arduino code.
• Allows simulation of basic electronics components.
• Pros:
• Lightweight and fast.
• Free and open-source.
• Cons:
• Lacks advanced features for complex projects.
• The user interface is minimalistic.
Simulate Different
Test Simple
Scenarios: Test code
Projects: Great for
under different
testing basic projects
conditions (e.g., Hardware
like LEDs, sensors,
sensor values, timing) Validation:
and motors before
that would be hard to
finalizing designs with
reproduce in a
real hardware.
physical environment.
• Definition:
• An Arduino library is a collection of pre-written code that simplifies complex tasks or interacts with specific hardware components.
Libraries help streamline the development process by providing reusable functions and reducing the need to write low-level code from
scratch.
• Purpose of Libraries:
• Simplify Programming: Provide easy-to-use functions for controlling sensors, motors, displays, communication protocols (e.g., I2C, SPI),
etc.
• Enhance Code Readability: Encapsulate complex code into simple function calls, making the code easier to understand and manage.
• Expand Functionality: Enable the use of external components and protocols without needing deep hardware or low-level programming
knowledge.
• Types of Libraries:
1. Standard Libraries: Built into the Arduino IDE, such as Wire (for I2C), SPI (for SPI communication), and Servo (for controlling servos).
2. Third-Party Libraries: Developed by the Arduino community and available online (e.g., for sensors, displays, GPS modules). These
libraries can be downloaded from platforms like GitHub or the Arduino Library Manager.
1. Open the Arduino IDE: Launch the Arduino IDE on your computer.
Use Case:
Key Functions:
Creating colorful
Adafruit_NeoPix
lighting effects
el.begin(),
in projects like
setPixelColor(),
light displays or
show()
indicators.
Solutions:
• Ensure the correct library
name is used in the
Library Not Problem: The #include directive (check
for typos).
Found/Error on Arduino IDE can't • Make sure the library is
Include find the library. installed properly via
Library Manager or
manually from the correct
source.
• Check if the library is
placed in the
Arduino/libraries folder.
• Missing Dependencies
• Problem: Some libraries require other libraries to function.
• Solutions:
• Look at the error message: It often lists the missing
dependencies.
• Install any necessary libraries by searching for them in
Library Manager or manually downloading them.
• For third-party libraries, check their GitHub repository for a
list of dependencies.
Compiler Errors
• Problem: Errors in code due to incorrect library usage.
• Solutions:
• Check Library Function Calls: Ensure you are calling functions
correctly, with the right parameters.
• Refer to the library’s examples in the IDE or its documentation
to verify correct usage.
• Update the IDE: Make sure your Arduino IDE is up to date, as
some libraries may depend on newer versions of the IDE.
Library-Specific Errors
• Problem: Specific libraries may have known issues or bugs.
• Solutions:
• Search online for error-specific fixes or workarounds (e.g.,
GitHub Issues page).
• Check the library's documentation or community forums
for known bugs and solutions.
• What is Arduino?
• Arduino is an open-source electronics platform based on simple software and hardware.
• It provides a straightforward way to create interactive electronic projects using microcontrollers,
sensors, and actuators.
• Key Features
• Open Source: Both the hardware and software designs are open and free for anyone to use, modify,
and distribute.
• Easy-to-Use: Simplifies electronics and programming for beginners while offering advanced features
for professionals.
• Cross-Platform: Works on Windows, macOS, and Linux operating systems.
• Affordable: The hardware is inexpensive, making it accessible for hobbyists, educators, and makers.
• Components of Arduino
• Arduino Board: The physical hardware, such as the Arduino Uno,
that contains a microcontroller to process inputs and control outputs.
• Arduino IDE: The software environment used to write, compile, and
upload programs (or "sketches") to the board.
• Libraries: Pre-written code to simplify working with sensors, motors,
displays, and other devices.
• Community Support: A large, global community that shares
projects, tutorials, and troubleshooting tips.
• Applications of Arduino
• Prototyping: Quickly build and test prototypes for new electronic devices.
• IoT Projects: Connect devices to the internet for remote monitoring and control (e.g., smart homes,
weather stations).
• Robotics: Create robots with sensors, motors, and decision-making algorithms.
• Educational Tools: Teach electronics, programming, and problem-solving through hands-on
projects.
Why Choose Arduino?
• Versatility: Suitable for projects ranging from simple LED blinkers to complex IoT systems.
• Ease of Use: Ideal for beginners but powerful enough for advanced users.
• Scalability: Easily integrate new sensors, devices, and communication protocols as projects evolve.
Key Features:
Use Case:
Purpose: Provides Typically includes a Purpose: Provides
Displaying sensor
Arduino LCD a simple interface 16x2 or 20x4 Arduino GPS GPS functionality to
data, user
Shield for adding an LCD character LCD and Shield Arduino projects for
interfaces, or
display to projects. a keypad for user location tracking.
project status.
input.
• Types of Actuators
1. Motors: Convert electrical energy into mechanical movement.
1. Example: DC motors, servo motors, stepper motors.
2. Connection: Use motor driver shields or H-bridge circuits for control.
2. LEDs: Convert electrical signals into light.
1. Example: Basic LEDs, RGB LEDs.
2. Connection: Connect to digital output pins with appropriate resistors to limit current.
3. Relays: Control high-power devices (like lights or appliances) using the low-power Arduino signal.
1. Example: 5V relay module for switching lights on/off.
2. Connection: Connect to digital output pins with a relay module.
4. Solenoids: Electromechanical devices that create linear motion.
1. Example: Locking mechanisms, robotic grippers.
2. Connection: Use transistors or relay shields to control solenoids with Arduino.
• Use Case: Display sensor readings, real-time clock, or user interface for control.
• Relay Modules
• Purpose: Control high-voltage appliances (e.g., lights, motors) safely using low-voltage control from Arduino.
• Use Case: Home automation, controlling devices remotely, or switching high-power devices.
• Sleep Mode: Allows the microcontroller to enter a low-power state when not actively processing.
• Example: Using LowPower library to put the Arduino into sleep mode between sensor readings.
• Turn Off Unused Components: Disable sensors, LEDs, and motors when not needed.
• Example: Use transistors or relays to cut off power to peripherals.
• PWM Control: Use Pulse Width Modulation (PWM) to control motor speed or LED brightness, reducing power use.
• Example: Use analogWrite() to control the power delivered to devices like motors or LEDs.
1 2 3 4
Power Saving with Reduce Processing Use of Low-Power Communication
Arduino Code Time: Libraries Protocols: Use I2C over
• Minimize unnecessary loops • LowPower library: A library SPI for low-power
and delays in the code to save that simplifies implementing sensor communication
processing power. low-power modes for Arduino (I2C uses less power
• Example: Use interrupts projects.
instead of delay() to reduce • Example: LowPower.sleep() to with fewer wires).
power consumption. put the Arduino to sleep.
What is IoT?
Sensors/Actuators: Collect and control data (e.g., temperature sensors, motion sensors,
actuators like motors, or LEDs).
Microcontroller (Arduino): Processes data from sensors and communicates with external
systems.
Connectivity Modules:
• Wi-Fi (ESP8266/ESP32): Enables Arduino to connect to the internet.
• Bluetooth (HC-05, HC-06): For short-range wireless communication.
• LoRa, GSM, or Zigbee: Alternative long-range wireless communication protocols.
Cloud/Server: Data storage and remote control (e.g., ThingSpeak, Blynk, Google Firebase,
custom servers).
Cloud Communication:
Software:
• Read data from the sensor.
• Send data to ThingSpeak using Wi-Fi for real-time monitoring.
• Display data in a graph on a web dashboard.