Added content.
- Notes - Practical - Question Papers - DISCLAIMER and motto file Lastly, updated README file.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,72 @@
|
||||
"""
|
||||
THIS CODE HAS BEEN TESTED ON RASPBERRY PI 3B AND IS FULLY OPERATIONAL.
|
||||
|
||||
Problem Statement: Understanding the connectivity of Raspberry-Pi / Arduino with IR sensor. Write an application to detect obstacle and notify user using LEDs.
|
||||
|
||||
Code from InternetOfThingsAndEmbeddedSystems (SPPU - Third Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-te-comp-content/InternetOfThingsAndEmbeddedSystems
|
||||
"""
|
||||
|
||||
# BEGINNING OF CODE
|
||||
# SINGLE LED ON/OFF
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.setup(16,GPIO.OUT)
|
||||
try:
|
||||
while True:
|
||||
print(“LED ON”)
|
||||
GPIO.output(16,GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
print(“LED OFF”)
|
||||
GPIO.output(16,GPIO.LOW)
|
||||
time.sleep(1)
|
||||
except:
|
||||
GPIO.cleanup()
|
||||
|
||||
##########
|
||||
|
||||
# TWO LEDs ON/OFF
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.setup(16,GPIO.OUT)
|
||||
GPIO.setup(26,GPIO.OUT)
|
||||
try:
|
||||
while True:
|
||||
print(“LED ON”)
|
||||
GPIO.output(16,GPIO.HIGH)
|
||||
GPIO.output(26,GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
print(“LED OFF”)
|
||||
GPIO.output(16,GPIO.LOW)
|
||||
GPIO.output(26,GPIO.LOW)
|
||||
time.sleep(1)
|
||||
except:
|
||||
GPIO.cleanup()
|
||||
|
||||
##########
|
||||
|
||||
# BUZZER WITH ONE LED ON/OFF
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.setup(16,GPIO.OUT)
|
||||
GPIO.setup(26,GPIO.OUT)
|
||||
try:
|
||||
while True:
|
||||
print("LED Buzzer ON")
|
||||
GPIO.output(16,GPIO.HIGH)
|
||||
GPIO.output(26,GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
print("LED & Buzzer OFF")
|
||||
GPIO.output(16,GPIO.LOW)
|
||||
GPIO.output(26,GPIO.LOW)
|
||||
time.sleep(1)
|
||||
except:
|
||||
GPIO.cleanup()
|
||||
|
||||
##########
|
||||
# END OF CODE
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
"""
|
||||
THIS CODE HAS BEEN TESTED ON RASPBERRY PI 3B and 4B AND IS FULLY OPERATIONAL.
|
||||
|
||||
Problem Statement: IR Sensor
|
||||
|
||||
Code from InternetOfThingsAndEmbeddedSystems (SPPU - Third Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-te-comp-content/InternetOfThingsAndEmbeddedSystems
|
||||
"""
|
||||
|
||||
# BEGINNING OF CODE
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.setup(16,GPIO.IN) # For IR sensor
|
||||
GPIO.setup(26,GPIO.OUT) # For LED
|
||||
|
||||
try:
|
||||
while True:
|
||||
if (GPIO.input(16)):
|
||||
print("No object")
|
||||
GPIO.output(26,GPIO.LOW) # LED OFF when no object detected
|
||||
else:
|
||||
print("Object Detected")
|
||||
GPIO.output(26,GPIO.HIGH) # LED ON when object detected
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup()
|
||||
# END OF CODE
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,44 @@
|
||||
"""
|
||||
THIS CODE HAS BEEN TESTED ON RASPBERRY PI 3B, 4B AND IS FULLY OPERATIONAL.
|
||||
|
||||
Problem Statement: Temperature and humidity sensing using DHT11.
|
||||
|
||||
Code from InternetOfThingsAndEmbeddedSystems (SPPU - Third Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-te-comp-content/InternetOfThingsAndEmbeddedSystems
|
||||
"""
|
||||
|
||||
# NOTE: PLEASE REFER DHT11 repo by notkshitij for initialization: https://git.kska.io/notkshitij/DHT11/
|
||||
|
||||
# This code will only work in the virtual environment
|
||||
# To enable the virtual environment, change current working directory using 'cd <DIR>'
|
||||
# Activate the virtual environment using 'source bin/activate'
|
||||
# Run this code 'python3 IoT\ -\ Code-4.py'
|
||||
|
||||
# BEGINNING OF CODE
|
||||
# NOTE: GPIO PIN 16 used
|
||||
|
||||
import RPi.GPIO as GPIO
|
||||
import dht11
|
||||
import time
|
||||
|
||||
# initialize GPIO
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False) # Set True if you are having trouble connecting the DHT11 sensor to Raspberry Pi. Doing so will show warnings on screen.
|
||||
|
||||
try:
|
||||
while True:
|
||||
# read data using pin 16
|
||||
instance = dht11.DHT11(pin = 16)
|
||||
result = instance.read()
|
||||
|
||||
if result.is_valid():
|
||||
print("Temperature: %-3.1f C" % result.temperature)
|
||||
print("Humidity: %-3.1f %%" % result.humidity)
|
||||
else:
|
||||
print("Error: %d" % result.error_code)
|
||||
# Error 1 implies sensor not detected, thus no data
|
||||
# Error 2 implies checksum error, data corrupted, i.e. GPIO connection might be lose
|
||||
time.sleep(3)
|
||||
except KeyboardInterrupt:
|
||||
print("Program stopped by user.")
|
||||
GPIO.cleanup()
|
||||
# END OF CODE
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
+19
@@ -0,0 +1,19 @@
|
||||
: '
|
||||
THIS CODE HAS BEEN TESTED ON RASPBERRY PI 3B, 4B AND IS FULLY OPERATIONAL.
|
||||
|
||||
Problem Statement: Picamera
|
||||
|
||||
Code from InternetOfThingsAndEmbeddedSystems (SPPU - Third Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-te-comp-content/InternetOfThingsAndEmbeddedSystems
|
||||
'
|
||||
|
||||
# BEGINNING OF CODE
|
||||
|
||||
# Run these command one by one manually in the terminal.
|
||||
# Image and video file will be saved in Desktop directory of the cuurent user.
|
||||
|
||||
cd /home/$(whoami)/Desktop/ # Changing current working directory to Desktop
|
||||
raspicam-still -o test.jpg # Image
|
||||
libcamera-vid --codec h254 vid.h264
|
||||
|
||||
# END OF CODE
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
# IoT Connections
|
||||
|
||||
[Refer Raspberry Pi pinout diagram](https://git.kska.io/sppu-te-comp-content/InternetOfThingsAndEmbeddedSystems/src/branch/main/Practical/Raspberry%20Pi%20%282+3+4+5%29%20GPIO%20Pinout.png)
|
||||

|
||||
|
||||
## Assignment 2 - LEDs and Buzzer
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Long terminal in LED is always positive, short terminal is always negative.
|
||||
|
||||
### Single LED
|
||||
|
||||
**Device** | **Positive terminal** | **Negative terminal (Ground/GND)** | **Signal/Output**
|
||||
--- | --- | --- | ---
|
||||
LED | GPIO 16 (PIN 36) | GROUND (PIN 34) | N/A
|
||||
|
||||
|
||||
### Two LEDs
|
||||
|
||||
**Device** | **Positive terminal** | **Negative terminal (Ground/GND)** | **Signal/Output**
|
||||
--- | --- | --- | ---
|
||||
LED 1 | GPIO 16 (PIN 36) | GROUND (PIN 34) | N/A
|
||||
LED 2 | GPIO 26 (PIN 37) | GROUND (PIN 39) | N/A
|
||||
|
||||
### Buzzer with one LED
|
||||
|
||||
**Device** | **Positive terminal** | **Negative terminal (Ground/GND)** | **Signal/Output**
|
||||
--- | --- | --- | ---
|
||||
Buzzer | GPIO 16 (PIN 36) | GROUND (PIN 34) | N/A
|
||||
LED | GPIO 26 (PIN 37) | GROUND (PIN 39) | N/A
|
||||
|
||||
## Assignment 3 - IR Sensor
|
||||
|
||||
**Device** | **Positive terminal** | **Negative terminal (Ground/GND)** | **Signal/Output**
|
||||
--- | --- | --- | ---
|
||||
IR Sensor | 5V power (PIN 2) | GROUND (PIN 34) | GPIO 16 (PIN 36)
|
||||
LED | GPIO 26 (PIN 37) | GROUND (PIN 39) | N/A
|
||||
|
||||
## Assignment 4 - DHT11 (Temperature sensor)
|
||||
|
||||
**Device** | **Positive terminal** | **Negative terminal (Ground/GND)** | **Signal/Output**
|
||||
--- | --- | --- | ---
|
||||
DHT11 | 5V power (PIN 2) | GROUND (PIN 34) | GPIO 16 (PIN 36)
|
||||
|
||||
## Assignment 5 - Camera
|
||||
|
||||
**Device** | **Positive terminal** | **Negative terminal (Ground/GND)** | **Signal/Output**
|
||||
--- | --- | --- | ---
|
||||
Picamera | N/A | N/A | CSI port
|
||||
|
||||
## Water level
|
||||
|
||||
**Device** | **Positive terminal** | **Negative terminal (Ground/GND)** | **Signal/Output**
|
||||
--- | --- | --- | ---
|
||||
Water sensor | 5V power (PIN 2) | GROUND (PIN 34) | GPIO 16 (PIN 36)
|
||||
LED | GPIO 26 (PIN 37) | GROUND (PIN 39) | N/A
|
||||
|
||||
---
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 142 KiB |
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
THIS CODE HAS BEEN TESTED ON RASPBERRY PI 3B, 4B AND IS FULLY OPERATIONAL.
|
||||
|
||||
Problem Statement: Water level
|
||||
|
||||
Code from InternetOfThingsAndEmbeddedSystems (SPPU - Third Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-te-comp-content/InternetOfThingsAndEmbeddedSystems
|
||||
"""
|
||||
|
||||
# BEGINNING OF CODE
|
||||
import RPi.GPIO as GPIO # Import library
|
||||
|
||||
# Initalize GPIO
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.setup(16, GPIO.IN) # Set GPIO 16 as input for water level sensor signal
|
||||
GPIO.setup(26, GPIO.OUT) # Set GPIO 6 as output for LED
|
||||
|
||||
try:
|
||||
while True:
|
||||
if (GPIO.input(16))
|
||||
GPIO.output(26, True) # Turn ON LED if water detected
|
||||
else
|
||||
GPIO.output(26, False) # Keep LED OFF if no water detected
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup()
|
||||
print("Program exited by user.")
|
||||
# END OF CODE
|
||||
Reference in New Issue
Block a user