Aksh Iot2
Aksh Iot2
(AUTONOMOUS)
(Affiliated to Osmania University)
Ibrahimbagh, Hyderabad – 500 031.
DEPARTMENT OF : Computer Science & Engineering
NAME OF THE LABORATORY : IoT lab
Name:E.Akshaya Roll No. : 1602-21-733-005 Page No. :
WEEK - 02
Buzzer and BME280 onboard sensor on Raspberry PI
PRELAB QUESTIONS - 02
Types of Sensors:
1.Analog Sensors: Thermistors (Temperature), Photocells (Light), Potentiometers
(Position).
2.Digital Sensors: Digital Temperature Sensors, Infrared Motion Sensors, Ultrasonic
Range Finders.
2.Give the details of BME280 sensor. What are the ranges supported by this sensor?
Ans:
The BME280 is an integrated environmental sensor developed by Bosch, capable of measuring
temperature, humidity, and pressure.
Ranges Supported:
1.Temperature: -40°C to +85°C
2.Humidity: 0% to 100% relative humidity
3.Pressure: 300 to1100 hPa (hectopascals)
3.What is an IO expander?
Ans:
An IO expander is a hardware device used to increase the number of input/output (I/O) pins
available on a microcontroller or microprocessor, allowing it to control more devices or read more
sensors. It typically communicates with the main processor via serial interfaces like I2C or SPI
LAB PROGRAM - 02
import sys
sys.path.append('/home/pi/Adafruit-Raspberry-Pi-Python-Code- legacy/Adafruit_MCP230xx')
from Adafruit_MCP230XX import Adafruit_MCP230XX
import time
mcp Adafruit_MCP230XX(busnum = 1, address = 0x20, num gpios = 16)
mcp.config(4, mcp.OUTPUT)
mcp.config(9, mcp.INPUT)
mcp.config(11, mcp.OUTPUT)
while True:
mcp.output(4,0)
if mcp.input(9)==0:
mcp.output(11,1)
mcp.output(4,1)
else:
mcp.output(11,0)
mcp.output(4,0)
OUTPUT:
VASAVI COLLEGE OF ENGINEERING
(AUTONOMOUS)
(Affiliated to Osmania University)
Ibrahimbagh, Hyderabad – 500 031.
DEPARTMENT OF : Computer Science & Engineering
NAME OF THE LABORATORY : IoT lab
Name:E.Akshaya Roll No. : 1602-21-733-005 Page No. :
2) Write a program to read data from BME280 onboard sensor on Raspberry PI
development kit
Code:
import sys
import time
sys.path.append('/home/pi/ETS_IOT KIT demo/DemoCode/BME280')
import BME280lib as BME
while True:
temperature, pressure, humidity=BME.readBME280A11()
print ("Temperature:", temperature, "C")
print ("Pressure :", pressure ,"hPa")
print ("Humidity :", humidity, "%")
time.sleep(3)
OUTPUT: