Chapter 2 Personal Weather Station

You might also like

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

6

CHAPTER 2
BACKGROUND THEORY OF PERSONAL WEATHER STATION

In this chapter, background theories of personal weather station and sensors


used in this system are described.

2.1. Processor Selection


There are two options to consider when selecting processor for the system. The
first option is to use microcomputers as the processor, and the second option is to use
microcontrollers. Therefore it is useful to know their differences.

2.1.1. Microcomputer
A microcomputer is a small, relatively inexpensive computer. In some cases, it
includes only a single printed circuit board containing a microprocessor, memory, and
input/output(I/O) circuitry. They may be called single board computers (SBCs).
Microcomputer are very useful for running multiple tasks simultaneously. And
moreover, general tasks can be performed similar to running programs in computers
and PCs. Their processing speed is very high [3].

2.1.2. Microcontrollers
A Microcontroller is a small and low-cost device, which is designed to perform
the specific tasks as in embedded systems. Examples of applications is the controller
for washing machines, microwave ovens, and air conditioners. They can be
programmed to perform these specific tasks, but once programmed, they will perform
the functions as in the program.

2.1.3 Comparison between Microcomputer and Microcontrollers


Raspberry Pi, one of the examples of microcomputer, have the processing speed
of up to 1.5 GHz for the latest generation, Raspberry Pi 4. Arduino family, a good
example of microcontrollers, has the processing speed of 16 MHz for all models.
7

When compared based on the price, the Arduino family are relatively cheaper
than the Raspberry Pi. As the proposed system consists of measuring the environmental
parameters, the choice of the processor may have an impact to interface with sensors.
Upon this issue, the Raspberry Pi have only GPIO pins which are digital only [4].
Arduino and NodeMCU, however, have both analog input pins and digital pins.
There may be doubt whether the microcontrollers can be used for building the desired
applications since the Arduino is relatively low in speed to Raspberry Pi. For running
specific tasks, the speed of NodeMCU is enough. Although the processing speed of the
Raspberry Pi is high, this high speed is shared by running multiple programs. Therefore,
the Raspberry Pi is not suitable for running specific tasks like microcomputers although
it can be programmed to perform such kinds of tasks. Based on these facts, the
NodeMCU will be used as the processor for the system. Therefore, what type of
NodeMCU should be used has to considered. Before this, it is very useful to study about
NodeMCU.

2.2. ESP8266 NodeMCU


ESP8266 NodeMCU is a low-cost open source IoT platform. It initially
included firmware which runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and
hardware which was based on the ESP-12 module. Later, support for the ESP32 32-bit
MCU was added. NodeMCU is an open source firmware for which open source
prototyping board designs are available. The name "NodeMCU" combines "node" and
"MCU" (micro-controller unit). The term "NodeMCU" strictly speaking refers to the
firmware rather than the associated development kits. Both the firmware and
prototyping board designs are open source. MCU stands for MicroController Unit -
which really means it is a computer on a single chip. A microcontroller contains one or
more CPUs (processor cores) along with memory and programmable input/output
peripherals. They are used to automate automobile engine control, implantable medical
devices, remote controls, office machines, appliances, power tools, toys etc.
The firmware uses the Lua scripting language. The firmware is based on the
eLua project, and built on the Espressif Non-OS SDK for ESP8266. It uses many open
source projects, such as lua-cjson and SPIFFS. Due to resource constraints, users need
to select the modules relevant for their project and build a firmware tailored to their
needs. Support for the 32-bit ESP32 has also been implemented.
8

The prototyping hardware typically used is a circuit board functioning as a dual


in-line package (DIP) which integrates a USB controller with a smaller surface-
mounted board containing the MCU and antenna. The choice of the DIP format allows
for easy prototyping on breadboards. The design was initially was based on the ESP-12
module of the ESP8266, which is a Wi-Fi SoC integrated with a Tensilica Xtensa
LX106 core, widely used in IoT applications.

Figure 2.1. Pin Description of ESP8266 NodeMCU [5]

The NodeMCU ESP8266 development board comes with the ESP-12E module
containing ESP8266 chip having Tensilica Xtensa 32-bit LX106 RISC microprocessor.
This microprocessor supports RTOS and operates at 80MHz to 160 MHz adjustable
clock frequency. NodeMCU has 128 KB RAM and 4MB of Flash memory to store data
and programs. Its high processing power with in-built Wi-Fi / Bluetooth and Deep Sleep
Operating features make it ideal for IoT projects. NodeMCU can be powered using
Micro USB jack and VIN pin (External Supply Pin). It supports UART, SPI, and I2C
interface. NodeMCU has 128 KB RAM and 4MB of Flash memory to store data and
programs. Its high processing power with in-built Wi-Fi / Bluetooth and Deep Sleep
9

Operating features make it ideal for IoT projects. NodeMCU can be powered using
Micro USB jack and VIN pin (External Supply Pin). It supports UART, SPI, and I2C
interface. Table 3.1 shows the pin description of ESP8266 NodeMCU [5].

Table 2.1. Pin Description of ESP8266 NodeMCU [5]

Pin Category Name Description

Micro-USB: NodeMCU can be powered through


Micro- the USB port
USB, 3.3V: Regulated 3.3V can be supplied to this pin to
Power
3.3V, power the board
GND, Vin GND: Ground pins
Vin: External Power Supply

Control Pins EN, RST The pin and the button resets the microcontroller

Used to measure analog voltage in the range of 0 -


Analog Pin A0
3.3V

GPIO1 to NodeMCU has 16 general purpose input-output pins


GPIO Pins
GPIO16 on its board
SD1,
NodeMCU has four pins available for SPI
SPI Pins CMD,
communication.
SD0, CLK
TXD0,
NodeMCU has two UART interfaces, UART0
RXD0,
UART Pins (RXD0 & TXD0) and UART1 (RXD1 & TXD1).
TXD2,
UART1 is used to upload the firmware/program.
RXD2
NodeMCU has I2C functionality support but due to
I2C Pins the internal functionality of these pins, users have to
find which pin is I2C.

2.3. Webserver
A web server, according to wikipedia, is server software, or hardware dedicated
to running this software, which can satisfy client requests on the World Wide Web. A
10

web server can, in general, contain one or more websites, which are made up of
webpages [6]. The primary function of a web server is to store the webpage, process
and deliver web pages upon requests. Pages are written in HTML (Hypertext Markup
Language) which is used to create the content of the page, such as written text, while
CSS (Cascade Styling Sheets) is used for the design or style of the website such as the
layout, visual effects and background color. Javascripts is also used to deliever the
dynamic behavior of the contents.
The communication between client and server takes place using the Hypertext
Transfer Protocol (HTTP). A user agent, commonly a web browser, initiates
communication by making a request for a specific resource using HTTP, and the server
responds the request with the content of that resource or an error message if unable to
do so.
“Many generic web servers also support server-side scripting using Active
Server Pages (ASP), PHP (Hypertext Preprocessor), or other scripting languages. This
means that the behaviour of the web server can be scripted in separate files, while the
actual server software remains unchanged. Usually, this function is used to generate
HTML documents dynamically ("on-the-fly") as opposed to returning static documents.
The former is primarily used for retrieving or modifying information from databases.
The latter is typically much faster and more easily cached but cannot deliver dynamic
content.”
Web servers can also be integrated in devices such as printers, routers, webcams
and serving only a local network. For routers, user can configure the device via the
webpage provided by the embedded server which can be reached by entering the IP
address of it. No additional software has to be installed on the client computer since
only a web browser is required. This eliminates the cross platform problems. That is
the reason why web applications is more popular than platform specific applications.
Since the purpose of the thesis to provide the data so that people on the local
area network can monitor, a small webserver is to be built to deliver the webpage
containing environmental data. Among different hardware options to serve as the web
server, ESP8266 WiFi Module is applicable. There is also community support on using
this device, including tutorials, examples, and libraries. Therefore, the features and
specifications of this module should be studied.

2.4. Sensors
Since the proposed system intends to measure some environmental parameters,
11

such as temperature, humidity and pressure sensors have to selected to get the desired
range and accuracy of environmental conditions.
Temperature should be known to avoid extreme heat problems. Humidity is
directly connected with how much the air is moist. Moist air mostly contains negative
ions. Research says a higher level of negative ions does good to well-being of humans.
Therefore, beside temperature, humidity is also to be measured. Atmospheric pressure
should be known to avoid noise bleeding problems.

2.5. Temperature and Humidity Sensor


For measuring temperature and humidity, the DHT sensors are to be used. These
sensors are made of two parts, a capacitive humidity sensor and a thermistor. There is
also a very basic chip inside which converts the measured analog data into digital output
and produces a digital signal with both the temperature and humidity. The digital signal
containing both temperature and humidity can be read by a microcontroller with the
help of libraries. There are two types of DHT sensor. These sensors are good choice
because they are very cheap but still providing great performance. They are DHT 11,
and DHT 22 [7].
These devices consist of a humidity sensing component, an NTC temperature
sensor and an IC. The humidity sensing component has two electrodes with moisture
holding substrate between them. So as the humidity changes, the conductivity of the
substrate changes or the resistance between the two electrodes changes. This change in
resistance is measured and processed by the IC.
For measuring temperature, these are NTC temperature sensor or a thermistor.
A thermistor is a variable resistor which changes its resistance according to the change
in temperature. These sensors are made with semi conductive materials such as
ceramics or polymers in order to provide larger changes in the resistance with just small
changes in temperature. The term “NTC” means “Negative Temperature Coefficient”,
which means that the resistance decreases with increase of the temperature [7].
Since there are two options, design must be considered which option suits the
desired results. In order to do so, comparison is to be made between these two sensors
based on their accuracy, measuring range, and sensitivity. The only difference between
the sensor and module is that the module will have a filtering capacitor and pull-up
resistor inbuilt, and for the sensor, have to use them externally if required. The brief
comparison between DHT 11 and DHT22 is given as in the Table 2.2.
12

Table 2.2. Comparison between DHT 11 and DHT22 [8]

Parameters DHT22 DHT11

Power
3.3-6V 3.5V to 5.5V
Supply

Output
Digital signal via single-bus Digital signal via single-bus
Signal

Sensing
Polymer capacity Polymer capacity
element

Operating Humidity-100%RH, Humidity-20~90%RH,


range temperature-40~80°C temperature-0~50°C

Humidity±2%RH(Max±5%R Humidity±1%RH(Max±5%RH);
Accuracy
H); temperature < ±0.5°C temperature < ±1°C

Resolution No more than 0.5 Hz


No more than 1 Hz sampling
or sampling rate (once every
rate (once every second)
Sensitivity second)

From the table, it is found that DHT22 offers better performance than DHT11.
However, its price is two times more than DHT11. Since the desired application is not
mission-critical application, the lower option, DHT11 is enough. The DHT11 is given
as shown in the Figure 2.2.

Figure 2.2. DHT11 [8]

From upper to lower, the first pin is VCC pin to which 5V supply must be given,
the second is data pin, the third pin has no connection, and the lowest being ground pin.
13

2.6. Atmospheric Pressure Sensor


For measuring the atmospheric pressure, the BMP180 is used. It is functionally
compatible with older BMP-085 digital pressure sensor. But the BMP180 provides less
power consumption, is smaller in size and more accurate. BMP180 combines
barometric pressure, temperature and altitude. The I2C allows easy interface with any
microcontroller. Even the microcontrollers which have no analog input pin can be
interfaced with it.
Since the BMP180 is an ultra-low power devices, it is optimized for use in
mobile phones, PDAs, GPS navigation devices and outdoor equipment. “With a low
altitude noise of merely 0.25m at fast conversion time, the BMP180 offers superior
performance. The I2C interface allows for easy system integration with a
microcontroller. The BMP180 is based on piezo-resistive technology for EMC
robustness, high accuracy and linearity as well as long term stability.” [9] The BMP
180 sensor is shown in Figure 2.3.

Figure 2.3. BMP180 Pressure Sensor [9]

Specifications of BMP 180 pressure sensor are that supply voltage is 1.8V to
3.6V, it has low power consumption with 0.5uA at 1Hz, it has I2C interface, max I2C
Speed is 3.5Mhz, it has very low noise with up to 0.02hPa (17cm), it is full calibrated,
its pressure range is 300hPa to 1100hPa (+9000m to -500m). The theoretical noise level
at the BMP180s highest resolution is 0.25m (about 10 inches). The accuracy can be
improved by taking a large number of readings and averaging them, although this will
slow down the sample rate and response time.

2.7. LCD Modules


In order to display environmental sensors, LCD (Liquid Crystal Display) is
used. Among different kinds of LCD modules, 16×2 LCD is used which has 16
Columns and 2 Rows. Therefore, it will have 32 characters in total and each character
will be made of pixels. The 16x2 LCD module is shown in the following Figure 2.4.
14

Figure 2.4. The 16x2 LCD module [10]

There is an interface IC, HD44780 whose function is to get the commands and
data from the MCU and process them to display information onto the LCD Screen. The
operating voltage of the module is 4.7V to 5.3V. Hence, the data pins can be connected
directly to Arduino. Current consumption without blacklight is 1mA [10].
Since it is an alphanumeric LCD display module, it can display alphabets and
numbers. It can work on both 8-bit and 4-bit mode. It can also display any custom
generated characters by writing own libraries. These modules are available in green and
blue backlight. The pinout of the module is shown in Figure 2.5.

Figure 2.5. The 16x2 LCD module Pinout [11]

The collected and processed data may need to be displayed. A LCD is a thin,
flat display device made up of any number of color or monochrome pixels arrayed in
front of a light source or reflector. It is often utilized in battery-powered electronic
devices because it uses very small amounts of electric power. The pin description of the
16x2 LCD module is shown in Table 2.3 to serve as the reference when interfacing with
microcontrollers.
15

Table 2.3. The pin description of the 16x2 LCD module [11]

Pin No Pin Name Description

1 Vss Ground pin connected to system ground

2 Vdd +5V pin

3 VE Decides the contrast level of display

4 Register To shift between command/data register


Select

5 Read/Write Used to read or write data. Normally grounded to write


data to LCD

6 Enable Toggled between 1 and 0 for data acknowledgement

7 to 14 Data Pin 0 Data pins 0 to 7 forms an 8-bit data line. They can be
to 7 connected to Microcontroller to send 8-bit data. When
operating in 4-bit mode, Data pin 4, 5, 6 and 7 will be
left free.

15 LED Backlight LED pin positive terminal


Positive

16 LED Backlight LED pin negative terminal


Negative

2.8. LCD Driver Module


In order to reduce the number of pins required to interface with microcontroller,
I2C Arduino LCD driver module is used as the driver. Since I2C requires only two pins,
the pin number requirement reduces down to two pins instead of seven data pins. The
driver module in connection with 16x2 LCD module is shown as in Figure 2.6.
16

Figure 2.6. 16x2 LCD module Pinout [11]

If the driver module is not used, a little circuit has to be added to adjust the light
intensity. The driver module eliminates this requirement, and has a potentiometer for
adjustment of the contrast of the display for best viewing. For easy programming with
Arduino, there is also “LiquidCrystal_I2C.h” library. The I2C address of the module is
either 0x3F (63 decimal) or 0x27 (39 decimal) but can be changed if needed. There are
3 address jumper locations marked A0, A1, A2 for this purpose [11].
The module connection to the display is via a 4-pin header. These connections
are listed as below.
▪ GND – Connect to system ground.
▪ VCC – Connect to 5V.
▪ SDA – Connect to the I2C / SDA pin on the microcontroller.
▪ SCL – Connect to the I2C / SCL pin on the microcontroller.
A red LED on the I2C interface board lights when power is applied.

2.9. Cooling Fan


Since the system measures and monitors environmental conditions, the system
can be used in integration with automation systems. For example, upon reaching high
temperature conditions, the system can also be programmed to activate some actions.
In this thesis, it will be illustrated with the use of cooling fan as the prototype. The 5V
cooling fan, used in cooling mobile devices, is used for this purpose. An example of
such a fan is shown in Figure 2.7.
17

Figure 2.7. Brushless DC fan [12]

The specifications of brushless DC fan are given as follows.


▪ Operating voltage: 5V
▪ Current: 0.2 A
▪ Brushless DC fan
▪ Fan dimensions: 30mm x 30mm x 8mm
▪ Fan weight: 6.2g / 0.22oz [12].

2.10. Driver for Cooling Fan


Since the output of the microcontroller is only 20mA, it cannot be connected
directly to fan which draws at about 200mA. For this reason, the driver is needed to
serve as an interface between fan and microcontroller. The simplest method is to build
a driver circuit with transistor [13]. An NPN transistor, 2N2222, which is commonly
available in this country, is used for this purpose, and is shown in the Figure 2.8.

Figure 2.8. 2N2222 NPN transistor [13]

2.11. Buzzer
A buzzer is a device which makes a buzzing or beeping noise. It is also a small
yet efficient component to add sound features to the system. It is compact two-pin
structure hence can be easily used on breadboard, Perf Board and even on PCBs which
makes this a widely used component in most electronic applications.
There are two types of buzzers that are commonly available. The one is a simple
buzzer which when powered will make a continuous beep sound. The other type is a
18

readymade buzzer which looks bulkier than this and will produce a beep sound due to
the internal oscillating circuit present inside it [14].

Figure 2.9. Buzzer [14]

The buzzer can be used by simply powering using a DC power supply ranging
4V to 9V. A simple 9V battery can also be used, but it is recommended to use a
regulated 5V or 6V. The sound is created by inducing rapid movements in the
diaphragm of the buzzer. In electronic buzzers these variations are made by an oscillator
circuit which drives a piezo to produce the sound. In electromechanical buzzers these
oscillations are self-made through a rapid switching of an electromagnet.

2.12. Relay
A relay operates as an electromagnetic switch. It can control a high voltage
circuit by using only a low voltage control signal. The building components of an
electromechanical relay are a fixed coil, a movable armature, a spring and contacts. The
coil generates a magnetic field when a low voltage control signal has been sent. The
armature is attracted by the magnetic field so that it pushes the contact pair towards
each other [15].
This completes the high voltage circuit. The spring is attached between the coil
and the armature. When the control signal is no longer sent to the circuit, the spring
pulls the armature back to its original position. The 5V relay shield consists of four
relays, which can be used to switch devices up to 250V AC with up to 10A of current
using 5V input signals from the microcontroller.

Figure 2.10. Relay [15]


19

2.13. Summary
This chapter describes theoretical background of each one is also described.
Specifications and pinout diagram as well as pin descriptions are also presented to serve
as the reference for interfacing with each other. The next chapter describes the
implementation steps of building the system.

You might also like