Arduino IOT Tutorial
Arduino IOT Tutorial
The Arduino platform has become quite popular with people just starting out with electronics,
and for good reason. Unlike most previous programmable circuit boards, the Arduino does not
need a separate piece of hardware (called a programmer) in order to load new code onto the
board – you can simply use a USB cable. Additionally, the Arduino IDE uses a simplified
version of C++, making it easier to learn to program. Finally, Arduino provides a standard form
factor that breaks out the functions of the micro-controller into a more accessible package.
The Uno is one of the more popular boards in the Arduino family and a great choice for
beginners. We’ll talk about what’s on it and what it can do later in the tutorial.
This is a screenshot of the Arduino IDE.
What's on the board?
There are many varieties of Arduino boards (explained on the next page) that can be used for
different purposes. Some boards look a bit different from the one below, but most Arduinos have
the majority of these components in common:
Every Arduino board needs a way to be connected to a power source. The Arduino UNO can be
powered from a USB cable coming from your computer or a wall power supply (like this) that is
terminated in a barrel jack. In the picture above the USB connection is labeled (1) and the barrel
jack is labeled (2).
The USB connection is also how you will load code onto your Arduino board. More on how to
program with Arduino can be found in our Installing and Programming Arduino tutorial.
Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)
The pins on your Arduino are the places where you connect wires to construct a circuit (probably
in conjuction with abreadboard and some wire. They usually have black plastic ‘headers’ that
allow you to just plug a wire right into the board. The Arduino has several different kinds of
pins, each of which is labeled on the board and used for different functions.
● GND (3): Short for ‘Ground’. There are several GND pins on the Arduino, any of which
can be used to ground your circuit.
● 5V (4) & 3.3V (5): As you might guess, the 5V pin supplies 5 volts of power, and the
3.3V pin supplies 3.3 volts of power. Most of the simple components used with the
Arduino run happily off of 5 or 3.3 volts.
● Analog (6): The area of pins under the ‘Analog In’ label (A0 through A5 on the UNO)
are Analog In pins. These pins can read the signal from an analog sensor (like
a temperature sensor) and convert it into a digital value that we can read.
● Digital (7): Across from the analog pins are the digital pins (0 through 13 on the UNO).
These pins can be used for both digital input (like telling if a button is pushed) and digital
output (like powering an LED).
● PWM (8): You may have noticed the tilde (~) next to some of the digital pins (3, 5, 6, 9,
10, and 11 on the UNO). These pins act as normal digital pins, but can also be used for
something called Pulse-Width Modulation (PWM). We have a tutorial on PWM, but for
now, think of these pins as being able to simulate analog output (like fading an LED in
and out).
● AREF (9): Stands for Analog Reference. Most of the time you can leave this pin alone. It
is sometimes used to set an external reference voltage (between 0 and 5 Volts) as the
upper limit for the analog input pins.
Reset Button
Just like the original Nintendo, the Arduino has a reset button (10). Pushing it will temporarily
connect the reset pin to ground and restart any code that is loaded on the Arduino. This can be
very useful if your code doesn’t repeat, but you want to test it multiple times. Unlike the original
Nintendo however, blowing on the Arduino doesn’t usually fix any problems.
TX RX LEDs
TX is short for transmit, RX is short for receive. These markings appear quite a bit in electronics
to indicate the pins responsible for serial communication. In our case, there are two places on the
Arduino UNO where TX and RX appear – once by digital pins 0 and 1, and a second time next
to the TX and RX indicator LEDs (12). These LEDs will give us some nice visual indications
whenever our Arduino is receiving or transmitting data (like when we’re loading a new program
onto the board).
Main IC
The black thing with all the metal legs is an IC, or Integrated Circuit (13). Think of it as the
brains of our Arduino. The main IC on the Arduino is slightly different from board type to board
type, but is usually from the ATmega line of IC’s from the ATMEL company. This can be
important, as you may need to know the IC type (along with your board type) before loading up
a new program from the Arduino software. This information can usually be found in writing on
the top side of the IC. If you want to know more about the difference between various IC’s,
reading the datasheets is often a good idea.
Voltage Regulator
The voltage regulator (14) is not actually something you can (or should) interact with on the
Arduino. But it is potentially useful to know that it is there and what it’s for. The voltage
regulator does exactly what it says – it controls the amount of voltage that is let into the Arduino
board. Think of it as a kind of gatekeeper; it will turn away an extra voltage that might harm the
circuit. Of course, it has its limits, so don’t hook up your Arduino to anything greater than 20
volts.
HARDWARE CONNECTIONS
CODE TO GENERATE DIFFERENT PATTERNS:-
The seven segment is constructed using the 8 led’s connected in a specific pattern.
● Common Cathode
● Common Anode
In this type, the cathode of all 8-led’s is connected together and GND is applied to it.
And all anode of 8-led’s assigned name a,b,c,d,e,f,g and dp. To glow a specific led in
the segment we apply a logic HIGH signal to the segment pin.
Common Anode Seven Segment Display
On the other side, it is just opposite to common cathode. All the anode of 8-led’s are
connected to each other and to glow a particular led we apply logic LOW to respective
pin.
“0” 0x3F 0 0 1 1 1 1 1 1
Digit Hex Value dp g f e d c b a
“1” 0x06 0 0 0 0 0 1 1 0
“2” 0x5B 0 1 0 1 1 0 1 1
“3” 0x4F 0 1 0 0 1 1 1 1
“4” 0x66 0 1 1 0 0 1 1 0
“5” 0x6D 0 1 1 0 1 1 0 1
“6” 0x7D 0 1 1 1 1 1 0 1
“7” 0x07 0 0 0 0 0 1 1 1
“8” 0x7F 0 1 1 1 1 1 1 1
“9” 0x6F 0 1 1 0 1 1 1 1
Hardware Required
● Arduino Uno
● Common Cathode Seven Segment Display
● Resistor 220 ohm
● Breadboard
HARDWARE CONECTIONS OF SEGMENT WITH
ARDUINO
LCD 16*2–
LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of
applications. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. These modules are preferred over seven segments and other multi
segment LEDs. The reasons being: LCDs are economical; easily programmable; have no
limitation of displaying special &evencustom characters (unlike in seven
segments), animations and so on.
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD
each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command
and Data.
The command register stores the command instructions given to the LCD. A command is an
instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the
cursor position, controlling display etc. The data register stores the data to be displayed on the
LCD. The data is the ASCII value of the character to be displayed on the LCD. Click to learn
more about internal structure of a LCD.
Pin Diagram:
Pin Description:
Pin
Function Name
No
4 Selects command register when low; and data register when high Register Select
5 Low to write to the register; High to read from the register Read/write
6 Sends data to data pins when a high to low pulse is given Enable
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
HARDWARE CONNECTIONS FOR LCD WITH ARDUINO
CODE TO PRINT DATA ON LCD
BLUETOOTH INTERFACING WITH ARDUINO
Software Features
● Slave default Baud rate: 9600, Data bits:8, Stop bit:1,Parity:No parity.
● Auto‐connect to the last device on power as default.
● Permit pairing device to connect as default.
● Auto‐pairing PINCODE:”1234” as default.
Pin Description
The HC-05 Bluetooth Module has 6pins. They are as follows:
ENABLE:
When enable is pulled LOW, the module is disabled which means the
module will not turn on and it fails to communicate.When enable
is left open or connected to 3.3V, the module is enabled i.e the
module remains onand communication also takes place.
Vcc:
Supply Voltage 3.3V to 5V
GND:
Ground pin
TXD & RXD:
These two pins acts as an UART interface for communication
STATE:
It acts as a status indicator.When the module is not connected to /
paired with any other bluetooth device,signal goes Low.At this low
state,the led flashes continuously which denotes that the module
is not paired with other device.When this module is connected
to/paired with any other bluetooth device,the signal goes High.At
this high state,the led blinks with a constant delay say for example
2s delay which indicates that the module is paired.
BUTTON SWITCH:
This is used to switch the module into AT command mode.To enable
AT command mode,press the button switch for a second.With the
help of AT commands,the user can change the parameters of this
module but only when the module is not paired with any other BT
device.If the module is connected to any other bluetooth device, it
starts to communicate with that device and fails to work in AT
command mode.
Hardware Connections
As we know that Vcc and Gnd of the module goes to Vcc and Gnd of
Arduino.The TXD pin goes to RXD pin of Arduino and RXD pin goes to
TXD pin of Arduinoi.e(digital pin 0
PRACTICALS DONE
1) Connect arduino Board with any android device , to send and
receive data and control an led from android device
Code1
void setup() {
Serial.begin(9600);
void loop() {
if(Serial.available()>0)
{
char a=Serial.read();
Serial.print(a);
}
}
CODE TO MAKE AN LED TURN ON AND OFF
void setup() {
Serial.begin(9600);
pinMode(7,OUTPUT);
}
void loop() {
if(Serial.available()>0)
{
char a=Serial.read();
Serial.print(a);
if(a=='A')
{
digitalWrite(13,HIGH);
}
if(a=='B')
{
digitalWrite(13,LOW);
}
}
}
LiquidCrystallcd(12,11,9,8,7,6);
int count;
charblankarr[32];
void setup(){
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(" BLUTOOTH BASED ");
lcd.setCursor(0,1);
lcd.print(" NOTICE BOARD");
delay(3000);
lcd.clear();
}
void loop()
{
if(Serial.available()>0)
{
lcd.clear();
count=0;
while(Serial.available() ) // Read 12 characters and store them
in input array
{
blankarr[count] = Serial.read();
count++;
delay(5);
Serial.print(blankarr[count]);
}
}
if(count<16)
{
lcd.setCursor(0,0);
for(char i=0;i<count;i++)
{
lcd.print(blankarr[i]);
}
}
if(count>16)
{
lcd.setCursor(0,0);
for(char i=0;i<16;i++)
{
lcd.print(blankarr[i]);
}
lcd.setCursor(0,1);
for(char i=16;i<count;i++)
{
lcd.print(blankarr[i]);
}
}}
HARDWARE CONNECTIONS
PRACTICALS PERFORMED
1. Dialing a number using gsm.
2. Attend an incoming call on gsm
3. Send a message to a particular number example:alert
messages with help of gsm
4. Recive a message from a number with help of gsm
and forward it to arduino.
AT
AT+CMGF=1 /// to put gsm in message mode
AT+CMGF=0/// to put gsm in call mode
ATDXXXXXXXXXX; ////to dial a call using gsm.
Xxxxxxxxxxx here is a 10 digit number to be dialed
ATA ////to attend a received call
ATH ///// to halt a received call
AT+CMGS=”+91xxxxxxxxxx” /////command to
send a message on particular number
The ESP8266 Wifi module is a complete WiFi network where you can easily
connect as a serving Wi- Fi adapter, wireless internet access interface to any
microcontroller based design on its simple connectivity through Serial
Communication or UART interface.
Communication with ESP8266 is via Attention Command or AT
Commands.
PRACTICALS DONE
Go to link :-thingspeak.com