Prelab1 1.What is IoT? Ans. The Internet of Things (IoT) describes the network of physical objects - “ things” — that are embedded with sensors, software, and other technologies for the purpose of connecting and exchanging data with other devices and systems over the internet. These devices range from ordinary household objects to sophisticated industrial too ls. Applications of IOT: 1.Smart Home 2.Smart Agriculture 3.Smart Parking 4.Smart Transport 5.Smart Cities. 2. What is a sensor? Identify some sensors used in smart homes. Ans. A device which detects or measures a physical property and records, indic ates, or otherwise responds to it. Some sensors used in smart homes are Temperature sensors, Ultrasonic sensors. 3. What is an actuator? What are the types of actuators? Ans. An actuator is a component of a machine that is responsible for moving and controlling a mechanism or system, for example by opening a valve. In simple terms, it is a "mover". An actuator requires a control device (controlled by control signal) an d a source of energy. The three main types of actuators are pneumatic (air pressure), hydraulic (fluid pressure) and electric. 4. What is the role of things and the internet in IoT? Ans. The Internet of Things (IoT) is a term that refers to the connection of physical devices to the internet, allowing them to "talk" to each other in order to collect and exchange data. This data can then be used to make decisions and take actions without any manual input from a user. 5. Draw the high - level architecture of IOT. Ans. 6.Write about I2C and SPI protocol. Ans. I2C stands for the inter - integrated controller. This is a serial communication protocol that can connect low - speed devices. It is a master - slave communication in which we can connect and control mu ltiple slaves from a single master. In this, each slave device has a specific address. SPI stands for the Serial Peripheral Interface. It is a serial communication protocol that is used to connect low - speed devices. It was developed by Motorola in the mid - 1980 for inter - chip communication. 7. What are the applications of buzzer and push buttons? Ans. Typical applications include siren, alarm device, fire alarm, air defense alarm, burglar alarm, timer, etc. It is widely used in household appliances, alarm sys tem, automatic production line, low - voltage electrical equipment, electronic toys, game machines and other products and industries. Experiment 1: 1. Programming the Raspberry Pi to blink RED LED glow AIM : To program Raspberry Pi to blink RED LED. THEORY: ETS IoT KIT has 3 RGB LEDs which has been connected to raspberry pi through MCP23017. SOURCE CODE : import sys import time sys. path.append("/home/pi/Adafruit - Raspberry - Pi - Python - Code - legacy/Adafruit_MCP230XX") from Adafruit_MCP230XX import Adafruit_MCP230XX mcp=Adafruit_MCP230XX(busnum=1,address=0x20,num_gpios=16) mcp.config(0,mcp.OUTPUT) mcp.config(1,mcp.OUTPUT) mcp.config(2,mcp.OUTPUT) mcp.config(3,mcp.OUTPUT) mcp.config(4,mcp.OUTPUT) mcp.config(5,mcp.OUTPUT) mcp.config(6,mcp.OUTPUT) mcp.c onfig(7,mcp.OUTPUT) mcp.config(8,mcp.OUTPUT) while(True): mcp.output(0,1) mcp.output(3,1) mcp.output(6,1) time.sleep(1) mcp.output(0,0) mcp.output(3,0) mcp.output(6,0) time.sleep(1) OUTPUT : The three LED’s glow red for 1 second and gets off for 1 second and again glows. 2. Programming the Raspberry Pi to detect push button AIM : To program Raspberry Pi to detect whether push button is pressed or not. THEORY: ETS IoT KIT has 2 PUSH BUTTON which has been connected to raspberry pi through MCP23017. SOURCE CODE : import sys import time sys.path.append("/home/pi/Adafruit - Raspberry - Pi - Python - Code - legacy/Adafruit_MCP230XX") from Adafruit_MCP230XX import Adafruit_MCP230XX mcp=Adafruit_MCP230XX(busnum=1,address=0x20,num_gpio s=16) mcp.config(9,mcp.INPUT) mcp.pullup(9,1) mcp.config(10,mcp.INPUT) mcp.pullup(10,1) while(True): print("PIN 9="+str(mcp.input(9))) print("PIN 10="+str(mcp.input(10))) time.sleep(2) OUTPUT : For every two seconds the status of pushbutton is printed on monitor. Case 1: When both pushbuttons are pressed PIN 9=1 PIN 10=1 Case 2: When only pushbutton on left side is pressed PIN 9=1 PIN 10=0 Case 3: When only pushbutton on right side is pressed PIN 9=0 PIN 10=1 Case 4: When no pushbutton is presse d PIN 9=0 PIN 10=0 Prelab 2 1. What is the functionality of IoT gateway? Ans. An IoT gateway can act as a central hub and perform the necessary translations to allow inter - device communications. Device - to - Cloud Communications: IoT devices commonly send data to cloud - based infrastructure for processing and use in applications. 2.The number of addresses can be achieved with IPv6 addressing__________ Ans. IPv6 uses 128 - bit (2^128) addresses, allowing 3.4 x 1038 unique IP addresses. This is equal to 340 trillion trillion trillion IP addresses. 3. Determine the IoT levels for designing home automation Ans. IOT level 1 is used for designing IOT devices for home automation. 4. Which communication protocols are used for M2M local area networks Ans. Some of the most widely used protocols in M2M are MQTT, CoAP, OMA LWM2M. Experiment 2 1. Programming the Raspberry Pi to buzzer AIM: To program the Raspberry Pi to ring the buzzer. THEORY: ETS IoT KIT has a BUZZER which has been connected to raspberry pi through MCP23017. SOURCE CODE: import sys import time sys.path .append("/home/pi/Adafruit - Raspberry - Pi - Python - Code - legacy/Adafruit_MCP230XX") from Adafruit_MCP230XX import Adafruit_MCP230XX mcp=Adafruit_MCP230XX(busnum=1,address=0x20,num_gpios=16) mcp.config(11,mcp.OUTPUT) while(True): mcp.output(11,1) time.sl eep(2) mcp.output(11,0) time.sleep(2) OUTPUT : The buzzer will ring for a second and it gets off and again rings after a second. This process continues until the program is running on the Raspberry Pi. 2 Programming the Raspberry Pi to implement (i) the glow all green LEDs when a push button is pressed (ii) the glow all red LEDs when a push button is pressed (iii) if user presses both buttons at a time, then buzzer should on AIM : To program the Raspberry Pi such that (i ) A ll LED’s glow green when push button is pressed. (ii)All LED’s glow red when push button is pressed. (iii)The buzzer gets on when both the push buttons are pressed at same time. THEORY : LED ETS IoT KIT has 3 RGB LEDs which has been connected to raspberry pi through MCP23017. Push Button ETS IoT KIT has 2 PUSH BUTTON which has been connected to raspberry pi through MCP23017 Buzzer ETS IoT KIT has a BUZZER which has been connected to raspberry pi through MCP23017. (i) SOURCE CODE : import sys import time sys.path.append("/home/pi/Adafruit - Raspberry - Pi - Python - Code - legacy/Adafruit_MCP230XX") from Adafruit_MCP230XX import Adafruit_MCP230XX mcp=Adafruit_MCP230XX(busnum=1,address=0x20,num_gpios=16) mcp.config(9,mcp.INPUT) mcp.pullu p(9,1) mcp.config(10,mcp.INPUT) mcp.pullup(10,1) mcp.config(1,mcp.OUTPUT) mcp.config(4,mcp.OUTPUT) mcp.config(7,mcp.OUTPUT) while(true): if(mcp.input(9) or mcp.input(10)): mcp.output(1,1) mcp.output(4,1) mcp.output(7,1) else: mcp.output(1,0) mcp.output(4,0) mcp.output(7,0) OUTPUT : All the three LED glow in green color when either of the push button is pressed. (i i ) SOURCE CODE : import sys import time sys.path .append("/home/pi/Adafruit - Raspberry - Pi - Python - Code - legacy/Adafruit_MCP230XX") from Adafruit_MCP230XX import Adafruit_MCP230XX mcp=Adafruit_MCP230XX(busnum=1,address=0x20,num_gpios=16) mcp.config(9,mcp.INPUT) mcp.pullup(9,1) mcp.config(10,mcp.INPUT) mcp.pullup(10,1) mcp.config(0,mcp.OUTPUT) mcp.config(3,mcp.OUTPUT) mcp.config(6,mcp.OUTPUT) while(true): if(mcp.input(9) or mcp.input(10)): mcp.output(0,1) mcp.output(3,1) mcp.output(6,1) else: mcp.output(0,0) mcp.output(3,0) mcp.output(6,0) OUTPUT : All the three LED glow in red color when either of the push button is pressed. (iii) SOURCE CODE : import sys import time sys.path.append("/home/pi/Adafruit - Raspberry - Pi - Python - Code - legacy/Adafruit_MCP 230XX") from Adafruit_MCP230XX import Adafruit_MCP230XX mcp=Adafruit_MCP230XX(busnum=1,address=0x20,num_gpios=16) mcp.config(9,mcp.INPUT) mcp.pullup(9,1) mcp.config(10,mcp.INPUT) mcp.pullup(10,1) mcp.config(11,mcp.OUTPUT) while(true): if(mcp.input (9) and mcp.input(10)): mcp.output(11,1) else: mcp.output(11,0) OUTPUT : The buzzer gets on when both the push buttons are pressed at same time and will remain or get turned off in any other case. Prelab 3 1. Give an application scenario where ultrasonic sensor can be used. Ans. The ultrasonic sensor can be used in automatic cars to detect the distance between car and any other object on the road. 2. What are the two modes numbering I/O pins in RPi? Which one is preferable? Ans. the two modes used for addressing the pins in Raspberry Pi are: GPIO and BCM. BCM channel changes as version number changes so, GPIO is preferable. 3. Draw the basic functional block diagram of BME280 humidity and temperature sensor 4. Give the details of BME 280 sensor? What are the ranges supported by this sensor? Ans. The BME280 device is a digital barometric pressure sensor and is a slightly upgraded version of the BMP180. This is available on a small module which provides access t o the sensor via the I2C interface. The I2C address of BME280 sensor in ETS IoT KIT is 0x76.The operational temperature range of the BME280 is - 40 to 85 °C. 5. Draw the connection diagram to BME280 Experiment 3 1. Programming open - source board to read data from onboard Temperature, Pressure & Humidity sensor (BME280) AIM : To program the open - source board to read data from onboard temperature, pressure and humidity using BM280 sensor. THEORY : ETS IoT KIT has an ENVIRONMENTAL Sensor which has been connected to raspberry pi through I2C. It will show the value of TEMPERATURE, PRESSURE and HUMIDITY. The I2C address of BME280 sensor in ETS IoT KIT is 0x76. SOURCE CODE : import sys sys.path.append('/home/pi/ETS_IOT_KIT_demo/DemoCode /BM280') import BM280 as BME while True: temperature,pressure,humidity=BME.readBME280All() print("Temperature :"+str(temperature)) print("Pressure :"+str(pressure)) print("Humidity :"+str(humidity)) OUTPUT : Temperature :26.71 Pressu re :951.254102412 Humidity :35.0968483115 Temperature :26.7 Pressure :951.25079809 Humidity :35.1283420684 Prelab 4 1.What is sensor? List different types of Analog and digital sensors Ans. A sensor is a device that measures or detects a physical quantity or environmental condition, such as temperature, pressure, light, sound, motion, or humidity, and converts the signal into an electrical or digital output that can be processed by a computer or electronic system. Analog sensors: Thermisto r - measures temperature changes through changes in electrical resistance Strain gauge - measures deformation or strain in an object due to an applied force Pressure sensor - measures changes in pressure or force Light dependent resistor (LDR) - measures c hanges in light intensity Accelerometer - measures changes in acceleration Digital sensors: Magnetic sensor - detects magnetic fields and changes in magnetic fields Motion sensor - detects motion and changes in motion Proximity sensor - detects the presence or absence of nearby objects pH sensor - measures the acidity or basicity of a liquid Gas sensor - detects the presence of specific gases in the environment 2.What is role of mcp3008? Ans.The MCP3008 is an analog - to - digital converter (ADC) chip t hat allows a microcontroller or computer to convert analog signals from sensors or other analog sources into digital data that can be processed and analyzed. 3.What is PIR and applications of PIR sensor. PIR stands for Passive Infrared Sensor. It is an el ectronic sensor that can detect the presence of objects, animals, or people by detecting changes in the infrared radiation emitted by them.PIR sensors are commonly used in security systems, motion - activated lighting systems, and other applications that req uire detection of movement or presence of people or objects. 4.What is pi to pi communication? Ans.Pi to Pi communication refers to the process of exchanging data between two Raspberry Pi devices, either directly through a physical connection or through a network connection. 5.How to generate server MAC address. Ans. To generate a MAC address for a server, you can follow these general steps: 1.Determine the organizationally unique identifier (OUI) for the manufacturer of the NIC. The OUI is the first thr ee bytes of the MAC address and is assigned by the Institute of Electrical and Electronics Engineers (IEEE). A list of OUIs is available from the IEEE website. 2.Generate a random value for the last three bytes of the MAC address. These bytes are used to c reate a unique identifier for the NIC. 3.Combine the OUI and the random value to create a complete MAC address. Experiment 4 1. Programming open - source board to interface with PIR sensor. AIM : To program open - source board to in terface with PIR sensor. THEORY : A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view. They are most often used in PIR - based motion detectors. The connections are made as follows: SOURCE CODE : import time import sys sys.path.append('/home/pi/Adafruit - Raspberry - Pi - Python - Code - legacy/Adafruit_MCP230XX') from Adadfruit_MCP230XX import Adafruit_MCP230XX mcp=Adafruit_MCP230XX(busnum=1,address=0x20,num_gpios=16) mcp1=Adafruit_MCP230XX(busnum=1,addre ss=0x21,num_gpios=16) mcp1.config(0,mcp.INPUT) mcp.config(11,mcp.OUTPUT) mcp.pullup(0,1) while(True): i=mcp1.input(0) time.sleep(2) if(i==1): print('Person Detected') mcp.output(11,1) #Buzzer starts buzzing time.sleep (2) #Buzzer sounds for 2 seconds mcp.output(11,0) #Buzzer is turned off else: print('Person Not Detected') OUTPUT : Case 1: When a person or an object approaches the PIR sensor then on monitor, we get display as “Person Det ected” and buzzer rings for 2 seconds. Case 2: When person or object is not near the sensor then on monitor, we get display as “Person Not Detected” and buzzer doesn’t ring. 2. Programming open - source board to interface with ultrasonic sensor. AIM : To program open - source board to interface with ultrasonic sensor. THEORY: Ultrasonic sensors “are based on the measurement of the properties of acoustic waves with frequencies above the human audible range,” often at roughly 40 kHz They typically operate by generating a high - frequency pulse of sound, and then receiving and evaluating the properties of the echo pulse. SOURCE CODE : import time import sys import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO_TRIGGER=16 GPIO_ECHO=18 GPIO .setup(GPIO_TRIGGER,GPIO.OUT) GPIO.setup(GPIO_ECHO,GPIO.IN) GPIO.output(GPIO_TRIGGER,False) i=1 time.sleep(0.5) while(True): GPIO.output(GPIO_TRIGGER,True) time.sleep(0.00001) GPIO.output(GPIO_TRIGGER,False) while(GPIO.input(GPIO_ECHO)==0): start=time.time() while(GPIO.input(GPIO_ECHO)==1): stop=time.time() elapsed=stop - start distance=elapsed*34300 distance=distance/2 print( “ Distance of Object is ”+str( distance) ) time.sleep(5) i+=1 OUTPUT : When an object or obstacle is placed at a distance of 10 cm from the sensor then the output will be: Distance of Object is 10 Prelab 5 1.Write the applications of servo motor Ans. Servo motors are widely used in various applications where precise control of position, velocity, and acceleration is required. Here are some common applications of servo motors: 1.Robotics 2.CNC machines 3.Aerospace industry 4.Industrial automation 2. Draw the pin mapping of servo motor Ans. 3. Classify the different motors available. Ans. Motors can be classified into different types based on several factors, including the type of power source, operating principle, and application. Here are some common classifications of motors: 1.AC motors 2.DC motors 3.Brushed DC motors 4.Brushless DC motors 5.Stepper motors 6.Servo Motors 4. Differentiate between Servo motor and DC motor. Ans. A servo motor is a rotatory actuator that allows for a precise control of angular position, velocity and acceleration. A DC motor is a type of electrical machine that uses electrical energy to convert it into mechanical energy for driving a mechanical load. 5. How does Tinkercad allow design of circuits? Ans. Tinkercad's Circuit s editor has a similar layout to its 3D design editor. We'll find a large window on the left for creating our design. On the right side we'll see a panel filled with components we can drag and drop into the workspace to create our circuit. Experiment 5 1. Pr ogramming open - source board to interface with moisture sensor for Agriculture based applications. AIM : To program open - source board to interface with moisture sensor for Agriculture based applications. THEORY : Soil Moisture Sensor is a simple breakout for measuring the moisture in soil and similar materials. The soil moisture sensor is pretty straight forward to use. The two large exposed pads function as probes for the sensor, together acting as a variable resistor. The more water that is in the soil means the better the conductivity between the pads will be and will result in a lower resistance, and a higher SIG out. SOURCE CODE : import time import Adafruit_GPIO.SPI as SPI import Adafruit_MCP3008 CLK=23 MISO=21 MOSI=19 CS=25 mcp=Adafruit_MCP3008.MCP3008( clk=CLK,cs=CS,miso=MISO,mosi=MOSI) SPI_PORT=0 SPI_DEVICE=0 mcp=Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT,SPI_DEVICE)) while(True): i=mcp.read_adc(0) t=i p=(100 - ((t/1023.0)*100)) print('Moisture Content :',p) time.sleep(3) OUTPUT : Moisture Content :17.899 Moisture Content :17.499 Moisture Content :17.599 Moisture Content :17.399 Prelab 6 1.How to measure accuracy of soil moisture sensor? Ans. The accuracy of a soil moisture sensor can be measured by comparing its readings to actual soil moisture measurements obtained through a different method, such as gravimetric soil moisture analysis or time domain reflectometry (TDR). By comparing the sensor readings to actual moisture co ntent values obtained through a different method, you can determine the accuracy of the soil moisture sensor and make any necessary adjustments to ensure more accurate readings. 2. What is the difference between volumetric water content(VWC) and gravimetr ic water content( GWC)? Ans. Volumetric water content (VWC) is the ratio of the volume of water held in the soil to the total volume of the soil. It is expressed as a percentage or decimal value, and represents the amount of water available for plants to u se. Gravimetric water content (GWC) is the ratio of the mass of water held in the soil to the mass of the dry soil. It is also expressed as a percentage or decimal value, and represents the amount of water in a given mass of soil. 3. After installing the sensor probes, there is some variability between readings even though they are all buried at the same depth why? Ans. There are several factors that can contribute to variability between soil moisture sensor readings, even when they are installed at the same depth. Here are some possible reasons: 1.Soil heterogeneity 2.Sensor placement 3.Sensor calibration 4.Environmental factors 4. Difference between EC - 5 and ECH20 sensors. Ans. The main differences between the EC - 5 and ECH2O soil moisture sensors are: 1.Measurement method: The EC - 5 uses time domain reflectometry (TDR) to measure soil moisture, while the ECH2O uses capacitance. 2.Accuracy: The EC - 5 is generally considered more accurate than the ECH2O, particularly in soils with high clay content or elec trical conductivity. 3.Cost: The EC - 5 is generally more expensive than the ECH2O. 4.Maintenance: The ECH2O requires periodic calibration, while the EC - 5 is typically more durable and requires less maintenance. Experiment 6 1.Programming open - source board t o interface with actuators (servo motor). AIM : To program open - source board to interface with actuators (servo motor). THEORY : The servo motor is most commonly used for high technology devices in the industrial application like automation technology. It is a self - contained electrical device that rotate parts of a machine with high efficiency and great precision. The output shaft of this motor can be moved to a particular angle. Servo motors are mainly used in home electronics, toys, cars, airplanes, etc. SOURCE CODE : import RPI import RPI.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(22,GPIO.OUT) pwm=GPIO.PWM(22,100) pwm.start(5) angle1=10 duty1=float(angle1)/10+2.5 angle2=160 duty2=float(angle2)/10+2.5 ck=0 while(ck<=5): pwm.changeDutyCycle(duty1) time.sleep(0.8) pwm.changeDutyCycle(duty2) time.sleep(0.8) ck=ck+1 time.sleep(1) GPIO.cleanup() OUTPUT: The actuator i.e., the servo motor rotates 100 degrees.