0% found this document useful (0 votes)
10 views

IoT_PPT04_Intro_Arduino_Board_and_IDE

Uploaded by

Md. Farabi Hasan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

IoT_PPT04_Intro_Arduino_Board_and_IDE

Uploaded by

Md. Farabi Hasan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Internet of Things

Introduction to Arduino
Arduino UNO Board & IDE

Thanks to Dr. Manas Khatua


What is Arduino?
• Arduino is an open-source electronics platform
– based on easy-to-use hardware and software.

• It was born at Interaction Design Institute Ivrea, Italy


– an easy tool for fast prototyping
– aimed at students without any background in electronics and programming.

• These boards are incorporated with microcontrollers


– To execute a small program, to receive input, to apply action on real world

• It has the capability to act as an interface for electrical and electronic systems

• These boards are used extensively because:


– Inexpensive
– Cross-platform – runs on Windows, Mac OS, and Linux OS.
– Easy-to-use hardware and software environment
– Open source hardware and software IDE
– Capable to interact with other boards and computers
– Can interact with sensors and actuators
– Facilitate serial communication

09-08-2023 2
Types of Arduino Boards
• Entry Level - easy to use and ready to power your first
creative projects.
– Arduino UNO
– Arduino Nano
– Arduino Micro
Arduino UNO
• Enhanced Features - boards with advanced
functionalities, or faster performances
– Arduino Zero
– Arduino Mega 2560
– Arduino Motor Shield

Arduino Mega 2560


• Internet of Things - Make connected devices easily with
one of these IoT products
– Arduino Nano 33 IoT
– Arduino Nano 22 BLE
– UNO WiFi REV2

Source: https://www.arduino.cc/ Arduino Nano 33 IoT


09-08-2023 3
Arduino UNO
• Arduino UNO is a Single board Microcontroller based on ATmega328P Processor
– a product of Atmel (now Microchip)
– 32 - represents it’s flash memory capacity that is 32KB
– 8 - represents it’s CPU type that is of 8 bit
– p - simply denotes picoPower (i.e. very low power).

Few competitors: STM32 ARM Cortex ,


MSP430, and PIC MCU

AVR CPU at up to 16 MHz,


32KB Flash, 2KB SRAM, 1KB EEPROM
09-08-2023 4
Pins/Jacks in Arduino UNO R3
• It has the following major pins/jacks:

 14 digital input/output pins (of which 6 can be used as PWM outputs),


 6 analog inputs,
 6 pins related to energy/power
 a reset pin
 an analog reference pin
 a reset button
 a USB connection,
 a power jack,
 a 16 MHz ceramic resonator,
 two ICSP header
 Atmel ATmega328 IC pins

Source: https://docs.arduino.cc/hardware/uno-rev3
09-08-2023 5
Detailed Pin Diagram

09-08-2023 6
Pin Description
Pin category Pin Name Details
Power Pins Vin, 3.3V, 5V, Vin : Input voltage to Arduino when using an external power
GND, source.
RESET
5V : Regulated power supply used to power microcontroller
and other components on the board.

3.3V : 3.3V supply generated by on-board voltage regulator.


Maximum current draw is 50mA.

GND : ground pins.

Reset: Reset the microcontroller

ICSP: In-Circuit ICSP pins: Used to code and boot an Arduino from an external source.
Serial MISO, VCC, Allow inter workings of two or more Arduino boards.
Programming SCK, MOSI, Allow you to upload your firmware.
RESET, GND

09-08-2023 7
Cont…
Pin category Pin No / name Details
Analog pin A0 - A5 Used to provide analog input in the range 0-5V.

Digital Input/output pin Digital Pins 2 - 13 Can be used as input or output pins.
Serial Communication 0(Rx),1(Tx) Used to receive and transmit TTL serial data.

External Interrupts 2, 3 To trigger an interrupt.


PWM: Pulse Width 3, 5, 6, 9, 10, 11 Provides 8-bit PWM output.
Modulation
SPI: Serial Peripheral 10 (SS), 11 (MOSI), 12 Used for SPI communication.
Interface (MISO) and 13 (SCK)
Inbuilt LED 13 To turn on the inbuilt LED.

I2C: Inter-IC, or A4 (SDA: Serial Data), Used for TWI / I2C communication.
TWI: Two Wire Interface A5 (SCL: Serial Clock)
AREF AREF : Analog Reference To provide reference voltage from an external
Voltage power supply for analog-to-digital conversion of
inputs to the analog pins.
E.g. if AREF is 4V – the analogRead() range of
0~1023 will relate to 0~4V and not 0~5V.
09-08-2023 8
Arduino in IoT
• Arduinos are used to create IoT projects.

• But, it requires either a specialized Arduino or


shields to provide network capabilities

• The network interface could be Ethernet / WiFi /


Cellular
EtherTen

Arduino + Ethernet Shield Arduino UNO WiFi Rev2


Arduino Ethernet Shield

09-08-2023 9
Configure Arduino IDE
• Download and Install Arduino IDE https://www.arduino.cc/en/Main/Software

• The Arduino Software (IDE) allows you to write programs and upload them to your board.

• When the Arduino IDE first opens, this is what you should see:

09-08-2023 10
Built-in Examples

• Launch the Arduino application

• Programs written using Arduino IDE


are called sketches.

• There are many built-in examples /


sketches.

• To open built-in examples: select File


-> examples.

• These simple programs demonstrate


all the basic Arduino commands.

09-08-2023 11
Set Arduino Board

• Plug in your board through cable

• Select the type of Arduino board


you're using:
 Tools -> Board -> (your board type)
 e.g. Arduino UNO

09-08-2023 12
Set Serial Port

• Select the serial/COM port that


your Arduino is attached to:
 Tools > Port > COMxx

Note: If you're not sure in which


serial port your Arduino is
connected, take a look at the
available ports, then unplug your
Arduino and look again. The one
that disappeared is your Arduino.

09-08-2023 13
Code Compilation

• Compilation
successful
message at the
bottom left
corner.

09-08-2023 14
Code Uploading

• With your Arduino board


connected, and the Blink sketch
open, press the 'Upload' button

• After a second, you should see


some LEDs flashing on your
Arduino, followed by the message
'Done Uploading' in the status bar
of the Blink sketch.

• If everything worked, the on-board


LED on your Arduino should now be
blinking!

09-08-2023 15
Serial Monitor
• The serial monitor is the 'tether' between the computer and your Arduino - it lets you
send and receive text messages.
• First select the port (go to Tools -> Port: ) to which the board is connected then click
the icon of Serial Monitor on the top right side of the Arduino IDE

Serial Monitor
output

09-08-2023 16
Serial Plotter
• Can use Serial Plotter to
plot the output signal

• See the below image for


example

09-08-2023 17
How to Install Sensor Libraries
• Let we will use DHT11 sensor for which we need DHT.h header file
• So, this header file needs to be installed first.

• Install Using the Library Manager


– click to Sketch menu -> Include Library -> Manage Libraries
– Search for “DHT” on the Search box and install the DHT library from Adafruit.

09-08-2023 18
Cont…
• After installing the DHT library from Adafruit, install “Adafruit Unified Sensor” libraries.

• There exist other methods for installing libraries


– Importing a .zip Library
• Sketch --> Include Library --> Add .Zip Library

– Manual Installation of Library


• Download the library as .Zip --> extract it
• Place the files in File --> Preferences --> Sketchbook location
• Restart Arduino IDE

09-08-2023 19
Demo: LED Blink

• See the Demo using Arduino UNO circuit board

1) Blink the in-built LED of Arduino Board

2) Blink the additionally attached LEDs

09-08-2023 20
Blink In-built LED Continuously
• First upload the bare
minimum example:
 Files -> Examples -> Basics ->
BareMinimum

• Output:
 In-built LED will glow
continuously

09-08-2023 21
Blink In-built LED Periodically
• First upload the bare
minimum example:
 Files -> Examples -> Basics ->
BareMinimum

• Output:
 In-built LED will glow
continuously

• Then, upload the blink


example:
 Files -> Examples -> Basics ->
Blink

• Output:
 In-built LED will glow
periodically

09-08-2023 22
Blink External LED

Connect the “digital out” pin 9 with the “Anode pin”


of LED (i.e. long leg of LED) through 1K Ohm resistor,
and “ground” pin with the Cathode pin of LED Upload this sketch in
Arduino UNO
OUTPUT:
 LED connected with digital pin 9 will blink periodically.

09-08-2023 23
Demo on LED Blink

09-08-2023 24
Lessons Learned
 What is Arduino

 Types of Arduino Board

 Arduino UNO pin diagram

 Arduino in IoT

 Arduino IDE

 Built-in Sketch in IDE

 Compiling and Uploading a sketch using IDE

 LED blink program and system setup

09-08-2023 25
09-08-2023 26
Which is better? ATmega328P vs STM32 vs MSP430

ATmega328P STM32 MSP430


Brand ATmel (now Cortex Texas Instruments
MicroChip) (STMicroelectronics)
Cost Low High Low
Architecture Advanced RISC Power Architecture Older, von-Neumann
architecture technology designed for architecture
embedded applications
Power Consumption Low Medium Low
Performance Medium, suitable High, fast processing Low, more suitable
for complex speed, Running 32 bit for only simple
projects ARM processor core projects
with sufficient RAM
Ease of Usage Easy to use, 8 bit Complicated due to its Complex relative to
and high nature of being a 32 bit Arduino boards
compatibility microcontroller
with Arduino
boards
09-08-2023 27

You might also like