Iot File Annanya PDF
Iot File Annanya PDF
LAB FILE
Aim: Study and Install IDE of Arduino and different types of Arduino.
Objectives: Student should get the knowledge of Arduino IDE and different types of Arduino Board.
Outcomes:Student will be get knowledge of Arduino IDE and different types of Arduino Board.
Arduino:
Arduino is a prototype platform (open-source) based on an easy-to-use hardware and software. It consists of a
circuit board, which can be programed (referred to as a microcontroller) and a ready- made software called
Arduino IDE (Integrated Development Environment), which is used to write and upload the computer code to
the physical board.
Arduino provides a standard form factor that breaks the functions of the micro- controller into a more
accessible package.
Arduino is a prototype platform (open-source) based on an easy-to-use hardware and software. It consists of a
circuit board, which can be programed (referred to as a microcontroller) and a ready- made software called
Arduino IDE (Integrated Development Environment), which is used to write and upload the computer code to
the physical board.
Arduino boards are able to read analog or digital input signals from different sensors and turn it
into an output such as activating a motor, turning LED on/off, connect to the cloud and many otheractions.
You can control your board functions by sending a set of instructions to the microcontroller on the
board via Arduino IDE (referred to as uploadingsoftware).
Unlike most previous programmable circuit boards, Arduino does not need an extra piece of
hardware (called a programmer) in order to load a new code onto the board. You can simply use aUSB 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 the functions ofthe micro-controller
into a more accessible package.
The process will extract and install all the required files to execute properly the Arduino Software
(IDE)
Proceed with board specific instructions
When the Arduino Software (IDE) is properly installed you can go back to the
Arduino USB
1.Arduino
This is the latest revision of the basic Arduino USB board. It connects to the computer with a standard USB
cable and contains everything else you need to program and use the board.
2.Arduino NG REV-C
Revision C of the Arduino NG does not have a built-in LED on pin 13 - instead you'll see two small unused
solder pads near the labels "GND" and "13".
Arduino Bluetooth
The Arduino BT is a microcontroller board originally was based on the ATmega168, but now is supplied
with the 328, and the Bluegiga WT11 bluetooth module. It supports wireless serial communication over
bluetooth.
Arduino Mega
The original Arduino Mega has an ATmega1280 and an FTDI USB-to- serial chip.
Arduino NANO
The Arduino Nano 3.0 has an ATmega328 and a two-layer PCB. The power LED moved to the top of the
board.
Experiment : 2
Aim: Write program using Arduino IDE for Blink LED
Objectives: Student should get the knowledge of Arduino Board and different types of LED
Outcomes: Student will be Write program using Arduino IDE for Blink LED
Hardware Requirements:
1x Breadboard
1x Arduino Uno R3
1x RGB LED
1x 330Ω Resistor
2x Jumper Wires
Blinking the RGB LED
With a simple modification of the breadboard, we could attach the LED to an output pin of theArduino. Move
the red jumper wire from the Arduino 5V connector to D13, as shown below:
Now load the 'Blink' example sketch from Lesson 1. You will notice that both the built-in 'L' LEDand
the external LED should now blink.
1. /*
2. Blink
3. Turns on an LED on for one second, then off for one second, repeatedly. 4.
5. This example code is in the public domain.
6.
*/
7.
8. // Pin 13 has an LED connected on most Arduino boards.
9. // give it a name:
10. int led = 13;
11.
12. // the setup routine runs once when you press reset:
13. void setup() {
14. // initialize the digital pin as an output.
15. pinMode(led, OUTPUT);
16.}
17.
18. // the loop routine runs over and over again forever:
19. void loop() {
20. digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
21. delay(1000); // wait for a second
22. digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
23. delay(1000); // wait for a second
24.}
Lets try using a different pin of the Arduino – say D7. Move the red jumper lead from pin D13 to pin
D7 and modify the following line near the top of the sketch:
so that it reads:
1. int led = 7;
Upload the modified sketch to your Arduino board and the LED should still be blinking, but
this time using pin D7.
Experiment No 3
Aim: Write Program for RGB LED using Arduino.
Objectives: Student should get the knowledge of Arduino IDE and RGB Led
Outcomes: Student will be developed programs using Arduino IDE and Arduino Board forRGB Led
Hardware Requirements:
1x Breadboard
1x Arduino Uno R3
1x LED
1x 330Ω Resistor
2x Jumper Wires
Blinking the LED
With a simple modification of the breadboard, we could attach the LED to an output pin of theArduino. Move
the red jumper wire from the Arduino 5V connector to D13, as shown below:
Now load the 'Blink' example sketch from Lesson 1. You will notice that both the built-in 'L' LEDand the
external LED should now blink.
The following test sketch will cycle through the colors red, green, blue, yellow, purple, and aqua.These
colors being some of the standard Internet colors.
1. /*
2. Adafruit Arduino - Lesson 3. RGB LED
3. */
4.
5. int redPin = 11;
6. int greenPin = 10;
7. int bluePin = 9;
8.
9. //uncomment this line if using a Common Anode LED
10.//#define COMMON_ANODE
11.
12.void setup()
13.{
14. pinMode(redPin, OUTPUT);
15. pinMode(greenPin, OUTPUT);
16. pinMode(bluePin, OUTPUT);
17.}
18.
19.void loop()
20.{
21. setColor(255, 0, 0); // red
22. delay(1000);
23. setColor(0, 255, 0); // green
24. delay(1000);
25. setColor(0, 0, 255); // blue
26. delay(1000);
27. setColor(255, 255, 0); // yellow
28. delay(1000);
29. setColor(80, 0, 80); // purple
30. delay(1000);
31. setColor(0, 255, 255); // aqua
32. delay(1000);
33.}
34.
35. void setColor(int red, int green, int blue)
36.{
37. #ifdef COMMON_ANODE
38. red = 255 - red;
39. green = 255 - green;
40. blue = 255 - blue;
41. #endif
42. analogWrite(redPin, red);
43. analogWrite(greenPin, green);
44. analogWrite(bluePin, blue);
45.}
1. int redPin = 11;
2. int greenPin = 10;
3. int bluePin = 9;
The next step is to write the 'setup' function. As we have learnt in earlier
lessons, the setup function runs just once after the Arduino has reset. In this
case, all it has to do is define the three pins we are using as being outputs.
1. void setup()
2. {
3. pinMode(redPin, OUTPUT);
4. pinMode(greenPin, OUTPUT);
5. pinMode(bluePin, OUTPUT);
6. }
Before we take a look at the 'loop' function, lets look at the last function in the sketch.
Download file
Copy Code
This function takes three arguments, one for the brightness of the red, green and blue LEDs. In
each case the number will be in the range 0 to 255, where 0 means off and 255 means
maximum brightness. The function then calls 'analogWrite' to set the brightness of each LED.
If you look at the 'loop' function you can see that we are setting the amount of red, green and
blue light that we want to display and then pausing for a second before moving on to the next
color.
1. void loop()
2. {
3. setColor(255, 0, 0); // red
4. delay(1000);
5. setColor(0, 255, 0); // green
6. delay(1000);
7. setColor(0, 0, 255); // blue
8. delay(1000);
9. setColor(255, 255, 0);// yellow
10. delay(1000);
11. setColor(80, 0, 80); // purple
12. delay(1000);
13. setColor(0, 255, 255);// aqua
14. delay(1000);
15.}
Try adding a few colors of your own to the sketch and watch the effect on your LED.
Experiment No: 4
Aim: Study the Temperature sensor and Write Program foe monitor temperature using Arduino.
Outcomes: Student will be developed programs using Arduino IDE and Arduino Board for
Temperature Sensor
They come in a "TO-92" package which means the chip is housed in a plastic hemi-cylinder with three
legs. The legs can be bent easily to allow the sensor to be
plugged into a breadboard. You can also solder to the pins to connect long wires. If you need to
waterproof the sensor, you can see below for an Instructable for how to make an excellent case.
Reading the Analog Temperature Data
Unlike the FSR or photocell sensors we have looked at, the TMP36 and friends doesn't act like a
resistor. Because of that, there is really only one way to read the temperature value from the sensor,
and that is plugging the output pin directly into an Analog (ADC) input.
Remember that you can use anywhere between 2.7V and 5.5V as the power supply. For this example
I'm showing it with a 5V supply but note that you can use this with a 3.3v supply just as easily. No
matter what supply you use, the analog voltage reading will range from about 0V (ground) to about
1.75V.
If you're using a 5V Arduino, and connecting the sensor directly into an Analog pin, you can use these
formulas to turn the 10-bit analog reading into a temperature:
Voltage at pin in milliVolts = (reading from ADC) * (5000/1024)
This formula converts the number 0-1023 from the ADC into 0-5000mV (= 5V) If you're using a
3.3V Arduino, you'll want to use this:
Voltage at pin in milliVolts = (reading from ADC) * (3300/1024)
This formula converts the number 0-1023 from the ADC into 0-3300mV (= 3.3V) Then, to convert
millivolts into temperature, use this formula:
Centigrade temperature = [(analog voltage in mV) - 500] / 10
Simple Thermometer
This example code for Arduino shows a quick way to create a temperature sensor, it simply prints to
the serial port what the current temperature is in both Celsius and Fahrenheit.
1. //TMP36 Pin Variables
2. int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
3. //the resolution is 10 mV / degree centigrade with a
4. //500 mV offset to allow for negative temperatures 5.
6. /*
7. * setup() - this function runs once when you turn your Arduino on
8. * We initialize the serial connection with the computer 9. */
10.void setup()
11.{
12. Serial.begin(9600); //Start the serial connection with the computer
13. //to view the result open the serial monitor
14.} 15.
16.void loop() // run over and over again
17.{
18. //getting the voltage reading from the temperature sensor
19. int reading = analogRead(sensorPin); 20.
21. // converting that reading to voltage, for 3.3v arduino use 3.3
22. float voltage = reading * 5.0; 23.
voltage /= 1024.0;
24.
25. // print out the voltage
26. Serial.print(voltage); Serial.println(" volts"); 27.
28. // now print out the temperature
29. float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit
500 mV offset
30. //to degrees ((voltage - 500mV)
times 100)
31. Serial.print(temperatureC); Serial.println(" degrees C"); 32.
33. // now convert to Fahrenheit
34. float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
35. Serial.print(temperatureF); Serial.println(" degrees F"); 36.37.
delay(1000);
38.}
Experiment : 5Aim: Study and Implement RFID, NFC using Arduino.
Objectives: Student should get the knowledge of RFID, NFC using Arduino.
Outcomes: Student will be developed programs using Arduino IDE and Arduino Board for
RFID, NFC.
Hardware Requirements:
RFID system is made up of two parts: a tag or label and a reader. RFID tags or labels are embedded with
a transmitter and a receiver. The RFID component on the tags have two parts: a microchip that stores
and processes information, and an antenna to receive and transmit a signal. The tag contains the specific
serial number for one specific object.
To read the information encoded on a tag, a two-way radio transmitter-receiver called an interrogator or
reader emits a signal to the tag using an antenna. The tag responds with the information written in its
memory bank. The interrogator will then transmit the read results to an RFID computer program.
Lets first wire the whole thing up. You may observe the circuit diagram given below. Take note of the
following stuffs.
Note 1:- Power supply requirement of RFID Readers vary from product to product. The RFID reader I
used in this tutorial is a 12 Volts one. There are 5 Volts and 9 Volts versions available in the market.
Note 2:- You may ensure the RFID Reader and RFID Tags are frequency compatible. Generally they
are supposed to be 125Khz. You may ensure this before purchasing them.
Note 3:- There are two possible outputs from an RFID Reader. One is RS232 compatible output and
other one is TTL compatible output. A TTL compatible output pin can be connected directly to Arduino.
Whereas an RS232 compatible output must be converted
to TTL using an RS232 to TTL converter (You can design this yourself using MAX232 IC)So that’s all!
Make connections as shown. Make sure you connect Ground Pin of RFID reader to Ground Pin of
Arduino. I am using the SoftwareSerial Library of Arduino which enables digital pins to be used in
serial communication. I have used pin 9 as the Rx of Arduino. (You can also use the hardware Rx pin of
Arduino uno – that’s pin 0). If you are new to SoftwareSerial Library, you may read my previous
tutorial on interfacing GSM module to Arduino (this article clearly explains how to use Software
Serial Library).
Objectives: Student should get the knowledge of MQTT Protocol using Arduino.
Outcomes: Student will be developed programs using Arduino IDE and Arduino Board for MQTT
Protocol
MQTT:
MQ Telemetry Transport (MQTT) is an open source protocol for constrained devices and low- bandwidth,
high-latency networks. It is a publish/subscribe messaging transport that is extremely lightweight and ideal for
connecting small devices to constrained networks.
MQTT is bandwidth efficient, data agnostic, and has continuous session awareness. It helps minimize the
resource requirements for your IoT device, while also attempting to ensure reliability and some degree of
assurance of delivery with grades of service. MQTT targets large networks of small devices that need to be
monitored or controlled from a back-end server on the Internet. It is not designed for device-to-device
transfer. Nor is it designed to “multicast” data to many receivers. MQTT is extremely simple, offering few
control options.
MQTT methods
MQTT defines methods (sometimes referred to as verbs) to indicate the desiredaction to be performed on the
identified resource. What this resource represents, whether pre-existing data or data that is generated
dynamically, depends on the implementation of the server. Often, the resource corresponds to a file or the
output of an executable residing on the server.
Connect
Waits for a connection to be established with the server.
Disconnect
Waits for the MQTT client to finish any work it must do, and for the TCP/IP session to disconnect.
Subscribe: Waits for completion of the Subscribe or UnSubscribe method.
UnSubscribe :Requests the server unsubscribe the client from one or more topics.
Publish:Returns immediately to the application thread after passing the request to the MQTT client.
Experiment: 7
Aim: Study and Configure Raspberry Pi.
Raspberry Pi
The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the
Raspberry Pi Foundationto promote the teaching of basic computer science in schools and in developing
countries.[4][5][6] The original model became far more popular than anticipated, selling outside of its
target market for uses such as robotics. Peripherals (including keyboards, mice and cases) are not included
with the Raspberry Pi. Some accessories however have been included in several official and unofficial
bundles.
According to the Raspberry Pi Foundation, over 5 million Raspberry Pis have been sold before February
2015, making it the best-selling British computer.[8] By November 2016 they had sold 11 million
units[9][10], reaching 12.5m in March 2017, making it the third best-selling "general purpose computer"
ever.
To get started with Raspberry Pi, you need an operating system. NOOBS (New Out Of Box Software) is an
easy operating system install manager for the Raspberry Pi.
1. GO to the https://www.raspberrypi.org/downloads/
2. Click on NOOBS, then click on the Download ZIP button under ‘NOOBS (offline and network
install)’, and select a folder to save it to.
It is best to format your SD card before copying the NOOBS files onto it. To do this:
3. Insert your SD card into the computer or laptop’s SD card reader and make a note of the drive letter
allocated to it, e.g. G:/
4. In SD Formatter, select the drive letter for your SD card and format it.
1. Once your SD card has been formatted, drag all the files in the extracted NOOBS folder and drop
them onto the SD card drive.
3. When this process has finished, safely remove the SD card and insert it into your Raspberry Pi.
FIRST BOOT
3. Your Raspberry Pi will boot, and a window will appear with a list of different operating systems
that you can install. We recommend that you use Raspbian – tick the box next to Raspbian and click on
Install.
4. Raspbian will then run through its installation process. Note that this can take a while.
5. When the install process has completed, the Raspberry Pi configuration menu (raspi- config) will
load. Here you are able to set the time and date for your region, enable a Raspberry Pi camera board, or
even create users. You can exit this menu by using Tab on your keyboard to move to Finish.
The default login for Raspbian is username pi with the password raspberry. Note
that you will not see any writing appear when you type the password.This is a
security feature in Linux.
To load the graphical user interface, type startx and press Enter.
Experiment : 8
Aim: WAP for LED blink using Raspberry Pi.
Objectives: Student should get the knowledge of LED blinking using Raspberry Pi. Outcomes:
Studentwill be developed program of LED bilking using Raspberry Pi. Hardware Requirements:
1x Breadboard
1x Raspberry Pi
1x RGB LED
1x 330Ω Resistor
2x Jumper Wires
Semiconductor light-emitting diode is a type of component which can turn electric energy into light
energy via PN junctions. By wavelength, it can be categorized into laser diode, infrared light-emitting
diode and visible light-emitting diode which is usually known as light-emitting diode (LED).
When 2V-3V forward voltage is supplied to an LED, it will blink only if forward currents flow through
the LED. Usually there are red, yellow, green, blue and color-changing LEDs which change color with
different voltages. LEDs are widely used due to their low operating voltage, low current, luminescent
stability and small size.
LEDs are diodes too. Hence they have a voltage drop which usually varies from 1V to 3V depending
on their types. Generally they brighten if supplied with a 5mA-30mA current and we usually use
10mA- 20mA.Thus when an LED is used ,it is necessary to connect a current-limiting resistor to
protect it from being burnt.
In this experiment, connect a 220Ω resistor to the anode of the LED, then the resistor to 3.3 V and
connect the cathode of the LED to GPIO0 (See Raspberry Pi Pin Number Introduction).
Step 1: Build the circuit given above
Step 3: Run
sudo python 01_led.py
Now, you should see the LED blink.
Python Cod
#!/usr/bin/env
python
import RPi.GPIO as
LedPin = #
def setup():
GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical
location GPIO.setup(LedPin, GPIO.OUT) # Set LedPin's
mode is output GPIO.output(LedPin, GPIO.HIGH) # Set LedPin
high(+3.3V) to off led
def loop():
while True:
print '...led on'
GPIO.output(LedPin, GPIO.LOW) # led on time.sleep
print 'led off...'
GPIO.output(LedPin, GPIO.HIGH)
# led off time.sleep(0.5)
def destroy():
GPIO.output(LedPin, # led off
GPIO.HIGH) # Release
ThingSpeak Basics
ThingSpeak is an application platform for the Internet of Things. ThingSpeak allows you to build an
application around data collected by sensors. Features of ThingSpeak include real-time data collection,
data processing, visualizations, apps, and plugins.
At the heart of ThingSpeak is a ThingSpeak Channel. A channel is where you send your data to be
stored. Each channel includes 8 fields for any type of data, 3 location fields, and 1 status field. Once
you have a ThingSpeak Channel you can publish data to the channel, have ThingSpeak process the
data, and then have your application retrieve the data.
Experiment : 10
Aim: Study of Thinger.io
The Thinger.io platform is an Open Source platform for the Internet of Things, it provides a ready to
use scalable cloud infrastructure for connecting things. Makers and companies can start controlling
their devices from the internet in minutes, without worrying about the required cloud infrastructure.
Thinger.io platform is formed by two main products a Backend (which is the actual IoT server) and a
web-based Frontend that simplifies working with all the features using any computer or smartphone.
The image below shows the main features provides by this platform to create IoT projects.
Connect devices: Fully compatible with every kind of device, no matter the processor, the
network or the manufacturer. Thinger.io allows to create bidirectional communications with
Linux, Arduino, Raspberry Pi, or MQTT devices and even with edge technologies like Sigfox
or LoRaWAN or other internet API data resources.
Store Device Data: Just a couple clicks to create a Data Bucket a store IoT data in a scalable,
efficient and affordable way, that also allows real-time data aggregation.
Display Real-time or Stored Data in multiple widgets such as time series, donut charts, gauges,
or even custom made representations to create awesome dashboards within minutes.
Trigger events and data values using an embedded Node-RED rule engine
Extend with custom features with multiple plugins to integrate IoT projects into your
company's software or any other third party Internet service.
Custom the appearance thanks to our fully rebrandeable frontend, that allows introducing
your branding colors, logotypes and web domain
Experiment : 11
Aim:Study of NodeMCU
NodeMCU is a low-cost open source IoT platform. It initially included firmware which runs on
the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which was based on the ESP-12
module. Later, support for the ESP32 32-bit MCU was added.NodeMCU is an open source
firmware for which open source prototyping board designs are available. The name
"NodeMCU" combines "node" and "MCU" (micro-controller unit). The term "NodeMCU"
strictly speaking refers to the firmware rather than the associated development kits.Both the
firmware and prototyping board designs are open source.
The firmware uses the Lua scripting language. The firmware is based on the eLua project, and
built on the Espressif Non-OS SDK for ESP8266. It uses many open source projects, such as
lua-cjson and SPIFFS. Due to resource constraints, users need to select the modules relevant for
their project and build a firmware tailored to their needs. Support for the 32-bit ESP32 has also
been implemented.
The prototyping hardware typically used is a circuit board functioning as a dual in-line package
(DIP) which integrates a USB controller with a smaller surface-mounted board containing the
MCU and antenna. The choice of the DIP format allows for easy prototyping on breadboards.
The design was initially based on the ESP-12 module of the ESP8266, which is a Wi-Fi SoC
integrated with a Tensilica Xtensa LX106 core, widely used in IoT applications.
NodeMCU has 128 KB RAM and 4MB of Flash memory to store data and programs. Its high
processing power with in-built Wi-Fi / Bluetooth and Deep Sleep Operating features make it
ideal for IoT projects. NodeMCU can be powered using Micro USB jack and VIN pin (External
Supply Pin). It supports UART, SPI, and I2C interface.s
Experiment :12
Aim: Study and Implement Zigbee Protocol using Raspberry Pi.
Objectives: Student should get the knowledge of Zigbee Protocol using Raspberry Pi. Outcomes: Student
Raspberry Pi2
XBee 1mW Wire Antenna- Series 1 (2 No:)
XBee Explorer Dongle (2 No:)
ZigBee is a communication device used for the data transfer between the controllers, computers, systems,
really anything with a serial port. As it works with low power consumption, the transmission distances is
limited to 10–100 meters line-of- sight. ZigBee devices can transmit data over long distances by passing
data through a mesh network of intermediate devices to reach more distant ones. ZigBee is typically used in
low data rate applications that require long battery life and secure networking. Its main applications are in
the field of wireless sensor network based on industries as it requires short-range low- rate wireless data
transfer. The technology defined by the ZigBee specification is intended to be simpler and less
Here we make use of an interface of Zigbee with Raspberry Pi2 for a proper wireless communication.
Raspberry Pi2 has got four USB ports, so it is better to use a Zigbee Dongle for this interface. Now we
want to check the communication between the two paired ZigBee modules.
The response showed inside a red box indicates the presence of a usb device in the module.
import serial
# Enable USB Communication ser = serial.Serial('/dev/ttyUSB0',
The two zigbee must be in a line of sight and check the results in the Python shell and in the
Introduction:
Arduino provides a standard form factor that breaks the functions of the micro-controller into a more
accessible package.
LEDs are small, powerful lights that are used in many different applications. To start, we will work
on blinking an LED, the Hello World of microcontrollers. It is as simple as turning a light on and off.
Establishing this important baseline will give you a solid foundation as we work towards
experiments that are more complex.
Instruments Required
1. Arduino Board
2. 2 LED’s
3. 220 Ohm resistor
4. Connecting wires
Board Diagram
Circuit Diagram
Working
1. First of all, connect two wires to any no. on Arduino board between 1 to 13.
2. Connect the wires to the breadboard just along-side of each other.
3. Connect the grounds wire to Arduino as well as breadboard.
4. Now once the setup is built and we will execute the code.
5. We will see that light blinks in each second since we have delayed it to 1000 msec.
6. Repeat the process again and again to get blinking light coding.
Code:
Voidsetup()
{ Serial.begin(9600);
// Setup the 3 pins as OUTPUT
pinMode(led1,OUTPUT);
pinMode(led2, OUTPUT);
// IMPORTANT:
// When multiple tasks are running 'delay' passes control to
// other tasks while waiting and guarantees they get executed.
delay(1000);
digitalWrite(led1, LOW);
delay(1000);
}
// Task no.2: blink LED with 0.1 second delay. void
loop2() {
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led2, LOW);
delay(100);
}
}
Output:
LED turn on and off. If the required output is not seen, make sure you have assembled the circuit
correctly, and verified and uploaded the code to your board.
Experiment:14
Aim:A project to read analog signal and represent it digitally or in the form ofvoltage.
Introduction
Microcontrollers are capable of detecting binary signals: is the button pressed or not? These are
digital signals. When a microcontroller is powered from five volts, it understands zero volts (0V) as a
binary 0 and a five volts (5V) as a binary 1. The world however is not so simple and likes to use
shades of grey. What if the signal is 2.72V? Is that a zero or a one? We often need to measure signals
that vary; these are called analog signals. A 5V analog sensor may output 0.01V or 4.99V or
anything in between. Luckily, nearly all microcontrollers have a device built into them that allows us
to convert these voltages into values that we can use in a program to make a decision.
An Analog to Digital Converter (ADC) is a very useful feature that converts an analog voltage on a
pin to a digital number. By converting from the analog world to the digital world, we can begin to
use electronics to interface to the analog world around us.
Circuit Diagram
Instruments Required
1. Arduino
2. USBcables
3. wires
4. Potentiometer
Code:
int sensorPin = A0; // select the input pin for the potentiometer int
ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// start serial port at 9600 bps:
Serial.begin(9600);
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.print(sensorValue); // print ADC value of analog reading
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for milliseconds:
delay(sensorValue);
}
Output
Experiment: 15
Aim:A project for switching on and off LED with the help of switch.Introduction
The program shows the simplest thing we can do with an Arduino with LED bulb in which first LED
gets light up when switch is on and gets off when switch is off. A relay, from the external point of view
is a simple switch capable of passing current or not. This phenomenon occurs through a physical
principle, based on the coupling magnet that is generated through a passage a small excitationcurrent,
which is supplied by the Arduino.
Board Diagram
Instruments Required
1. Arduino board
2. LED
3. 220 ohm resistor
4. Hook-up wires
5. Breadboard
6. Switch
Working
Output:
When we switch on the button, light gets on for a specific time and when switch is off, light
gets off.
Experiment: 16
Aim: A project to control bulb using Bluetooth and relay module.
Introduction
There are three main parts to this project. An Android smartphone, a Bluetooth transceiver, and an
Arduino.
HC 05/06 works on serial communication. The Android app is designed to send serial data to the
Arduino Bluetooth module when a button is pressed on the app. The Arduino Bluetooth module at
the other end receives the data and sends it to the Arduino through the TX pin of the Bluetooth module
(connected to RX pin of Arduino). The code uploaded to the Arduino checks the received data and
compares it. If the received data is 1, the LED turns ON. The LED turns OFF when the received data
is 0. You can open the serial monitor and watch the received data while connecting.
Board Diagram
Instruments Required
1. Arduino Uno
2. Bluetooth Module HC-05
3. 2 channel Relay
4. Breadboard
5. 2 Bulbs
6. Wires
7. A Bluetooth Control App
Arduino Pins | Bluetooth Pins
RX (Pin 0) ———> TX
TX (Pin 1) ———> RX
5V ———> VCC
Code
Introduction
It is an Open-source, Interactive, Programmable, Low cost, Simple, Smart, WI-FI enabled board which
can help you to build IOT projects with ultra-fast prototyping. it works on 3V logic and you have to
make arrangements when connecting sensors which work on 5V. This board has 30 Pins.
Blynk is a Platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes over
the Internet.
Blynk was designed for the Internet of Things. It can control hardware remotely, it can display
sensor data, it can store data, visualize it and do many other cool things.
It's a digital dashboard where you can build a graphic interface for your project by simply dragging
and dropping widgets. It's really simple to set everything up and you'll start tinkering in less than 5
mins. Blynk is not tied to some specific board or shield. Instead, it's supporting hardware of your choice.
Whether your Arduino or Raspberry Pi is linked to the Internet over Wifi, Ethernet or this new
ESP8266 chip, Blynk will get you online and ready for the Internet Of Your Things.
Component Required
1. Node MCU
2. Arduinouno
3. 5v 4 channel relay module
4. 5v adapter
5. jumper wires male to female
6. ac 220v/120v loads/home appliances
7. android phone
8. laptop/pc
1. First install the Blynk app from google play store and then sign in
2. After that Press on click on New Project and you will get a screen (Refer Screen shots)
and then you will see below the authentication token no. If you want it in your email you can send it
through email also
3. Now you will get your dashboard screen. Just click on the the top most button "+" on the right
corner to add widgets to your project.
4. In this project we add a simple button and then configure its settings as Digital GP13 pin.(Refer
Screen Shots)
5. Its your choice you can either have the button set as push type or as a switch
Code:
Introduction
RFID tagging is an ID system that uses small radio frequency identification devices for identification
and tracking purposes. An RFID tagging system includes the tag itself, a read/write device, and a
host system application for data collection, processing, and transmission.
In simple words an RFID uses electromagnetic fields to transfer data over short distances. RFID is
useful to identify people, to make transactions, etc…
You can use an RFID system to open a door. For example, only the person with the right information
on his card is allowed to enter. An RFID system uses:
Component Required
1. Arduino UNO
2. LED (Red, Green)
3. RFID sensor (MFRC522)
4. Servo
5. Jumpers
6. Breadboard
Code
#include <SPI.h>
#include
<MFRC522.h>#define
SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup()
{
Serial.begin(9600); SPI.begin();
mfrc522.PCD_Init();
Serial.println("Approximate your card to the reader...");Serial.println();
}
void loop()
{
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return; }
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i< mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); Serial.print(mfrc522.uid.uidByte[i],
HEX); content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "BD 31 15 2B") //change here the UID of the card/cards thatyou want to
give access
{
Serial.println("Authorized access");Serial.println();
delay(3000);
}
else {
Serial.println(" Access denied");
delay(3000);
}
}
Output:
After having the circuit ready, go to File > Examples > MFRC522 >DumpInfo and upload the code.
Then, open the serial monitor. You should see something like the figure below:
Approximate the RFID card or the keychain to the reader. Let the reader and the tag closer until all
the information is displayed.
This is the information that you can read from the card, including the card UID that is highlighted in
yellow. The information is stored in the memory that is divided into segments and blocks as you can
see in the previous picture.
You have 1024 bytes of data storage divided into 16 sectors and each sector is protected by two
different keys, A and B.
Write down your UID card because you’ll need it later. Upload the Arduino code that has been
suffixed here.
Demonstration:
Approximate the card you’ve chosen to give access and you’ll see:
If you approximate another tag with another UID, the denial message will show up: