Ajay D - (MC & MP ASSIGN)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

18ETEC004008_AJAY.

D
MINI WEATHER STATION:

INTRODUCTION:

Capturing physical data in real-3me is always fascina3ng. Arduino board mini weather
sta3on is a mini weather sta3on which is able to give live updates. In this project, we will
find three fundamental physical parameters for weather predica3on temperature, humidity
and atmospheric pressure and also display the real-3me data on a LCD screen. In the first
part an array of libraries has been included to keep the programming short and simple. The
Wire.h and SPI.h libraries are used because Wire.h is the one that allows the Arduino to
communicate with the I2C/TWI devices such as the BMP-280 and the ST7735 LCD and SPI.h
provides the serial peripheral interface with the ST7735 LCD. In the second part, the
sensors are ini3alized and the layout, font colour, etc. of the LCD are set up for displaying
the data as per our preferences. In the final part, the output from the sensors are obtained
and displayed with a convenient delay between each reading to keep things stable.
The weather sta3on collects the following data related to the weather and environment
using different sensors:
• Temperature
• Humidity
• Atmospheric pressure
• Light intensity
• UV index
• Dust concentra3on

Descrip7on and Working Principle


The two sensors used in this project are BMP-280 and DHT-11. The former senses the
temperature and atmospheric pressure whereas the later senses the rela3ve humidity. The
DHT-11 could have been done with by using BME-280 (it can measure humidity also)
instead of the BMP-280, but if the cost is taken into account then using the combina3on of
sensors used here is much more economical for DIY projects. It should also be no3ced that
although DHT-11 is capable of sensing both temperature and humidity, it is used for
humidity sensing only because its temperature sensing resolu3on is +/-2° compared to
+/-.5° for BMP-280. The heart of this project is the Arduino NANO development board.
Here also the NANO board has been chosen over the mass-preferred UNO because of its
affordable price. A 1.44” ST7735 series TFT LCD-screen is used as the display for our
project. A bigger screen has been avoided-here so that the Arduino NANO is not
overloaded.
Circuit and Programming
A combina3on of circuit diagram and block diagram has been provided as conveniently as
possible to help the makers understand the physical configura3on and connec3on of the
components. Tables for pin-out of the components is also provided to make things easier.
Going through the diagram and tables one will no3ce that the 5V and GND pins of the ICSP
header on Arduino NANO has been u3lised for supplying power to the components along
with the on-board power and ground pins. This has been done to do away with any
addi3onal power source which will make the system bulky.
1 of 7
18ETEC004008_AJAY.D

Coming to the programming, in the first part an array of libraries have been included to
keep the programming short and simple. Besides the obvious ones, the Wire.h and SPI.h
libraries are worth men3oning because Wire.h is the one that allows the Arduino to
communicate with the I2C/TWI devices such as the BMP-280 and the ST7735 LCD and SPI.h
provides the serial peripheral interface with the ST7735 LCD. In the second part, the
sensors are ini3alized and the layout, font colour, etc. of the LCD are set up for displaying
the data as per our preferences. In the final part of our programming, the output from the
sensors are obtained and displayed with a convenient delay between each reading to keep
things stable.

SoCware requirements:

Arduino IDE:
The Arduino Integrated Development Environment is a cross- pladorm applica3on that is
wrieen in func3ons from C and C++. It is used to write and upload programs to Arduino
compa3ble boards, but also, with the help of 3rd party cores, other vendor development
boards.

Construc7on and Tes7ng

In the prototype, the components have been kept modular and connected using jumper
wires instead of soldering. This not only allows easy troubleshoo3ng and repairing but also
makes the assembly process hassle free. The device-case has been custom 3D-printed for a
perfect fit for the components. The case is provided with proper ven3la3on in order to
expose the sensors to the measurands and dissipate the heat generated by the system
which will otherwise interfere with the sensing elements. The device is powered via the
same type AUSB to type B mini USB used to program the Arduino. The prototype has been-
tested indoors at stretch for a few hours using both PC USB port and 5Vsmartphone
charger as supply. The results are quite accurate compared with online meteorological
data, considering the produc3on cost and development 3me.

Importance of mini weather sta7on :

- Real-Time Data
One of the biggest reasons why people have been going in for weather sta3ons is because
of the ability to get their informa3on in real 3me. In the past, the weather predic3ons were
reliant on the weather reports on the news or reports from the meteorological
departments. With weather sta3ons, users don’t have to depend on these external sources
and can get their own accurate informa3on on the weather much faster than they would
through other means.
- Real-Time Alerts
Weather condi3ons can change at any point and take a turn for the worse, especially in
areas that are prone to storms and hurricanes. Having a home weather sta3on in these
instances can help you, and your family members stay safe the moment the weather

2 of 7
18ETEC004008_AJAY.D
changes are detected. These real-3me alerts can help you, and your family members be
informed about the weather, helping everyone stay safer.
- Ease Of Use
Weather sta3ons are designed to be efficient and straighdorward. These devices are meant
to be able to provide the most accurate informa3on in the simplest way possible. If you
want a device that is simple to read, and which doesn’t overburden you with informa3on, a
wireless weather sta3on is definitely one that you should choose. If you are on the lookout
for a simple and efficient weather sta3on for your home, the ThermoPro TP-67 weather
sta3on is one product to go in for. The ease of use, as well as the fast installa3on, make this
the perfect weather sta3on to choose for your home.
- Accurate Readings
Ojen, the metrological department may be located far from your home. In these instances,
the weather predic3ons that they give are not always the most accurate. The weather in
that area might not be the same as the place that you are living in, which is why weather
sta3ons are so useful. These devices can tell you the exact temperate in the area that you
are living in and give you specific readings that are centered around your home.

BLOCK DIAGRAM:

- DHT-11 Temp Sensor:


The DHT11 is a low-cost digital temperature and humidity sensor with a single wire digital
interface. It uses a capaci3ve humidity sensor and a thermistor to measure the surrounding
air and spits out a digital signal on the data pin (no analog input pins needed). The sensor is
calibrated and doesn’t require extra components so you can get the right to measuring
rela3ve humidity and temperature. It is quite simple to use but requires careful 3ming to
grab data. You can only get new data from it once every 2 seconds.

3 of 7
18ETEC004008_AJAY.D
- BMP-280 barometric sensor:
It is an absolute barometric pressure sensor, which is especially feasible for mobile
applica3ons. Its small dimensions and its low power consump3on allow for the
implementa3on in baeery-powered devices.

- 1.44” ST7735 series TFT LCD screen:

It is used for the display of our output.

CODE:

#include <SPI.h> //include Serial Peripheral Interface library


#include <Wire.h> //include Two Wire Interface library
#include <Adafruit_GFX.h> // include Adafruit graphics library
#include <Adafruit_ST7735.h> // include Adafruit ST7735 TFT library
#include <Adafruit_BMP280.h> // include Adafruit BMP280 sensor library
#include "DHT.h" //include DHTXX sensor library
#define DHTPIN 2 //DHT11 data pin connected to arduino pin D2
#define DHTTYPE DHT11 //specifying the type of DHT sensor used
#define TFT_RST 8 // TFT RST pin is connected to arduino pin D8
#define TFT_CS 10 // TFT CS pin is connected to arduino pin D9
#define TFT_DC 9 // TFT DC pin is connected to arduino pin D10
// ini3alize ST7735 SERIES TFT library
Adafruit_ST7735 dt = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

// define device I2C address: 0x76 or 0x77 (0x77 is the library default address)
#define BMP280_I2C_ADDRESS 0x76

Adafruit_BMP280 bmp280; // ini3alize Adafruit BMP280 library


DHT dht(DHTPIN, DHTTYPE); // ini3alize DHT sensor

void setup(void)
{
dht.begin(); // synchronizing DHT sensor
dt.initR(INITR_144GREENTAB); // ini3alize a ST7735S chip, black tab
dt.fillScreen(ST77XX_BLACK); // sewng black background
dt.drawFastHLine(0, 15 , dt.width(), ST77XX_CYAN);// draw horizontal separa3on line at posi3on (0, 15)

dt.setTextColor(ST77XX_CYAN, ST77XX_BLACK); // set text colour to white and black background


dt.setTextSize(1); // sewng text size to 1
//dt.setCursor(4, 0); // move cursor to posi3on (4, 0) pixel
//dt.print("ARDUINO + ST7735 TFT");
dt.setCursor(25, 5); // move cursor to posi3on (25, 5) pixel
dt.print("WEATHER BUDDY");

// ini3alize the BMP280 sensor


if( bmp280.begin(BMP280_I2C_ADDRESS) == 0 )
{ // connec3on error or device address wrong!
dt.setTextColor(ST77XX_RED, ST77XX_CYAN); // set text color to red and black background
dt.setTextSize(2); // sewng text size to 2

4 of 7
18ETEC004008_AJAY.D
dt.setCursor(5, 76); // move cursor to posi3on (5, 76) pixel
dt.print("Connec3on");
dt.setCursor(35, 100); // move cursor to posi3on (35, 100) pixel
dt.print("Error");
while(1); // stay here
}

dt.drawFastHLine(0, 55, dt.width(), ST77XX_CYAN); // draw horizontal sepera3on line at posi3on (0, 55)pixel
dt.drawFastHLine(0, 95, dt.width(), ST77XX_CYAN); // draw horizontal sepera3on line at posi3on (0, 195)pixel
dt.setTextColor(ST77XX_RED, ST77XX_BLACK); // set text color to red and black background
dt.setCursor(30, 20); // move cursor to posi3on (30, 20) pixel
dt.print("TEMPERATURE "); // sewng heading for first sec3on
dt.setTextColor(ST77XX_CYAN, ST77XX_BLACK); // set text color to cyan and black background
dt.setCursor(40, 60); // move cursor to posi3on (40, 60) pixel
dt.print("HUMIDITY "); // sewng heading for second sec3on
dt.setTextColor(ST77XX_GREEN, ST7735_BLACK); // set text color to green and black background
dt.setCursor(40, 100); // move cursor to posi3on (40, 100) pixel
dt.print("PRESSURE "); // sewng heading for third sec3on
dt.setTextSize(2); // sewng text size to 2
}

// main loop
void loop()
{

char _buffer[8];
// read temperature, humidity and pressure from the BMP280 sensor
float temp = bmp280.readTemperature(); // get temperature in °C
float hum = dht.readHumidity(); // get humidity in rH%
float pres = bmp280.readPressure(); // get pressure in hPa

// print temperature (in °C)


if(temp < 0) // if temperature < 0
sprind( _buffer, "-%02u.%02u", (int)abs(temp), (int)(abs(temp) * 100) % 100 );
else // if temperature >= 0
sprind( _buffer, " %02u.%02u", (int)temp, (int)(temp * 100) % 100 );// sewng the value approxima3on
dt.setTextColor(ST77XX_YELLOW, ST77XX_BLACK); // set text color to yellow and black background
dt.setCursor(11, 34); // move cursor to posi3on (11,34) pixel
dt.print(_buffer); // print temperature from BMP-280 sensor
dt.drawCircle(89, 34, 2, ST77XX_YELLOW); // print the degree symbol ( ° )(can be omieed if * is used instead)
dt.setCursor(95, 34); // move cursor to posi3on (95,34) pixel
dt.print("C"); // print the Celcius symbol

// 2: print humidity (in %)


sprind( _buffer, "%02u ", (int)(hum)); // sewng the value approxima3on
dt.setTextColor(ST77XX_MAGENTA, ST77XX_BLACK); // set text color to magenta and black background
dt.setCursor(45, 74); // move cursor to posi3on (45,74) pixel
dt.print(_buffer); // print humidity from DHT-11 sensor
dt.setCursor(75, 74); // move cursor to posi3on (75,74) pixel
dt.print("%"); // print the percentage symbol

// 3: print pressure (in hPa)


sprind( _buffer, "%04u.%02u", (int)(pres/100), (int)((uint32_t)pres % 100) ); // sewng the value approxima3on
dt.setTextColor(ST77XX_ORANGE, ST77XX_BLACK); // set text color to orange and black background
dt.setCursor(3, 112); // move cursor to posi3on (3,112)pixel
5 of 7
18ETEC004008_AJAY.D
dt.print(_buffer); // print atmospheric pressure from BMP-280
dt.setCursor(91, 112); // move cursor to posi3on (91,112)pixel
dt.print("hPa"); // print unit of atmospheric pressure as hecto pascal

delay(1000); // wait 1 second before taking next sensor reading

Conclusion

In conclusion it can be said that this project is quite economical, useful to say the least, and
most importantly, it is fun having a small and handy weather sta3on that fits right in your
pocket.

COURSERA CERTIFICATES :

(i). The Arduino Pla`orm and C Programming :

LINK:
heps://www.coursera.org/account/accomplishments/records/446C4JD6RQMN?
utm_source=link&utm_medium=cer3ficate&utm_content=cert_image&utm_campaign=sh
aring_cta&utm_product=course

6 of 7
18ETEC004008_AJAY.D

(ii). Interfacing with the Arduino:

LINK:
heps://www.coursera.org/account/accomplishments/records/6E3LYL8YSTQY?
utm_source=link&utm_medium=cer3ficate&utm_content=cert_image&utm_campaign=sh
aring_cta&utm_product=course

7 of 7

You might also like