Professional Documents
Culture Documents
2.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(13,GPIO.IN) #button
GPIO.setup(21,GPIO.OUT) #led
while True:
# Turn LED on
print ("LED on")
GPIO.output(21, GPIO.HIGH)
3.
#import mod
import smtplib
from email.mime.text import MIMEText
import RPi.GPIO as GPIO
import time
#setup gpio pins
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
#Print message on screen
print "Push button to send email,"
#start loop
loop = "1"
while loop == "1":
#test GPIO for input
if GPIO.input(17):
#create email
message = """Test email send via RPi and Python"""
msg = MIMEText(message)
msg['subject'] = 'Rpi test'
msg['from'] = 'My email>'
msg['to'] = 'Their email'
# send mail
s = smtplib.SMTP('smtp server')
s.login('user name' , 'Password')
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.quit
print "Email sent"
time.sleep(2)
while GPIO.input(17):
pass
4.
#!/usr/bin/env python
import os
import datetime
import time
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
DEBUG = 1
GPIO.setmode(GPIO.BCM)
def RCtime (RCpin):
reading = 0
GPIO.setup(RCpin, GPIO.OUT)
GPIO.output(RCpin, GPIO.LOW)
time.sleep(.1)
GPIO.setup(RCpin, GPIO.IN)
# This takes about 1 millisecond per loop cycle
while (GPIO.input(RCpin) == GPIO.LOW):
reading += 1
return reading
while True:
GetDateTime =
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
LDRReading = RCtime(3)
print RCtime(3)
# Open a file
fo =
open("/home/pi/Desktop/gpio_python_code/foo.txt", "wb")
fo.write (GetDateTime)
LDRReading = str(LDRReading)
fo.write ("\n")
fo.write (LDRReading)
5.
a) Asus Tinker Board
b) ODroid XU4
Its specs stand out from the crowd too, with the ability to add
fast SSD storage via its 4 x PCIe 2.0 NMVe interface and SATA
3.0 ports, and support for up to 32GB of DDR4 RAM.
Additionally, there is fast network connectivity via the two
gigabit Ethernet ports, although no mention of Wi-Fi support.
However, while Odroid boards have a good reputation for
software support, this board doesn't appear to be targeting
hardware hackers, with only a 20-pin expansion header.
d) NanoPi NEO4
It's worth noting that some users of recent NanoPi boards have
also encountered driver problemsand system setup issues, so
this board and the NEO4 may be one for the more technically
proficient.
e) Rock64
UNIT-V
1.
MapReduce framework which allows us to perform such parallel
computations without bothering about the issues like reliability,
fault tolerance etc. Therefore, MapReduce gives you the
flexibility to write code logic without caring about the design
issues of the system.
MapReduce Tutorial: What is MapReduce?
MapReduce consists of two distinct tasks – Map and
Reduce.
As the name MapReduce suggests, reducer phase takes
place after mapper phase has been completed.
So, the first is the map job, where a block of data is read
and processed to produce key-value pairs as intermediate
outputs.
The output of a Mapper or map job (key-value pairs) is input
to the Reducer.
The reducer receives the key-value pair from multiple map
jobs.
Then, the reducer aggregates those intermediate data
tuples (intermediate key-value pair) into a smaller set of
tuples or key-value pairs which is the final output.
2.
Use:
1.better performance
2.increased reliability
3. Granular Scalability
4. Simplifed Decoupling
Amazon SQS:
Amazon SQS supports the logical data types String, Number,
and Binary with optional custom data type labels with the
format .custom-data-type
With DynamoDB, you can create database tables that can store
and retrieve any amount of data, and serve any level of request
traffic. You can scale up or scale down your tables' throughput
capacity without downtime or performance degradation, and
use the AWS Management Console to monitor resource
utilization and performance metrics.
Components Required:
Raspberry Pi
Pi Camera
PIR Sensor
LED
Bread Board
Resistor (1k)
Connecting wires
Power supply
Working Explanation:
5.
Air quality nowadays has been degraded to a large extent that
it has become a necessary criteria for us to monitor its quality.
The quality of air has been affected by various factors like
industrial emission, vehicular transmission etc.
The evolution of various technology like the Internet of Things,
Raspberry Pi, it has become easier for us to deploy sensors
and allow to detect the quality of air in real time.
The Internet Of things is a term for various devices
communicating with each other which was not possible before
since the different devices use different kind of data which has
been overcome by the use of single board computer
(Raspberry Pi).
Integration of IOT with Sensor nodes with the help of Raspberry
Pi for Air Quality Monitoring provides an effective way than the
approaches that were previously used.
Sensor web node is proposed with commercial gas sensors for
detecting the gases like CO, CO2 etc to monitor both indoor
and outdoor air quality.
The results obtained through these sensors are then evaluated
by Ruby on Rails Server through web socket.