You are on page 1of 30

Energy efficient building automation

A REPORT on B. Tech Project Part-1

(EE4191)

BY

Devajothi Sardar: 2020EEB018


Satyam Kumar Jha: 2020EEB027
Sounak Bhattacharya: 2020EEB055
Sashank Kandala: 2020EEB063
Priyanshu Agrawal:2020EEB079

UNDER THE GUIDANCE OF

ASHOKE SUTRADHAR

DEPARTMENT OF ELECTRICAL ENGINEERING


INDIAN INSTITUTE OF ENGINEERING SCIENCE AND TECHNOLOGY,
SHIBPUR

2023-2024
DECLARATION BY THE CANDIDATES

I certify that to the best of my knowledge


i) The work contained in the thesis has been done by myself/ourselves
under the general supervision of my/our supervisor/supervisors.

ii) I/We have conformed to the norms and guidelines given in the Ethical
Code of Conduct of the Institute.

iii) Whenever I/we have used materials (data, theoretical analysis and
text) from other sources, I/we have given due credit to them by citing
them in the text of the report and giving their details in the
references.

iv) Whenever I/we have quoted written materials from other sources,
I/we have put them under quotation marks and given due credit to
the sources by citing them and giving details in the references.

SL Name Examination Signature


No. Roll No.

1 Devajothi Sardar 2020EEB018


2 Satyam Kumar Jha 2020EEB027
3 Sashank Kandala 2020EEB063
4 Sounak Bhattacharya 2020EEB055
5 Priyanshu Agrawal 2020EEB079

Date:
Place:
CERTIFICATE

I, do hereby, forward the report on B. Tech. Project Part-1 entitled


Energy efficient building automation prepared by Devajothi Sardar, Satyam
Kumar Jha, Sounak Bhattacharya, Sashank Kandala, Priyanshu Agrawal
under my guidance, as partial fulfillment of requirements for the
completion of degree of B.Tech (Electrical) at IIEST, Shibpur.

_________________________________
Prof. Ashoke Sutradhar
Professor
Department of Electrical
Engineering
IIEST, Shibpur

_______________________________

Dr. Anindita Sengupta


Professor and Head
Department of Electrical Engineering
IIEST, Shibpur
CERTIFICATEOF APPROVAL

We recommend that the report on B. Tech Project Part-1 entitled


“Energy efficient building automation” submitted by Devajothi Sardar,
Satyam Kumar Jha, Sounak Bhattacharya, Sashank Kandala, Priyanshu
Agrawal bearing 2020EEB018, 2020EEB027, 2020EEB055,
2020EEB063, 2020EEB079 to the Department of Electrical
Engineering, Indian Institute of Engineering Science and Technology,
Shibpur be accepted in partial fulfillment of the requirements for the
degree of Bachelor of Technology in Electrical Engineering from this
institution after successfully defended the work by the candidate in the
viva-voce examination held on 07.12.2023.
Board of Examiners

1. ___________________ Signature with date

___________________ Name of the examiner

2.____________________ Signature with date

____________________ Name of the examiner

3.____________________ Signature with date

_____________________ Name of the examiner

4..____________________ Signature with date

____________________ Name of the examiner

Table of Contents
Chapter 1: Introduction............................................................................................................1

Chapter 2: Objective and Overview of the Project...................................................................3

Chapter 3: Implementation of Building Automation System....................................................5

3.1: Controller - Arduino.......................................................................................................6


3.2: Sensors used in the project:.......................................................................................... 6
3.2.1: MQ – 135 GAS SENSOR...............................................................................................6
3.2.2: GP2Y1010AU0F DUST SMOKE PARTICLE SENSOR.......................................................9
3.2.3: DHT11 Temperature and Humidity Sensor...............................................................12
3.2.4: BH1750FVI LIGHT INTENSITY SENSOR.......................................................................15

Chapter 4: Control Logic and Operation.................................................................................17

Conclusion.............................................................................................................................. 19

References..............................................................................................................................20

Appendix................................................................................................................................ 21
Chapter 1: Introduction
A building automation system (BAS) is a system that controls the heating, ventilation, air
conditioning (HVAC), lighting, and other systems in a building. It can be used to improve
energy efficiency, comfort, and security.

An energy management system (EMS) is a system that monitors, controls, and optimizes the
energy use of a building or other facility. It can be used to improve energy efficiency, reduce
energy costs, and improve the comfort and safety of building occupants. EMS is a subset of
BAS

A BAS typically consists of a network of sensors, controllers, and actuators. The sensors
measure the conditions in the building, such as temperature, humidity, and occupancy. The
controllers use the sensor data to determine how to operate the HVAC, lighting, and other
systems. The actuators then carry out the instructions of the controllers.

BAS can be used to improve energy efficiency in a number of ways. For example, they can be
used to:

 Automatically adjust the temperature and humidity in the building to match the
occupancy levels.
 Turn off lights in unoccupied areas.
 Schedule the operation of HVAC and lighting systems.
 Monitor the performance of the building's systems and identify areas where energy
savings can be made.

BAS can also be used to improve comfort and security in a building. For example, they
can be used to:

 Control the ventilation system to improve indoor air quality.


 Monitor the security of the building and trigger alarms if unauthorized access is
detected.
 Provide remote access to the building's systems for maintenance and
troubleshooting.

1|Page
BAS are becoming increasingly common in buildings of all types. They offer a number of
benefits, including improved energy efficiency, comfort, and security.

There are many different types of sensors used in building automation systems (BAS).

The specific sensors used in a BAS will depend on the size and type of building, as well as the
specific needs of the building occupants.

Here are some of the benefits of using a BAS:

 Improved energy efficiency: BAS can help to reduce energy consumption by


automatically adjusting the operation of the building's systems to match the
occupancy levels and weather conditions.
 Improved comfort: BAS can help to create a more comfortable environment for
building occupants by automatically adjusting the temperature, humidity, and
lighting levels.
 Improved security: BAS can help to improve the security of a building by monitoring
access control, intrusion detection, and fire alarm systems.
 Reduced maintenance costs: BAS can help to reduce maintenance costs by providing
remote monitoring and diagnostics of the building's systems.
 Increased productivity: BAS can help to increase productivity by creating a more
comfortable and secure environment for building occupants.

If you are considering installing a BAS, there are a few things you should keep in mind:

The size and complexity of the building will affect the size and complexity of the BAS.

The type of building will also affect the BAS. For example, a hospital will have different
needs than a commercial office building.

The budget available for the BAS will also be a factor.

It is important to work with a qualified BAS engineer to design and install a system that
meets the specific needs of your building.

2|Page
Chapter 2: Objective and Overview of the Project
Building automation systems (BAS) are integrated computer systems that monitor and
control the building's mechanical and electrical equipment. They are designed to improve
the efficiency, comfort, and safety of buildings.

Components of BAS:

BAS are made up of several components, including:

Sensors: Sensors collect data about the building's environment, such as temperature,
humidity, and occupancy.

Actuators: Actuators control the building's equipment, such as heating and cooling systems,
lights, and doors.

Controllers: Controllers are the brains of the BAS. They receive data from the sensors, make
decisions about how to control the equipment, and send commands to the actuators.

Networks: Networks connect all of the BAS components together. They allow the
components to communicate with each other and share data.

Software: Software provides the user interface for the BAS. It allows users to monitor the
building's environment, control the equipment, and troubleshoot problems.

3|Page
In this project we aim to implement an Energy Efficient Building Automation System using
Arduino as the controller.

4|Page
Chapter 3: Implementation of Building Automation
System
3.1: Controller - Arduino
Arduino is an open-source electronics platform based on easy-to-use hardware and
software. Arduino boards are affordable, accessible, flexible and modular, making them well
suited for a wide range of projects, from simple sensor readings to complex robotics.

ATmega328P microcontroller. It has 14 digital input/output pins (of which 6 can be used as
PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power
jack, an ICSP header, and a reset button.

The Arduino Uno has six ADC channels, each capable of converting analog voltages between
0 and 5V into 10-bit digital values ranging from 0 to 1023.

In Arduino, PWM is implemented using analogWrite() function. This function takes two
arguments: the pin number and the desired PWM value. The PWM value ranges from 0 to
255, corresponding to a duty cycle of 0% to 100%.

3.2: Sensors used in the project:


3.2.1: MQ – 135 GAS SENSOR
The MQ-135 Gas sensor can detect gases like Ammonia (NH3), Sulfur (S), Benzene (C6H6),
CO2, and other harmful gases and smoke. Similar to other MQ series gas sensor, this sensor
also has a digital and analog output pin. When the level of these gases go beyond a
threshold limit in the air the digital pin goes high. This threshold value can be set by using
the on-board potentiometer. The analog output pin, outputs an analog voltage which can be
used to approximate the level of these gases in the atmosphere.

Working Principle:

Chemical Reaction:

5|Page
The MQ-135 sensor contains a tin dioxide (SnO2) sensing layer, which undergoes a chemical
reaction with the gases it is designed to detect.

When certain gases come into contact with the SnO2 layer, they cause a change in the
conductivity of the sensor.

Gas Adsorption and Desorption:

In the presence of specific gases, the surface of the SnO2 layer adsorbs or absorbs oxygen
(O2) molecules from the surrounding air.

This process reduces the conductivity of the SnO2 layer in the absence of the target gas.

Conductivity Change:

The conductivity of the SnO2 layer changes depending on the concentration of the target
gas in the environment.

When the sensor is exposed to the target gas, the conductivity increases due to the
chemical reaction between the gas and the SnO2 layer.

Resistance Measurement:

The resistance of the SnO2 layer is measured, and this resistance is inversely proportional to
the gas concentration.

Higher gas concentrations result in lower sensor resistance, and vice versa.

Output Signal:

The change in resistance is converted into an electrical signal that can be processed and
used to determine the concentration of the target gas.

This output signal can be calibrated to provide a quantitative measurement of the gas
concentration.

6|Page
Figure 1 MQ135 SENSOR MODULE

Figure 2 MQ135 Connection Diagram

7|Page
3.2.2: GP2Y1010AU0F DUST SMOKE PARTICLE SENSOR
GP2Y1010AU0F is a dust sensor that works by using optical sensing system. An infrared
emitting diode (IRED) and a photo-transistor are diagonally arranged into this device. It
detects the reflected light of dust in air. Especially, it is effective to detect very fine particle
like the cigarette smoke. In addition, it can distinguish smoke from house dust by pulse
pattern of the output voltage obtained.

Working Principle:

Infrared LED and Phototransistor Pair:

The sensor contains an infrared LED and a phototransistor positioned in such a way that the
emitted infrared light from the LED passes through the air and is scattered by particles in the
air. The scattered light is then detected by the phototransistor.

Amplification Circuit:

The phototransistor generates a current proportional to the amount of scattered light it


receives. An amplification circuit is used to amplify this current signal, making it easier to
measure.

Output Signal:

The amplified signal is then converted into a voltage signal, which is the output of the
sensor. The voltage level is directly related to the concentration of particles in the air—the
higher the concentration, the higher the output voltage.

Calibration:

The sensor may need calibration to correlate the output voltage with a specific particle
concentration. Calibration is typically done by exposing the sensor to a known concentration
of particles and adjusting the sensor output accordingly.

8|Page
Signal Processing:

In some applications, additional signal processing may be performed to filter out noise and
improve the accuracy of particle concentration measurements.

Output Interface:

The sensor often has an analog voltage output that can be connected to a microcontroller or
other measurement devices for further processing.

Figure 3 GP2Y1010AU0F Particle sensor

Figure 4 GP2Y1010AU0F Connection diagram

9|Page
3.2.3: DHT11 Temperature and Humidity Sensor
The DHT11 sensor measures humidity and temperature using a capacitive humidity sensor
and a thermistor, respectively. It communicates with a microcontroller using a single digital
data pin, sending a series of 40 bits of data consisting of humidity, temperature, and a
checksum. It is a low-cost, easy-to-use sensor with moderate accuracy, making it suitable for
various applications like home automation, weather monitoring, and environmental
monitoring.

The DHT11 sensor is a low-cost, digital temperature and humidity sensor .It is used to
measure the humidity and temperature of a room. Commonly used in various applications,
including home automation, weather monitoring, and environmental monitoring. It utilizes
two primary sensing elements: a capacitive humidity sensor and a thermistor.

Working Principle:

Humidity Measurement:

The capacitive humidity sensor consists of two electrodes separated by a moisture-sensitive


substrate. As the humidity level increases, the substrate absorbs more water molecules,
causing the dielectric constant of the material between the electrodes to change. This
change in dielectric constant alters the capacitance of the sensor, which is directly
proportional to the surrounding humidity.

Temperature Measurement:

The thermistor, a negative temperature coefficient (NTC) resistor, exhibits a decreasing


resistance with increasing temperature. By measuring the resistance of the thermistor, the
temperature can be determined using the Steinhart-Hart equation or a similar calibration
curve.

Data Communication:

The DHT11 sensor communicates with a microcontroller or data logger using a single digital
data pin. The sensor initiates the data transfer process by pulling the data pin low for a brief
period. Upon receiving the request, the microcontroller sends a high signal to acknowledge

10 | P a g e
the sensor. The sensor then responds by sending a series of 40 bits of data, consisting of an
integral humidity value, an integral temperature value, and a checksum byte for error
detection.

Key Characteristics of DHT11 Sensor:

• Low cost
• Digital output
• Easy to use
• Wide operating range (0-50°C, 20-80% RH)
• Moderate accuracy (+/-2°C for temperature, +/-5% RH for humidity)

Applications of DHT11 Sensor:

• Home automation (humidistats, thermostats)


• Weather monitoring systems (meteorological stations)
• Environmental monitoring (greenhouses, indoor air quality)
• Industrial applications (HVAC systems, data centers)

DHT11 working principle using Arduino

The DHT11 sensor can be easily interfaced with an Arduino microcontroller to measure
temperature and humidity. Here's a step-by-step guide:

• Connect the DHT11 sensor to the Arduino:


• Connect the DHT11 sensor's VCC pin to Arduino's 5V pin.
• Connect the DHT11 sensor's DATA pin to Arduino's digital pin 2 (e.g., pin 2
for Arduino Uno).
• Connect the DHT11 sensor's GND pin to Arduino's GND pin.

11 | P a g e
Figure 5 DHT11 Sensor Module And Sensing element

Figure 6 DHT11 connection Diagram

12 | P a g e
3.2.4: BH1750FVI LIGHT INTENSITY SENSOR
The BH1750FVI is a digital light sensor commonly used in Arduino projects to measure
ambient light intensity. It utilizes a photodiode to convert incident light into an analog
signal, which is then processed by an integrated circuit to produce a digital output. The
sensor communicates with the Arduino using the I2C protocol, allowing for easy data
transfer and integration into various applications.

Key Components of BH1750FVI:

 Photodiode: The photodiode is the primary light-sensing element, converting


incident light into an electrical current proportional to the light intensity.
 Analog-to-Digital Converter (ADC): The ADC converts the analog current from the
photodiode into a digital signal that can be processed by the microcontroller.
 Integrated Circuit (IC): The IC houses the ADC and other circuitry responsible for
processing the digital signal, converting it into a lux value, and managing the I2C
communication.

Working Principle:

1. Light Detection: When ambient light falls on the photodiode, it generates an


electrical current proportional to the light intensity.

2. Signal Processing: The analog current is converted into a digital signal by the ADC.

3. Lux Calculation: The IC processes the digital signal and converts it into a lux value, a
standardized unit of light intensity.

4. I2C Communication: The sensor communicates with the Arduino using the I2C
protocol, sending the lux value to the microcontroller for further processing.

13 | P a g e
Interfacing with Arduino:

To interface the BH1750FVI with an Arduino, follow these steps:

1. Hardware Connections: Connect the sensor's VCC pin to Arduino's 5V pin, the GND
pin to Arduino's GND pin, and the SDA pin to Arduino's SDA pin (usually pin A4) and SCL pin
to Arduino's SCL pin (usually pin A5).

2. Library Installation: Install the BH1750 library from the Arduino IDE library manager
or download and install it manually.

3. Arduino Code: Write the Arduino code to initialize the sensor, read lux values, and
perform any desired actions based.

Figure 7 BH1750 Sensor Module

14 | P a g e
Chapter 4: Control Logic and Operation

Figure 8 BH1750 Connection Diagram

Diagram 1 Logic for MQ135 Diagram 2 logic for GP2Y1010AU

15 | P a g e
Diagram 3 logic for DHT11 Diagram 4 logic for BHV1750

Diagram 5 Overall flowchart

Please refer appendix for


implementation of this logic in C++

16 | P a g e
Conclusion
In conclusion, the successful identification of key hardware components such as controllers
and sensors, coupled with the development of a well-crafted codebase, marks a significant
milestone in the advancement of our building automation project. This comprehensive
groundwork lays the foundation for a seamless integration of automation technologies to
enhance building functionality.

As we progress towards the hardware implementation phase, the project is poised to


transition from theory to tangible reality. The incorporation of Internet of Things (IoT)
further propels our initiative into the realm of smart and connected systems, enabling real-
time monitoring and control from remote locations. This not only amplifies the efficiency of
building operations but also contributes to sustainability by optimizing resource utilization.

The convergence of hardware and IoT reflects a holistic approach to modern building
management, where the amalgamation of cutting-edge technologies facilitates intelligent
decision-making and adaptive responses to environmental changes. Moving forward, the
project promises not only streamlined automation but also a glimpse into the future of
smart infrastructure, where interconnected devices collaborate harmoniously for the
betterment of occupants and the environment.

17 | P a g e
References

Fig-1: https://www.elprocus.com/mq135-air-quality-sensor/
Fig-2: https://projecthub.arduino.cc/m_karim02/arduino-and-mq-135-gas-sensor-with-
arduino-code-0385af
Fig-3: https://circuitdigest.com/microcontroller-projects/interfacing-dust-sensor-with-
arduino
Fig-4: https://circuitdigest.com/microcontroller-projects/interfacing-dust-sensor-with-
arduino
Fig-5: https://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-
arduino/
Fig-6: https://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-
arduino/
Fig-7: https://circuitdigest.com/microcontroller-projects/how-to-use-bh1750-ambient-light-
sensor-with-arduino
Fig-8: https://miliohm.com/bh1750-light-sensor-tutorial-diy-lux-meter-with-arduino-
esp8266/
Other references;
Diagrams: https://www.lucidchart.com/pages/examples/flowchart-maker
https://forum.arduino.cc/
https://circuitglobe.com/
https://www.teachmemicro.com/mq-135-air-quality-sensor-tutorial/

18 | P a g e
Appendix

MQ135 Arduino Code


#include <MQ135.h>
#include <LiquidCrystal.h>
int relay = 8; //relay connected to pin 8
const int aqsensor = A0; //output of mq135 connected to A0 pin of Arduino
int threshold = 250; //Threshold level for Air Quality
void setup()
{
pinMode (relay,OUTPUT); // relay is connected as Output from Arduino
pinMode (aqsensor,INPUT); // MQ135 is connected as INPUT to arduino
Serial.begin (9600); //begin serial communication with baud rate of 9600
}
void loop()
{
int ppm = analogRead(aqsensor); //read MQ135 analog outputs at A0 and store it
in ppm
Serial.print("Air Quality: "); //print message in serail monitor
Serial.println(ppm); //print value of ppm in serial monitor
if (ppm > threshold) // check is ppm is greater than threshold or not
{ Serial.println("AQ Level HIGH");
digitalWrite(relay,HIGH); //Turn ON relay
}
else{ digitalWrite(relay,LOW); //Turn off relay
Serial.println("AQ Level Good");
}
delay (50);
}

DUST SENSOR GP2Y1010AU0F Arduino code


#include <SPI.h>
int measurePin = A5;
int ledPower = 7;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
float threshold=0.34;
int relay = 8; //relay connected to pin 8
void setup(){

19 | P a g e
Serial.begin(9600);
}
void loop(){
digitalWrite(ledPower,LOW);
delayMicroseconds(280);
voMeasured = analogRead(measurePin);
calcVoltage = voMeasured*(5.0/1024);
dustDensity = 0.17*calcVoltage-0.1;
if ( dustDensity < 0)
{
dustDensity = 0.00;
}

if (DustDensity > threshold) // check is ppm is greater than threshold or not


{ Serial.println("AQ Level HIGH");
digitalWrite(relay,HIGH); //Turn ON relay
}
else
{
digitalWrite(relay,LOW); //Turn off relay
Serial.println("AQ Level Good");
}
delay(1000);
}
DHT11 Arduino Code

#include "dht.h"
#define dht_apin A0 ;// Analog Pin sensor is connected to
dht DHT;
double tset;
int relay = 8; //relay connected to pin 8
void setup(){
Serial.begin(9600);
delay(500);//Delay to let system boot
Serial.println("DHT11 Humidity & temperature Sensor\n\n");
delay(1000);//Wait before accessing Sensor
}
void loop(){
double temp=DHT.temperature;
DHT.read11(dht_apin);
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");

if (temp > tset) // check is ppm is greater than threshold or not


{ Serial.println("TEMPERATURE Level HIGH");
digitalWrite(relay,HIGH); //Turn ON relay

20 | P a g e
}
else
{ digitalWrite(relay,LOW); //Turn off relay
Serial.println("TEMPERATURE Level Good");
}
delay (500);
}
BH1750 Arduino Code
#include <BH1750FVI.h>
BH1750FVI LightSensor;
void setup()
{
Serial.begin(9600);
LightSensor.begin();
pinMode(8,OUTPUT);
}
void loop()
{ int k=512;
int s;
float lux = LightSensor.GetLightIntensity();
Serial.print("Light intensity: ");
Serial.print(lux);
Serial.print(" lux");
While(lux!=k)
{ if(k<lux)
{ s++;
}
else
{ s=s-1;
}
}

Serial.println();

Overall code
#include <MQ135.h>
#include <LiquidCrystal.h>
#include <BH1750FVI.h>
#include "dht.h"

#define GP2Y1010AU_ADDRESS 0x03


#define dht_apin A0

int relay = 8; // Relay connected to pin 8

const int aqsensor = A0; // Output of MQ135 connected to A0 pin of Arduino


int thresholdMQ135 = 250; // Threshold level for Air Quality

21 | P a g e
int measurePin = A5;
int ledPower = 7;
float thresholdDust = 0.34;

dht DHT;
double tset;

BH1750FVI LightSensor;

void setup() {
pinMode(relay, OUTPUT);
Serial.begin(9600);
LightSensor.begin();
}

void loop() {
readMQ135();
readDustSensor();
readDHT11();
readBH1750();
delay(500);
}

void readMQ135() {
int ppm = analogRead(aqsensor);
Serial.print("Air Quality: ");
Serial.println(ppm);
if (ppm > thresholdMQ135) {
Serial.println("AQ Level HIGH");
digitalWrite(relay, HIGH);
} else {
digitalWrite(relay, LOW);
Serial.println("AQ Level Good");
}
}

void readDustSensor() {
byte data[2];
Wire.beginTransmission(GP2Y1010AU_ADDRESS);
Wire.write(0x00);
Wire.endTransmission();
Wire.requestFrom(GP2Y1010AU_ADDRESS, 2, true);
while (Wire.available() < 2) {}
Wire.readBytes(data, 2);
int distance = data[0] << 8 | data[1];
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");

22 | P a g e
digitalWrite(ledPower, LOW);
delayMicroseconds(280);
float voMeasured = analogRead(measurePin);
float calcVoltage = voMeasured * (5.0 / 1024);
float dustDensity = 0.17 * calcVoltage - 0.1;
if (dustDensity < 0) {
dustDensity = 0.00;
}
Serial.println("Dust Density:");
Serial.println(dustDensity);
if (dustDensity > thresholdDust) {
Serial.println("AQ Level HIGH");
digitalWrite(relay, HIGH);
} else {
digitalWrite(relay, LOW);
Serial.println("AQ Level Good");
}
}

void readDHT11() {
double temp = DHT.temperature;
DHT.read11(dht_apin);
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");

if (temp > tset) {


Serial.println("TEMPERATURE Level HIGH");
digitalWrite(relay, HIGH);
} else {
digitalWrite(relay, LOW);
Serial.println("TEMPERATURE Level Good");
}
}

void readBH1750() {
int k = 512;
float lux = LightSensor.GetLightIntensity();
Serial.print("Light intensity: ");
Serial.print(lux);
Serial.print(" lux");
while (lux != k) {
if (k < lux) {
// Do something if lux is higher than the threshold
} else {
// Do something if lux is lower than the threshold
}

23 | P a g e
}
Serial.println();
}

24 | P a g e

You might also like