100% found this document useful (1 vote)
95 views16 pages

ch3 Software New

This document describes the software implementation of an environmental measuring and monitoring system using Arduino. It explains the overall pin connections of the sensors and components to the Arduino board. It then provides a flowchart showing the process of reading sensor data, displaying it on an LCD and uploading it to a web server via WiFi. It also discusses the software used, including the Arduino IDE, C programming language, and Fritzing for circuit design.

Uploaded by

yma warrior
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
95 views16 pages

ch3 Software New

This document describes the software implementation of an environmental measuring and monitoring system using Arduino. It explains the overall pin connections of the sensors and components to the Arduino board. It then provides a flowchart showing the process of reading sensor data, displaying it on an LCD and uploading it to a web server via WiFi. It also discusses the software used, including the Arduino IDE, C programming language, and Fritzing for circuit design.

Uploaded by

yma warrior
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

25

CHAPTER 3
SOFTWARE IMPLEMENTATION OF THE SYSTEM

In this chapter describes software implementation of environmental measuring


and monitoring system. Software implementation Arduino, implementation of web
sever using wi-fi module, flowchart and sensor function are expressed.

3.1. Overall Pin Diagram of the System


Overall pin diagram of the system is shown in Figure 3.1. Pin connections of
the system are as follows:
The output pin of DHT22 sensors are connected Arduino Mega pin 2. Supply
and ground pins of these component are directly connected to the Arduino Mega
ground pin and supply pin. Transmit pin (Tx) and receive pin (Rx) of the ESP8266
wi-fi module are connected to receive pin (Rx) and transmit pin (Tx) of the Arduino
Mega.

12 V adapter output

Figure 3.1. Overall pin Diagram of the System


26

Vcc, Reset, CH-EN and ground pin of these components are connected to the
3.3 V and ground pin of the Arduino Mega. LCD module requires 7data pin. So, LCD
driver is used. LCD driver only needs two pins to work. SCL and SDA of the LCD
driver are connected to A20 and A21 of the Arduino Mega. Supply and ground pins of
these components are connected to 5 V and ground pins of the Arduino Mega.
SCL and SDA of the BMP180 sensor are connected to A20 and A21 of the
Arduino Mega. Supply and ground pins of these components are connected to 3.3 V
and ground pins of the Arduino Mega. LEDs are connected to the Arduino Mega pin
no 3,4,5,6,7. Relay is connected with pin (8) of Arduino mega. Fan supply is
connected relay on and ground pin is connected to ground pin of the Arduino Mega.
Aout of the CO sensor is connected to A2 of the Arduino Mega. Supply and ground of
these components are connected to 5 V and ground pin of the Arduino Mega. Aout of
the UV sensor is connected to A0 of the Arduino Mega. 3.3 V, EN and ground of
these components are connected to 3.3 V and ground pin of the Arduino Mega. 12
VAC adapter is used for power supply. LM2596 DC to DC converter is used for 5V
power supply to operate the whole system.

3.2. Operation of the Environmental Measuring and Monitoring via Web System
The Arduino Mega reads the data from temperature and humidity sensor,
atmospheric pressure sensor, carbon monoxide sensor and ultra violet intensity sensor.
All these sensor data are displayed on LCD display and LEDs are also used to signal
the extreme conditions. And then, Arduino Mega tries to connect with the webserver.
The web page can be accessed by joining ESP8266 and entering http//192.168.4.1 in
browser. If connection is made, it will be sent sensor data to the server. These sensor
data can be viewed from any devices containing browser by connecting the IP address
of the server. If the controller does not get connection with the server, these data can
still be viewed on LCD display. The temperature exceeds the predetermined value the
cooling fan will turn on.

3.3. Flowchart of Environmental Measuring and Monitoring Via Web System


This flowchart is drawn for general operations of all sensors and their actions.
Steps include reading values, making comparison, and taking actions, displaying in
LCD and displaying in web page. The procedures steps and program flowchart of
environmental measuring and monitoring via web system are described in Figure 3.2.
27

Start

Read Sensors Data

Exceed With
predetermined values
No
Tem > 30 degC, Hum < 65%,
Pre < 1012mb, CO > 100ppm, UV >
1mW/cm^2
?

Yes

Turn On Corresponding LED or Fan

Display On Local LCD Display

Try To Connect With Web Server, IP address


192.168.4.1

Connected No
?

Yes

Upload Data To Server

End

Figure 3.2. Flowchart of Environmental Measuring and Monitoring via Web System

3.4. Software Requirements of Environmental measuring and monitoring via


Web
In this system, Arduino IDE software, C programming and Fritzing software
are used to designed and upload the program. Firstly, circuit design is illustrated with
Fritzing software. When this outcome result is certainly completely, C programming
28

language is studied for programming. And then, Arduino IDE is used to program the
Arduino Uno and all of the hardware components. Details of Arduino IDE, C
programming and circuit design software are mentioned below.

3.4.1. Fritzing Software


Fritzing is an open-source hardware initiative that makes electronics
accessible as a creative material for anyone. Fritzing offer a software tool, a
community website and services in the spirit of Processing and Arduino, fostering a
creative ecosystem that allows users to document their prototypes, share them with
others, teach electronics in a classroom, and layout and manufacture professional
PCBs. The software is created in the spirit of the processing programming language
and the Arduino microcontroller and allows a designer, artist, researcher, or hobbyist
to document their Arduino-based prototype and create a PCB layout for
manufacturing. The associated website helps users share and discuss drafts and
experiences as well as to reduce manufacturing costs. Fritzing empowers the Internet
of Things through an ecosystem of easy-to-use tools and services for creative people.
The open-source Fritzing software turns even non-engineers into producers of
interactive electronics. Fritzing has made a code view option, where one can modify
code and upload it directly to an Arduino device. Component images are distributed
under CC-BY-SA, which will also be the license for any generated breadboard views.
In this system, this software is used to design the overall system.

Figure 3.3. Using Fritzing Software


29

3.4.2. C Programming Language


C programming is a general-purpose, procedural computer programming
language supporting structured programming, lexical variable scope, and recursion,
with a static type system. C programming provides constructs that map efficiently to
typical machine instructions. It has found lasting use in applications previously coded
in assembly language. Such applications include operating systems and various
applications software for computer architectures that range from supercomputers to
PLCs and embedded systems. A successor to the programming language B, C was
originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 to
construct utilities running on Unix. It was applied to re-implementing the kernel of the
Unix operating system. During the 1980s, C gradually gained popularity. It has
become one of the most widely used programming languages, with C compilers from
various vendors available for the majority of existing computer architectures and
operating systems. C has been standardized by the ANSI since 1989 (ANSI C) and by
the International Organization for Standardization (ISO).

Figure 3.4. C Programming Language

C is an imperative procedural language. It was designed to be compiled to


provide low-level access to memory and language constructs that map efficiently to
machine instructions, all with minimal runtime support. Despite its low-level
capabilities, the language was designed to encourage cross-platform programming. A
standards-compliant C program written with portability in mind can be compiled for a
30

wide variety of computer platforms and operating systems with few changes to its
source code. The main features of C language include low-level access to memory,
a simple set of keywords, and clean style, these features make C language suitable for
system programming like an operating system or compiler development. Many later
languages have borrowed syntax/features directly or indirectly from C language. Like
syntax of Java, PHP, JavaScript, and many other languages are mainly based on C
language. C++ is nearly a superset of C language (There are few programs that may
compile in C, but not in C++).

3.5. Software Implementation of Arduino


This system can be developed using Arduino IDE and C programming.
Arduino is an open-source platform used for building electronics projects. Arduino
consists of both a physical programmable circuit board (often referred to as a
microcontroller) and a piece of software, or IDE (Integrated Development
Environment) that runs on your computer, used to write and upload computer code to
the physical board. The Arduino platform has become quite popular with people just
starting out with electronics, and for good reason. Unlike most previous
programmable circuit boards, the Arduino does not need a separate piece of hardware
(called a programmer) in order to load new code onto the board you can simply use a
USB cable. Additionally, the Arduino IDE uses a simplified version of C++, making
it easier to learn to program.
Finally, Arduino provides a standard form factor that breaks out the functions
of the microcontroller into a more accessible package. Arduino is a single-board
microcontroller meant to make the application more accessible which are interactive
objects and its surroundings. The hardware features with an open-source hardware
board designed around an 8-bit Atmel AVR microcontroller or a 32-bit Atmel ARM.
Current models consists a USB interface, six analog input pins and 14 digital I/O pins
that allows the user to attach various extension boards.

3.5.1. Arduino Development IDE


The Arduino integrated development environment (IDE) is a cross-platform
application written in Java, and is derived from the IDE for the processing
programming language and the wiring projects. It is designed to introduce
programming to artists and other newcomers unfamiliar with software development. It
31

includes a code editor with features such as syntax highlighting, brace matching, and
automatic indentation, and is also capable of compiling and uploading programs to the
board with a single click. There is typically no need to edit make files or run programs
on a command-line interface. Interface Arduino Uno program is as shown in Figure
3.5.

Figure 3.5. Interface Arduino Uno Program

Arduino programs are written in C or C++. The Arduino IDE comes with a
software library called “Wiring” from the original Writing project, which makes many
common input/output. Operations can be much easier. Users only need define two
functions. To make a runnable cyclic executive program:
1. Setup ( ): a function run once at the start of a program that can initialize
settings.
2. Loop ( ): a function called repeatedly until the board powers off.
The control software program is written in ‘Embedded C’. The program has
the capability of sending and receiving the SMS from and to the user mobile via GSM
modem to tell that unauthorized entry/smoke has detected in case of security system
and to control some devices in case of automation system respectively. The program
also provides the display of current status of the system.
32

3.5.2. Install the Board Drivers


If the Installer used, Windows - from XP up to 10 - will install drivers
automatically as soon as connect to board. If user downloaded and expanded the Zip
package or, for some reason, the board wasn't properly recognized, please follow the
procedure below.
1. Click on the start menu, and open up the control panel.
2. While in the control panel, navigate to system and security. Next, click on
system.
3. Once the system window is up, open the device manager.
4. Look under ports (COM & LPT). See an open port named "Arduino UNO
(COMxx)". If there is no COM & LPT section, look under "Other Devices"
for "Unknown Device".
5. Right click on the "Arduino UNO (COmxx)" port and choose the "Update
Driver Software" option.
6. Next, choose the "Browse my computer for Driver software" option.
7. Finally, navigate to and select the driver file named "arduino.inf", located in
the "Drivers" folder of the Arduino Software download (not the "FTDI USB
Drivers" sub-directory). If you are using an old version of the IDE (1.0.3 or
older), choose the Uno driver file named "Arduino UNO.inf"
8. Windows will finish up the driver installation from there.
Open the LED blink example sketch: File > Examples >01.Basics > Blink.

Figure 3.6. Example of LED Blink


33

3.5.3. Select Board Type and Port


Need to select the entry in the Tools > Board menu that corresponds to the
Arduino board.

Figure 3.7. Selecting Board Type

Select the serial device of the board from the tools | Serial Port menu. This is
likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware
serial ports). To find out, disconnect this board and re-open the menu; the entry that
disappears should be the Arduino board. Reconnect the board and select that serial
port.

Figure 3.8. Selecting Port


34

3.6. Upload the Program


Now, simply click the "Upload" button in the environment. Wait a few
seconds - should see the RX and TX LEDs on the board flashing. If the upload is
successful, the message "Done uploading." will appear in the status bar.

Figure 3.9. Upload the Program

3.7. Implementation of Web Server Using Wi-Fi Module


IDE is open-source software which is not only used for writing programmed
but also for uploading code to Arduino. Android application for ESP8266 is available
in the play store (Android smart phone) provides a platform to control different loads.
The ESP module is an integrated chip which offers an inbuilt strong and high range
Wi-Fi connectivity. For operating the devices on cloud or over the internet the data is
transferred wirelessly to database. This will only work if it is connected to the IP
address and the port which is provided by the ESP8266 module.

Figure 3.10. Show the Data on the Webserver Page


35

A web server is server software that can satisfy World Wide Web client
requests. The web server may then be used as a part of a system for monitoring.
Server controls and monitors the various sensors, and can be easily configured to
handle more hardware interface module (sensors).
After IP address and port address are obtained user can login from the mobile
phone or monitor. After the successful connection to the server, the data of sensors are
sent to the web server for monitoring of the system. Figure 3.8 shows the web server
page on the PC which will allow the user to monitor the system. The browser used is
chrome running on Windows 10. By entering the assigned IP address in the web
browser this web server page will appear. The web server gives the information about
the temperature or other conditions in different conditions around the environments. It
also gives the status of the various electrical appliances like light, fan etc. A few
seconds after the upload finishes, the pin 13 (L) LED on the board start to blink in
orange. If it does, Arduino board up and running.

3.8. Programing Steps for Pressure Sensor


Calculating the altitude and barometric pressure with BMP180 module needs a
lot of math. Fortunately, Adafruit BMP180 Library was written to hide away all the
complexities so that simple commands to read the barometric pressure and altitude
data. To install the library navigate to the Sketch > Include Library > Manage
Libraries. Wait for Library Manager to download libraries index and update list of
installed libraries.

Figure 3.11. Searching Library for Pressure Sensor


36

Filter search by typing ‘BMP180’. There should be a couple entries. Look for
Adafruit BMP085 Library by Adafruit. Click on that entry, and then select install as
shown in figure 3.12.

Figure 3.12. Installing Necessary Libraries for Pressure Sensor

The following sketch will give that complete understanding on how to read
barometric pressure from BMP180 module and can serve as the basis for more
practical experiments and projects.

Figure 3.13. Arduino Program for Pressure Sensor


37

3.9. Programing Steps for DHT22 Sensor


DHT22 library works if users also have the Adafruit Unified Sensor library
installed, which is also available on GitHub and install the library by going to Sketch
> Include Library > Add .ZIP Library in the Arduino IDE.

Figure 3.14. Searching Library for DHT22 Sensor

And then, ‘dht’ and ‘adafruit unified sensor’ is searched and looked for the
library by Adafruit. The latest version is selected and then clicked Install as shown in
figure 3.15.

Figure 3.15. Installing Necessary Libraries for DHT22 Sensor


38

The following figure as shown in figure 3.15 is uploaded code to the Arduino
using the Arduino IDE.

Figure 3.16. Arduino Program for DHT22 Sensor

3.10. Programing Steps for UV Sensor


To add a UV library, Sketch —>Include Library —> Add. Zip Library is
chosen step by step. And repeat the same step for all four libraries.

Figure 3.17. Searching Library for UV Sensor


39

The following figure as shown in figure 3.18 is uploaded code to the Arduino
using the Arduino IDE.

Figure 3.18. Arduino Program for UV Sensor

3.11. Programing Codes for CO Sensor


The following figure as shown in figure 3.19 is uploaded code to the Arduino
using the Arduino IDE.

Figure 3.19. Arduino Program for CO Sensor


40

3.12. Programing Codes for ESP8266 Wi-Fi Module


The following figure as shown in figure 3.20 is uploaded code to the Arduino
using the Arduino IDE.

Figure 3.20. Arduino Program for ESP8266 Wi-Fi Module

3.13 Summary
This chapter explains the overall software implementation of the system. The
program flowchart, Arduino IDE and C programming language are expressed this
chapter. Test and results are described in the next chapter.

You might also like