Professional Documents
Culture Documents
Iot Record15
Iot Record15
AIM:
To design an IoT application to illustrate the working of PIR in movement detection.
PROCEDURE:
1. Open Terminal
2. Launch IDLE IDE by typing
3. After the IDLE launches, open a new window by FILE>OPEN or Ctrl+N
4. Type the code
5. Save the code by FILE>SAVE or Ctrl+S
6. To run your code RUN>RUN or Ctrl+F5.
7. Connect VCC to Pin 2 (VCC)
8. Connect GND to Pin 6 (GND)
9. TRIG to Pin 12 (GPIO18)
10. Connect ECHO to GPIO 24.
CODE:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
TRIG = 23
ECHO = 24
print "Distance Measurement"
GPIO.setup(TRIG, GPIO.OUT)
GPIO.setup(ECHO, GPIO.IN)
GPIO.output(TRIG, False)
time.sleep(2)
GPIO.output(TRIG, True)
time.sleep(0.00001)
GPIO.output(TRIG, False)
while GPIO.input(ECHO)==0:
pulse_start = time.time()
while GPIO.input(ECHO)==1:
pulse_end = time.time()
pulse_duration = pulse_end - pulse_start
distance = pulse_duration x 17150
distance = round(distance, 2)
print "Distance: “, distance,"cm"
GPIO.cleanup()
RESULT:
The application was designed using PIR sensor and the distance was measured.
AIM:
To design an IoT application to simulate the working of traffic signal.
PROCEDURE:
1. Open Terminal
2. Launch IDLE IDE by typing
3. After the IDLE launches, open a new window by FILE>OPEN or Ctrl+N
4. Type the code
5. Save the code by FILE>SAVE or Ctrl+S
6. To run your code RUN>RUN or Ctrl+F5.
7. Connect three pins to GPIO 12 ,GPIO 16 and GPIO 23
8. Connect button to GPIO 19.
9. Connect ground to PIN 3
CODE:
import RPi.GPIO as GPIO import time
try:
def lightTraffic(led1, led2, led3, delay ): GPIO.output(led1, 1)
Print(“GREEN”)
time.sleep(delay) GPIO.output(led1, 0)
GPIO.output(led2, 1) Print(“YELLOW”)
time.sleep(delay) GPIO.output(led2, 0)
GPIO.output(led3, 1) Print(“RED”) time.sleep(delay) GPIO.output(led3, 0)
GPIO.setmode(GPIO.BCM) button = 19
GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP) ledGreen = 16
ledYellow = 12
ledRed = 23
RESULT:
The Application was developed to simulate the working of traffic signal.
AIM:
To control the rotation of a servo motor.
PROCEDURE:
1. Open Terminal
2. Launch IDLE IDE by typing
3. After the IDLE launches, open a new window by FILE>OPEN or Ctrl+N
4. Type the code
5. Save the code by FILE>SAVE or Ctrl+S
6. To run your code RUN>RUN or Ctrl+F5.
7. Connect orange wire to pin GPIO 21.
8. Connect red wire to GCC
9. Connect brown wire to ground
CODE:
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(12,
GPIO.OUT)
p = GPIO.PWM(12, 50)
p.start(7.5) try:
while True:
p.ChangeDutyCycle(7.5) # turn towards 90 degree print(“90 degree”)
time.sleep(1) # sleep 1 second p.ChangeDutyCycle(2.5) # turn towards 0 degree print(“0
degree”)
time.sleep(1) # sleep 1 second p.ChangeDutyCycle(12.5) # turn towards 180 degree
print(“180 degree”)
time.sleep(1) # sleep 1 second except KeyboardInterrupt:
p.stop() GPIO.cleanup()
RESULT:
The servo motor working was connected and rotated.
AIM:
To vary the brightness of an LED using PWM signal.
PROCEDURE:
1. Open Terminal
2. Launch IDLE IDE by typing
3. After the IDLE launches, open a new window by FILE>OPEN or Ctrl+N
4. Type the code
5. Save the code by FILE>SAVE or Ctrl+S
6. To run your code RUN>RUN or Ctrl+F5.
7. Connect LED to pin GPIO 21 .
8. Connect ground to PIN 3
CODE:
import RPi.GPIO as GPIO from time import sleep led_pin = 21 GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT) pwm = GPIO.PWM(led_pin, 100) pwm.start(0)
try:
while 1:
Print(“INCREASING”)
for x in range(100): Print(x)
pwm.ChangeDutyCycle(x) sleep(0.01)
Print(“DECREASING”)
for x in range(100,0,-1): Print(x)
pwm.ChangeDutyCycle(x) sleep(0.01)
# If keyboard Interrupt except KeyboardInterrupt:
pass pwm.stop GPIO.cleanup()
RESULT:
Using PWM signal the intensity of the LED was varied.
AIM:
To implement the interface LED, Switch and buzzer with raspberryPi and interface
board by using the python.
DESCRIPTION:
Raspberry Pi is the name of a series of single-board computers made by the Raspberry Pi
foundation, a UK charity that aims to educate people in computing and create easier access to
computing education. It is useful in interfacing various devices for interoperability and for
developing integrated IOT system. The LED and buzzer are integrated with the GPIO [General
Purpose Input Output] pins of Raspberry Pi circuit. The circuit is booted over monitor with
Raspbian OS system. The code for controlling LED and buzzer over a switch is written in
Python.
PROCEDURE:
Connection with Raspberry Pi :
• Connect GPIO 11 of Raspberry Pi to LED through connecting jumperwires.
• Connect GPIO 13 to Raspberry Pi to LED through connecting jumperwires.
• Connect GPIO 15 of Raspberry Pi to buzzer pin through connecting, jumperwires.
• Connect GPIO 23 of Raspberry Pi to switch pin through connecting jumperwires.
• Using jumper wires connect the ground pin of Raspberry Pi and LED interfacing board.
• Now power up the Raspberry Pi and boot.
PIN DIAGRAM:
CODE:
import time
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(23,GPIO.IN,pull_up_down=GPIO.PUD_UP) try:
while True:
button_state = GPIO.input(23) if button_state == False:
GPIO.output(11,True) GPIO.output(13,True) print('Button Pressed...') time.sleep(0.2)
else:
GPIO.output(13,False) GPIO.output(11,False) print('Button released')
except:
GPIO.cleanup()
CODE:
import time
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(23,GPIO.IN,pull_up_down=GPIO.PUD_UP)
try:
while True:
button_state = GPIO.input(23) if button_state == False:
for i in range(0,8): GPIO.output(11,True) GPIO.output(13,True) time.sleep(0.2)
GPIO.output(13,False) GPIO.output(11,False) time.sleep(0.2)
except:
GPIO.cleanup()
CODE:
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOAR
D)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
GPIO.setup(23,GPIO.IN,pull_up_down=GPIO.PUD_UP)
try:
while True:
button_state = GPIO.input(23)
if button_state == False:
for i in range(0,5):
GPIO.output(11,True)
GPIO.output(13,True)
time.sleep(1)
GPIO.output(13,False)
GPIO.output(11,False)
time.sleep(1)
GPIO.output(15,True)
GPIO.output(13,True)
time.sleep(1)
GPIO.output(15,False)
GPIO.output(13,False)
time.sleep(1)
except:
GPIO.cleanup()
RESULT:
Thus, the implementation of the LED, switch and buzzer with Raspberry Pi and interface
board using python has been successfully completed
AIM:
PIN CONFIG:
ESP32
GPIO 2 BUZZER
CODE:
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) ||
!defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
#define BUZZER 2
BluetoothSerial SerialBT;
char incomingChar;
void setup() {
pinMode(BUZZER, OUTPUT);
Serial.begin(115200);
void loop() {
if (SerialBT.available()){
if (incomingChar != '\n'){
message += String(incomingChar);
else{
message = "";
Serial.write(incomingChar);
if (message =="on"){
digitalWrite(BUZZER, HIGH);
digitalWrite(BUZZER, LOW);
delay(20);
OUTPUT:
RESULT
Thus the buzzer using Bluetooth in IOT development it has been executed successfully.
AIM:
CODE:
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) ||
!defined(CONFIG_BLUEDROID_ENABLED)
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
if (SerialBT.available()) {
Serial.write(SerialBT.read());
delay(20);
OUTPUT:
RESULT:
Thus the program to implement communication ESP32 through Bluetooth using IOT kit
development kit has been executed successfully.
AIM:
PIN CONFISURATION:
ESP32 TFT
GND GND
GPIO 12 CS
GPIO 14 RES
GPIO 13 A0
GPIO 21 SDA
3.3V VCC
CODE:
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
//**************************************************************************
*********
#define TFT_CS 12
#define TFT_RST 14
#define TFT_DC 13
#define TFT_SCLK 22
#define TFT_MOSI 21
//**************************************************************************
*********
void setup(void) {
Serial.println("Initializing...");
tft.setTextWrap(true);
void loop() {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ST7735_RED);
tft.setTextSize(2);
tft.println("Hello!");
delay(2000);
tft.setTextColor(ST7735_YELLOW);
tft.setTextSize(2);
delay(1000);
tft.setTextColor(ST7735_GREEN);
tft.setTextSize(3);
tft.println("BYE!");
delay(2000);
OUTPUT:
RESULT:
Thus the program to implement TFT display has been executed successfully.
AIM:
To implement temperature and humidity sensor in IOT kit
PIN CONFIGURATION:
ESP32 DHT11
3.3V 3.3V
GPIO 4 I/O
GND GND
PROGRAM:
#include "DHT.h"
#define DHTPIN 4
void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t) ) {
return;
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(t);
Serial.print("°C ");
Serial.println("");
OUTPUT:
RESULT:
Thus, the program to implement temperature and humidity sensor using IOT kit has been
executed successfully.