MODULE 5
MODULE 5
IoT Logical Design using Python, IoT Physical Devices and Endpoints - Raspberry Pi
interfaces, Programming Raspberry Pi using Python, Other IoT devices, IoT Physical
devices and Cloud offerings, Cloud Storage Models, WAMP - Autobahn for IoT,
Django, Designing RESTful Web API, Cloud Web Services for IoT.
1) What are the basic building blocks of an IoT Device?
1. Sensing- Sensors can be either on-board the IoT device or attached to the device.
2. Actuation- IoT devices can have various types of actuators attached that allow
taking actions upon the physical entities in the vicinity of the device.
3. Communication-Communication modules are responsible for sending collected
data to other devices or cloud-based servers/storage and receiving data from
other devices and commands from remote applications.
4. Analysis & Processing- Analysis and processing modules are responsible for
making sense of the collected data.
Block diagram of an IoT Device
#Switch Pin
GPIO.setup(25, GPIO.IN)
# KLED Pin
GPIO.setup(18, GPIO.OUT)
state=false
def togglelED(pin):
state = not state
GPIO.output(pin, state)
while True:
try:
if (GPIO.input(25) == True):
toggleLED(pin)
sleep(.01)
except KeyboardInterrupt:
exit()
5.3) Python program for switching LED/Light based on LDR Reading?
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
ldr_threshold=1000
LDR_PIN=18
LIGHT_PIN=25
def readLDR(PIN):
reading=0
GPIO.setup(LIGHT_PIN, GPIO.0UT)
GPIO.output(PIN, False)
time.sleep(0.1)
GPIO.setup(PIN, GPIO.IN)
while (GPIO.input(PIN)==Fa1se):
reading=reading+1
return reading
def switchOnLight(PIN):
GPIO.setup(PIN, GPIO.OUT)
GPIO.output(PIN, True)
def switchOfLight(PIN):
GPIO.setup(PIN, GPIO.OUT)
GPIO.output(PIN, False)
While True:
ldr_reading=readLDR(LDR_PIN)
if ldr_reading<ldr_threshold:
switchOnLight(LIGHT_PIN)
else:
switchOffLight(LIGHT_PIN)
time.sleep(1)
Advantages of Xively:
3. File Storage:
File storage is a type of storage that stores data as files, typically accessed using
Network File System (NFS) or Server Message Block (SMB) protocols.
It is commonly used in content management systems, file sharing platforms, and
collaborative applications.
Advantages: File storage is easy to use and provides shared access to files across
multiple users or systems. It also supports features such as file locking, file
permissions, and access control.
Disadvantages: It have slower access times and lower scalability than object
storage.
4. Archive Storage:
Archive storage is a type of storage that is designed for long-term retention of
data that is rarely accessed.
Archive storage is ideal for storing data that must be retained for regulatory
purposes, such as legal documents or financial records.
Advantages: Archive storage provides cost-effective, long-term storage with low
access costs.
Disadvantages: It may have longer access times and lower availability than other
types of storage.