Wa0006.
Wa0006.
Aim:
Apparatus Required:
1. 1 X LED
2. 1 X Resistor, 330 Ohm
3. Breadboard
4. Arduino UNO R4 or earlier versions.
5. Jumper wires
THEORY:
Introduction:
Double-click the Arduino application (arduino.exe) you have previously downloaded. (Note:
if the Arduino Software loads in the wrong language, you can change it in the preferences dialog. See
the Arduino Software (IDE) page for details.)
Select the serial device of the Arduino board from the Tools | Serial Port menu. This is likely
to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find
out, you can disconnect your Arduino board and re-open the menu; the entry that disappears should
be the Arduino board. Reconnect the board and select that serial port.
Now, simply click the "Upload" button in the environment. Wait a few seconds - you should see the
RX and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will
appear in the status bar. (Note: If you have an Arduino Mini, NG, or other board, you'll need to
physically press the reset button on the board immediately before clicking the upload button on the
Arduino Software).
A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start
to blink (in orange). If it does, congratulations! You've gotten Arduino up-and- running. If
you have problems, please see the troubleshooting suggestions.
Coding:
Program 1:
Program 2:
void setup()
{
pinMode(1
3,OUTPU
T); }
void
loop() {
digitalWr
it
e(13,HIG
H);
delay(100
0);
digitalWrit
e(13,LOW
);
delay(100
0);
}
RESULT:
Aim:
To write the Arduino program for communication between two trainers and control the
led by switch.
Apparatus Required:
1. Arduino UNO
2. AtMega328 microcontroller
3. Zigbee Transmitter (ZTx)
4. Zigbee Receiver (ZRx)
5. USB cables
6. LEDs
Theory:
al XBee(2,3);
int SW1 =
A4;
void setup()
{
Serial.begin(9600
);
pinMode(SW1,
INPUT);
XBee.begin(9600
);
}
void loop()
{
if (digitalRead(SW1) == HIGH)
{
Serial.println("Turn on
LED");
XBee.write('1'
); delay(1000); }
else if (digitalRead(SW1) == LOW)
{
Serial.println("Turn off
LED");
XBee.write('0');
delay(1000);
}
}
void setup()
{
Serial.begin(9600);
zigbee.begin(9600);
pinMode(led, OUTPUT);
} void
loop()
{
//check if the data is
received if
(zigbee.available() >
0)
{ received = zigbee.read();
//if the data is 0, turn off the
LED
if (received == '0')
{
Serial.println("Turning off LED");
digitalWrite(led, LOW);
}
//if the data is 1, turn on the
LED
else if (received == '1')
{
Serial.println("Turning on LED");
digitalWrite(led, HIGH);
} }}
RESULT:
Thus, the Arduino is interfaced to the Zigbee module and the output is verified.
EX.NO:03 INTERFACING ARDUINO TO GSM MODULE
Aim:
To write the Arduino program for detect the flame and send a sms.
Apparatus Required:
Theory:
#include <SoftwareSerial.h>
Thus, the Arduino is interfaced to the GSM module and the output is verified.
EX.NO:04 INTERFACING ARDUINO TO BLUETOOTH MODULE
Aim:
To write the Arduino program for Electronics Notice Board.
Apparatus Required:
1. Arduino UNO
2. AtMega328 Microcontroller 3. HC-05 Bluetooth Module.
4. LED.
5. Breadboard.
6. Resistors - 1K & 2K Ohm.
7. Connecting Wires.
Note: DIP Switch S1 in 16X2 LCD Display Block should be all ON position.
Theory:
The HC-05 is a class 2 Bluetooth module designed for transparent wireless serial communication.
It is pre-configured as a slave Bluetooth device. Once it is paired to a master Bluetooth device such
as PC, smart phones and tablet, its operation becomes transparent to the user.
Program:
RESULT:
Thus, the Arduino is interfaced to the Bluetooth module and the output is verified.
EX.NO:05 INTRODUCTION TO RASPBERRY PI PLATFORM AND PYTHON
PROGRAMMING
Aim:
To write the python program for Turn on & off a LED.
Apparatus Required:
1. Raspberry Pi
2. PiCo W
3. LED
4. Connecting Wires
Theory:
Python is the official programming language of the Raspberry Pi. It is known for its two unique characteristics: cross-
platform compatibility and easy-to-understand syntax. Unlike lower-level languages like C and C++, Python uses a
Python interpreter that translates the Python program into machine-specific instructions. So as long as you have a Python
interpreter on your computer, you can run any Python program written on whatever machine. Moreover, compared to
other languages, the syntax is simple. Syntax is the arrangement of symbols, words, and phrases needed to make a
Python program work. The friendly Python syntax makes programming fun, which is perfect for a credit card computer
that is made to acquaint people in the field of computer science.
Program:
import machine
import time
led=machine.Pin(15,machine.Pin.OUT)
led.off() time.sleep(1)
RESULT:
Thus, the LED was turned on and off and the output was verified.
EX.NO:06 INTERFACING SENSORS TO RASPBERRY PI
Aim:
To write the python program for measure the obstacle distance in cm using Ultrasonic Sensor.
Apparatus Required:
1. Raspberry Pi
2. PiCo W
3. Ultrasonic Sensor (HC-SR04)
4. Connecting Wires
Theory:
Program:
1. Raspberry Pi
2. PiCo W
3. Arduino UNO
4. AtMega328 Microcontroller
5. Zigbee Transmitter (ZTx)
6. Zigbee Receiver (ZRx)
7. Connecting Wires
}
RESULT:
Thus, the communication between Arduino and Raspberry Pi using ZigBee wireless medium
is done and the output was verified.
EX.NO:08 SETUP A CLOUD PLATFORM TO LOG THE DATA
Aim:
Apparatus Required:
1. Arduino UNO
2. Arduino IDE 1.8.2 or higher
3. Thingspeak Account
4. Thinhspeak Library
5. Arduino Wifi Shield 101
6. Photocell
7. Temperature Sensor (This example uses a TMP36)
8. 10K Ohm Resistor
Procedure:
Step-1: The first step is to create an account. The good part is that ThingSpeak does not require a
Credit card (like AWS/Azure) for signing up. You may sign up here.
Step-2: After signing up on ThingSpeak, login here.
Step-3: Create a new ThingSpeak channel by clicking on the "New Channel".
Step-4: In the new channel creation screen, fill out the details of the device from which data will be
received.
Step-5: In the new channel creation screen, scroll down further and make this channel public. So that
you can post data to it.
Step-6: After saving the channel, the channel details screen will get displayed (as shown below). Notice
that there will be 5 tabs: Private View, Public View, Channel Settings, API Keys and Data
Import/Export. You are all set! Browse through them to get a feeling of the contents. Make note of the
Channel ID, as you will need it for posting and reading data to ThingSpeak.
Step-7: Now we will see how to log data and read data to and from this channel. Browse to the API
Keys tab for your channel. Note down the read and write api_keys (as shown below), as you will need
it for posting and reading data to ThingSpeak. I have obscured the api keys for my channel intentionally.
Never share your channel api keys with unintented recipients as they might spam the channel
inadvertently.
Step-8: Use the following URL format to log data to ThingSpeak.
https://api.thingspeak.com/update.json?api_key=<your-write-api-key>&field1=58
Upon hitting the above URL, the data '58' will get logged in the ThingSpeak IoT cloud.
Correspondingly, you can also see the logged data in the ThingSpeak channel's Private/Public.
Step-9: Use the following URL format to read the logged data from ThingSpeak.
http://api.thingspeak.com/channels/<your-channel-id>/feeds.json?key=<your-read-
apikey>&results=1
On hitting the above URL in the browser, you will receive the last posted data row from ThingSpeak.
Code:
Thus, the IoT cloud platform ThinkSpeak was set up to log the data and the output was
verified.
EX.NO:09 LOG DATA USING RASPBERRY PI AND UPLOAD TO THE CLOUD
PLATFORM
Aim:
To write the python program for Log Temperature Data using Raspberry Pi and upload to
theCloud Platform.
Apparatus Required:
1. Raspberry Pi
2. PiCo W
3. LM35 Temperature Sensor
Theory:
LM35 sensor uses the basic principle of a diode, whereas the temperature increases, the voltage
across a diode increases at a known rate. By precisely amplifying the voltage change, it is easy to
generate an analog signal that is directly proportional to temperature.
Program:
Import network import
urequests from time
import sleep import
machine
sensor_temp = machine.ADC(26) #Network
Initialization ssid = "IElec Systems"
password = "9840838264" def
ConnectWiFi(): wlan =
network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while wlan.isconnected() == False:
print('Waiting for connection...')
sleep(1) ip = wlan.ifconfig()[0]
print(f'Connected on {ip}') return
ip
#Connect to Network ip =
ConnectWiFi() #ThingSpeak
Initialization server =
"http://api.thingspeak.com/" apikey
= "74085BCYRZG0G9YJ"
field = 1
#Main Program while
True:
temperature = sensor_temp.read_u16() temperature
= ((temperature/65535)*3300)/10
print(temperature)
url = f"{server}/update?api_key={apikey}&field{field}={temperature}"
request = urequests.post(url) request.close() sleep(20)
RESULT:
Thus, the data was logged using Raspberry Pi and uploaded to the Cloud Platform.
EX.NO:10 DESIGN AN IOT BASED SYSTEM
Aim:
To write a program to design a Home Automation system using Ardunio and Bluetooth control.
Apparatus Required
1. PIR Motion Sensor (generic)
2. HC-05 Bluetooth Module
3. LDR (Light Dependent Resistor)
4. LED (generic)
5. Arduino UNO
6. Temperature Sensor
7. Relay (generic)
8. Jumper wires (generic)
9. Apps and platforms
10. Arduino IDE
11. Windows 10
Theory:
An Arduino UNO will control devices and reads sensor data. The figure "Room Architecture"
depicts how the Arduino UNO will connects with the devices and sensors. Room have multiple
controllable devices (i.e. Light(s), Fan, Wall Socket(s), etc.), one PassiveIR (to detect human
presence in the room), one temperature sensor (LM35 to collect room temperature) and LDR (to
detect light intensity near room window).
PIR:
PIR sensor consists of three pins, ground, signal, and power at the side or bottom. Generally, the
PIR sensor power is up to 5V, but, the large size PIR modules operate a relay instead of direct
output.
Program:
float x,y;
//TEMP
#define trigPin 12 //ULTRA
#define echoPin 10
int ledPin= 13; int duration, distance;
//ULTRA #include<Servo.h> //servo
Servo my; //servo char val;
//bluetooth void setup() {
Serial.begin(9600); pinMode(2,INPUT);
//IR GATE FIRST pinMode(3,INPUT);
my.attach(11); //servo
pinMode(4, OUTPUT); //IR GATE FIRST
pinMode(7,OUTPUT); //TEM
pinMode(8,INPUT); //pir 1
pinMode(9,OUTPUT); //LED 1 //
pinMode(10,INPUT); //pir 2
//pinMode(11,OUTPUT); //LED2 pinMode(trigPin,
OUTPUT); //12 PIN ULTRA pinMode(echoPin,
INPUT); //10 PIN ULTRA pinMode(ledPin, OUTPUT);
//13 PIN ULTRA pinMode(3,OUTPUT);
//bluetooth
} void loop() { x=analogRead(0);
//TEMP y=((x/1024)*5)*100;
Serial.println(y); delay(500);
if(y>44) { digitalWrite(7,1); } else {
digitalWrite(7,0); delay(500);
}
//TEMP
if(digitalRead(8)==HIGH) //pir
{ digitalWrite(9,HIGH);
}
Else { digitalWrite(9,LOW);}
digitalWrite(trigPin, HIGH); //ULTRA
delayMicroseconds(10); digitalWrite(trigPin,
LOW); duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1; if (distance
>= 10 || distance <= 0)
{
// Serial.println("no object detected"); digitalWrite(ledPin,LOW);
} else
{
Serial.println("object detected \
");
Serial.print("distance= "); Serial.print(distance);
digitalWrite(ledPin,HIGH);
} //ULTRA if(digitalRead(2)==HIGH)
//gate first
{ my.write(0);
//servo
}
Else { my.write(90);
//servo }
analogRead(5); //ldr
float a = analogRead(5);
Serial.println(a); if (a
<=200) { digitalWrite(4,1);
Serial.println("LDR is DARK, LED is ON");
} else {
digitalWrite(4,0);
Serial.println("-----");
} //ldr if (Serial.available())
//bluetooth
{ val = Serial.read();
Serial.println(val);
if(val == 'TV')
digitalWrite(3,HIGH);
else if(val == 'tv')
digitalWrite(3,LOW);
} //Bluetooth
}
RESULT:
Thus, the program was written to design a Home Automation system using Ardunio and
Bluetooth control and the output was verified.