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

Iot Practicals

iot&es

Uploaded by

Sushma Borkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Iot Practicals

iot&es

Uploaded by

Sushma Borkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CAMERA

CODE :
import picamera

from time import sleep

camera picamera.PiCamera()

camera.capture( img7.jpg)

sleep (1)

camera.capture('img8.jpg)

camera.start_preview()

camera.brightness=75

sleep(3)

camera.stop preview()
IR SENSOR
CODE:
import RP1.GPIO as GPIO

import time

sensor= 16

buzzer = 18

GPIO.setmode (GPIO.BCM)

GPIO.setup(sensor,GPIO.IN)

GPIO.setup(buzzer, GPIO.OUT)

GPIO.output (buzzer,False)

print ("IR Sensor Ready...”)

print(" “)

try:

while True:

if GPIO.input (sensor):

GPIO.setwarnings(True)

GPIO.output (buzzer,False)

print ("Object detected")

while GPIO.input (sensor):

time.sleep(0.2)

else:

GPIO.output (buzzer, True)

print("Object not detected")

except KeyboardInterrupt:

GPIO.cleanup()
WATER SENSOR :
CODE:
import RP1.GPIO as GPIO

import time

sensor= 16

buzzer = 18

GPIO.setmode (GPIO.BCM)

GPIO.setup(sensor,GPIO.IN)

GPIO.setup(buzzer, GPIO.OUT)

GPIO.output (buzzer,False)

print ("Water Sensor Ready...”)

print(" “)

try:

while True:

if GPIO.input (sensor):

GPIO.setwarnings(True)

GPIO.output (buzzer,True)

print ("Water Detected")

while GPIO.input (sensor):

time.sleep(0.2)

else:

GPIO.output (buzzer, False)

print("Water not detected")

except KeyboardInterrupt:

GPIO.cleanup()
TEMPERATURE SENSOR:
CODE:
import Adafruit_DHT

import time

import RP1.GPIO as GPIO

led-18

sensor=16

GPIO.setmode (GPIO.BCM)

GPIO.setup(sensor,GPIO.IN)

GPIO.setup(led, GPIO.OUT)

while True:

humidity, temperature = Adafruit_DHT.read_retry(11,16)

print(temperature, humidity)

time.sleep(1)

if (humidity>50):

GPIO.input (sensor)

GPIO.output (led, True)

else:

GPIO.output (led,False)

You might also like