Data Acquisition System Using The Esp8266 Nodemcu Module
Data Acquisition System Using The Esp8266 Nodemcu Module
Guaratinguetá
2017
Pedro Cannavale Graça
Guaratinguetá
2017
To my mother Rita de Cássia Cannavale Graça and to my father Paulo Cesar da Silva Graça, for everything
support, understanding, and affection.
ACKNOWLEDGMENTS
The proposal of this project is to create a prototype of a data acquisition system capable of measuring
magnitudes such as brightness, temperature, and humidity, in work environments such as laboratories
of research. The project is divided into three main parts: the set of sensors, composed of the
sensor DHT22 and the LDR, the NodeMCU microcontroller and the IoT platform. Initially, the sensors
we measure their respective magnitudes, the collected data is then processed by the
microcontroller with WiFi support, which is responsible for interfacing between the
data and the IoT platform. Once on the platform, the data can be viewed in real time
by the user or stored in a database so that they can be consulted later, all of this
It can be performed by the user through remote access using a web browser. For the
the validation of this system was carried out by calibrating the sensors and all the data was compared
with data from equipment sold on the market. The collected data reveal aspects
interesting aspects about the working environment of the CVD Diamond Laboratory at the Center for Energies
Renewables show the importance of this type of system.
The purpose of this project is to create a prototype of a data acquisition system capable of measuring
such as luminosity, temperature and humidity, in work environments such as research laboratories.
The project was divided into three main parts: a set of sensors, consisting of the DHT22 sensor and the LDR,
the NodeMCU microcontroller and the IoT platform. Initially, the sensors perform the measurement
of their respective magnitudes, this collected data is then treated by the microcontroller with WiFi
connection support, which is responsible for performing the interface between the data and the IoT
platform. Once in the platform, the data can be viewed in real time by the user or stored in the database so
they can be queried later, this can all be accomplished by the user through a remote access using a
web browser. For the validation of this system the calibration of the sensors was performed and all
data were compared with data from equipment sold in the market. The data collected reveal interesting
aspects about the working environment of the CVD Diamond Laboratory in the Renewable Energy
Center and demonstrate the importance of this type of system.
IP Internet Protocol
GND Ground
% Percentage
◦C Celsius degree
Ω Ohm
SUMMARY
1 INTRODUCTION. . . . . . . . . . . . . . . . . . . . . . . .14
. . . . . . . . . . .
1.1 OBJECTIVE. . . . . . . . . . . . . . . . . . . . . . . . . .15
. . . . . . . . . . . .
2 BIBLIOGRAPHIC REVIEW. . . . . . . . . . . . . . . . . . 16 . . . . . . . . .
2.1 Microcontroller. . . . . . . . . . . . . . . . . . . . .16. . . . . . . . .
2.1.1 ESP8266. . . . . . . . . . . . . . . . . . . . . . . . . . 16
. . . . . . . . . . . . .
2.1.1.1 NodeMCU. . . . . . . . . . . . . . . . . . . . . . . . . .17 . . . . . . . . . . . .
2.2 MICROCONTROLLER PROGRAMMING . . . . . . . . . . . . . 18 . . . . . .
2.2.1 C++ language. . . . . . . . . . . . . . . . . . . . . . . .18. . . . . . . . . . .
2.2.2 Arduino IDE . . . . . . . . . . . . . . . . . . . . . . . . .19. . . . . . . . . . .
2.3 SENSORS. . . . . . . . . . . . . . . . . . . . . . . . . 20. . . . . . . . . . . .
2.3.1 TeTemperature and Humidity (DHT22) . . . . . . . . . . . . . . . . 20
. . . . . . . .
2.3.2 Luminosity (LDR). . . . . . . . . . . . . . . . . . . . . .20 . . . . . . . . . .
2.4 PLATAFORMA IoT . . . . . . . . . . . . . . . . . . . . . . .21. . . . . . . . . .
2.4.1 Thingr.I. . . . . . . . . . . . . . . . . . . . . . . . . .22
. . . . . . . . . . . .
5 CONCLUSION. . . . . . . . . . . . . . . . . . . . . . . .33
. . . . . . . . . . .
REFERENCES. . . . . . . . . . . . . . . . . . . . . . . 34
. . . . . . . . . . .
APPENDIX A – DECLARATION OF THE VARIABLE LIBRARIES . . 36
.
1 INTRODUCTION
Supported by the great development of the WiFi system (Wireless Fidelity, Wireless Connection), the
the world is experiencing its fourth industrial revolution, known as Industry 4.0. Because of this
new concepts and technologies have emerged that can be seen in Figure 1. For example:
IoT (Internet of Things), term created by MIT (Massachusetts Institute of Technology)
Technology, Massachusetts Institute of Technology), which represents communication among various
devices, creating a world where any process can be monitored, controlled, and analyzed;
Cloud Computing, technology initially explored by large technology companies such as
Google, Oracle, and Microsoft seeks to explore the relationship between client and server; with computing in
cloud, client computers can use the storage capacity of servers, to
perform various tasks such as: storing and accessing data, running programs and peripherals, everything
through the internet connection and can be carried out from anywhere in the world; Big Data,
basically refers to a huge and complex amount of information.
From these concepts and technologies, new devices emerge that are capable of communicating and storing.
data, these are the main responsible for the improvement and digitization of physical processes.
As a result, the presence of monitoring and acquisition systems in the market becomes very common.
data, because through IoT technology, the sensors, computers, and other devices, which would be the
things can communicate with each other and generate datasets and reports, which are usually
used in the strategic planning of companies, in the management of the main public services and even
even in the administration of cities (CLINE, 2017).
Meanwhile, the IoT concept is not only for the business environment: an acquisition system
Data based on this technology can be easily implemented in research laboratories.
Normally during the development of experiments, it is common for students and teachers to collect
15
data such as temperature, luminosity, and humidity; improving and digitizing this process can help
to reveal an influence of the working environment conditions in the experiments conducted.
As an example, the CVD Diamond laboratory of the Renewable Energy Center at UNESP.
Guaratinguetá already has a device responsible for monitoring temperature and humidity.
environment, during experiments he is often consulted by students and teachers. The introduction of
a system based on IoT technology brings several benefits, including: it enables a more in-depth analysis
it needs to be of higher quality, speeds up the process, in addition to enabling those responsible
due to the research, a flexibility because of the possibility of remote access to the collected data.
This monograph consists of five chapters. The second chapter deals with the Literature Review.
about the main components that make up this data acquisition system. The third chapter
presents in detail all the stages for the development of this system. The fourth chapter
encompasses the samples of the data obtained and their respective analyses. The fifth chapter deals with the conclusion
of this project.
1.1 OBJECTIVE
2 LITERATURE REVIEW
2.1 MICROCONTROLLER
2.1.1 ESP8266
The ESP8266 module is a microcontroller from the company Espressif (OLIVEIRA, 2017) that deals with
basically a WiFi-SOC, meaning it has the ability to connect to a WiFi network,
can act as a stand-alone application, where it does not need any other component to
function, or as a slave MCU (Microcontroller Unit).
In the second condition, it works as a WiFi adapter for another microcontroller, such as
example the arduino; it is important to emphasize that normally in this type of condition, it is necessary to use
SPI type adapters (Serial Peripheral Interface) or UART (Universal)
asynchronous receiver/transmitter, Universal Asynchronous Receiver/Transmitter.
In operation, the ESP8266 can function in two configurations: access point and client.
In the first configuration, it essentially works as a router, creating a restricted WiFi network.
password porlogine. In this mode, the ESP8266 creates a server with IP (Internet Protocol, Protocol of
random or predefined depending on the programming performed, this server can contain
a webpage with information about the components connected to the ESP8266. As a client, it establishes
a connection with the chosen WiFi network, once connected it also creates a server and all the
devices connected to the same WiFi network as the ESP8266 have access to this server at the address
of IP. This server may also contain a web page and your IP may also be random or
predefined in the programming. It is still possible to perform a third configuration and make the ESP8266
work simultaneously as access point client (ŠKRABA, A. et al, 2016).
This data acquisition system operates in client configuration, so that it would be possible to use it.
from an IoT platform for data transmission, and in addition, it actually uses the ESP8266 module -
12 coupled to the NodeMCU V3 microcontroller. This module, which can be seen in Figure 2, has
a reduced size and a reasonable cost, when compared to other WiFi adapters, has
a WiFi communication protocol 802.11 b/g/n/e/i, which allows a range of up to 120 m indoors
open.
17
2.1.1.1 NodeMCU
The NodeMCU microcontroller emerged to facilitate the construction of projects using the ESP8266,
it then presents a 3.3 V voltage regulator (operating voltage of the ESP8266), and with it, it is no longer
it is necessary to use other components such as SPI and UART adapters to make the connection.
It emerged shortly after the launch of the ESP8266, being released with the intention of being a board for
development of IoT projects. Another major advantage is due to the fact that it presents a
USB-serial interface coupled, which facilitates both the power supply of the microcontroller, which
can be done through a mobile phone charger, like the transmission part of the program
written from the computer to the board. It is worth remembering that the NodeMCU can be programmed through
scripts written in the LUA language, or can be programmed through the C++ language, by itself
Arduino platform, as was done in this project (OLIVEIRA, 2017).
Among his physical characteristics, which can be observed in Figure 3, he has a band
operation between 5 and 9V, this allows the use of, for example, a 9V alkaline battery to
microcontroller power supply. In addition, it has a total of 11 GPIO (General Purpose) ports.
Input/Output, General purpose input/output port), which can be used to connect
sensors or other external devices.
18
The NodeMCU can be programmed through scripts written in the LUA language, or through the
C++ language. This project uses the C++ language for several reasons, among them: because it deals with
of a more widespread language, with a very large number of followers, used in various
commercial programs are taught in most universities, which facilitates the search for materials for
consultation, like books and articles. Another advantage of the C++ language is that it facilitates understanding
of the logic of programming algorithms.
The LUA language is a scripting language, which implies among other things that
it does not need to be compiled, unlike the C++ language. The LUA language is very easy to be
learned, it is a simple language, and as can be seen in Figure 4, the code written in LUA is
less than what is written in C++.
Using an integrated development environment offers several advantages for the programmer.
among them: less time and effort to write the code, tools that allow for a better
project management and usually already have an integrated compiler. This project uses the IDE
for Arduino, because it provides a large number of resources for project development,
for example: the serial monitor, which allows monitoring the connection between the computer and the
NodeMCU microcontroller, and it also allows the user to provide commands to the microcontroller.
Another great advantage of using this platform is due to the development language, which
is very similar to the C++ language. It is important to emphasize that any new file created in the
The Arduino IDE platform comes by default with two functions already written, the void setup function, where
Typically, the declaration of some parameters and the void loop function is carried out, which causes
the program created should be executed infinitely by the microcontroller (MCROBERTS, 2011). As
the functions set up for this project can be viewed in Appendices B and C respectively.
This platform also features a simple interface, as can be seen in Figure 5,
in addition to a vast set of libraries related to NodeMCU and ESP8266, facilitating the stage of
project programming, as these libraries provide functions that reduce the number of lines of
programming, in addition to providing examples of projects that can be adapted as needed
to the user.
.
Source: Mota (2017)
20
2.3 SENSORS
For having a low current consumption while making the measurements, around
2.5 mA, in addition to good precision and a good operating range for humidity (0 to 100% )
temperature range (-40 to 125)◦ C), this sensor is capable of meeting all the needs of
It is worth noting that the market offers sensors at a lower cost than the DHT22, such as
for example the DHT11, its predecessor, but which has a more limited operating range being
between 20 and%80 for humidity is from 0 to 50◦ C for temperature (AOSONG ELECTRONICS CO,
2017)
conductor. This process generates an increase in current, and consequently there is a decrease in
the resistance of the LDR, in contrast with a low incidence of light, we have low conductivity
and with that a high resistance (KODALI and MANDAL, 2016). The advantages of using the sensor
LDR in this project, which can be observed in Figure 7, is related to the low cost of
component and its easy use, furthermore there are several electronic circuit projects that
they use LDR, which facilitates the search for support materials.
The IoT technology can be divided into several layers, as can be seen in Figure 8, among
these layers include the storage layer, represented by IoT platforms. Generally
the technology is divided into three layers: the producers layer, storage layer, and the
consumer layer. In the producer layer, which would be the lowest level layer, there are
generally the sensors, however, can be any device capable of generating data. In the layer of
storage, which would be the intermediate level layer, are the IoT platforms, which have the function
to receive, store, and provide the data to the last layer, the consumers' layer.
In this layer are the users, applications, and services that use the platform to access the
data (RODRIGUES, 2016).
22
These platforms are simple and practical spaces, regardless of the type of thing that is connected.
they use cloud computing and big data concepts to assist the user in analysis
and storage of the collected data. All platforms generally have a large
the amount of resources that help consumers visualize the data is up to the developer
research which provides the best cost-benefit ratio for the project. It is necessary to verify points
important related to data security, it is interesting to look for platforms that have the
SSL (Secure Socket Layer) security certificate, this protocol is mainly responsible for
encrypt the entire connection between the browser and the server.
2.4.1 Thinger.io
This project uses the thinger.io platform, due to the wide variety of resources for construction.
dodashboards1 in addition to the possibility of storing data in data buckets2 , these characteristics
they greatly assist in the visualization and analysis of data by the user.
Thinger.io is an open-source platform and its workflow works from the
following way:
This platform includes the complete set of APIs (Application Programming Interface).
application programming) to handle HTTP requests, in addition it has an application for
cell phone that allows control of all devices connected to the platform (VITHLANI et al,
2017).
1
Panel that allows data visualization.
2
Space for storing the collected data
23
To use thinger.io, the user needs to access the site through their web browser.http://thinger.io
create a username and password; the access information will be used in the programming of the microcontroller.
to establish the connection of it with the platform. Thinger.io is one of the best platforms
of the market, its free version limits the number of devices, dashboards, and data buckets, but
even so, it was able to meet all the needs of this project.
24
The system that can be observed in Figure 9 was assembled and designed to be capable of measuring
magnitudes such as temperature, humidity, and luminosity and store this data so that it can be
later analyzed. This data acquisition system can then be divided into three parts:
Set of sensors
NodeMCU Microcontroller
IoT Platform
The NodeMCU microcontroller receives all the necessary programming to perform the interface.
between the collected data and the IoT platform, that is, it is responsible for storing the data
collected by the sensors into variables and transmit the same to the platform. In addition, all
the connection part both with the WiFi network and with the IoT platform is also carried out by
microcontroller. On the platform, the data will be presented to the user and will be stored.
for future analyses.
The circuit was assembled with simple components and has two power supply options: one
direct feeding where we take advantage of the micro-usb port of the NodeMCU and connect directly
a cell phone charger, or a usb/micro-usb cable and we take advantage of the power from a computer or
25
notebook. It can also be used with indirect power supply through a circuit containing a
9V alkaline battery and a 5V voltage regulator. The output of the regulator is applied to the Vin pin.
do NodeMCU.
It is possible to observe in Figure 9 a red LED, which is used to indicate connection failures.
the NodeMCU with the WiFi network, when a failure occurs the LED turns on, being turned off when the connection
reestablished so that it does not harm the data collection related to luminosity.
• SPI.h: it is about the serial peripheral interface, this library is responsible for providing functions
able to perform communication between a microcontroller and a peripheral device, or
between two microcontrollers. This communication is performed through a serial protocol of
adequate data.
• ThingerWiFi.h: it is the library responsible for providing functions that allow connection
microcontroller with the thinger.io platform, in addition to providing the functions responsible for the
statement of the devices and by sending data to the platform, all the functions of this library
They start with the word thing.
• DHT.h: this is the library responsible for providing functions that facilitate programming of the
sensor DHT22, it contains the functions dht.readTemperature() and dht.readHumidity(), responsible
for processing the signal received at the GPIO port of the microcontroller.
• math.h: it is a basic Arduino library that allows for operations to be carried out
more complex mathematics.
In addition to the libraries, it is in this initial part of the code that some parameters are defined and occurs
the creation of all the variables that will be used in the program. Appendix A shows that the two
the first variables created (lines 9 and 10) are of type char, and receive the information from the WiFi network
which microcontroller will connect. Right after that (lines 12 to 16) the parameters are defined.
26
which enable the connection to the IoT platform and the GPIO port that will be used by the DHT22 sensor.
To avoid errors, all created variables are initialized (lines 20 to 25) with the value zero, this
prevents any residue in the memory from being added to the measured value.
Before the program enters the void setup() function, two functions are still called: aThingerWiFi
(line 27), responsible for establishing the connection with the Thinger.io platform, it receives as parameters
the username, the device identification, and the access password, respectively in that order.
And the function WiFiServer(line 28), originating from the ESP8266WiFi library, is responsible for creating a
server that receives connections from port 80.
chosen, through the function WiFi.begin(line 13) from the library ESP8266WiFi.h, which
receives as parameters the name and access password of the WiFi network. In addition, still within the function
setup also involves connecting the devices to the IoT platform, using the function a
thing.add-wifi(line 4), which takes the same parameters as the function WiFi.begin.
In the setup function, the declaration of our API is also carried out (lines 15 to 18), through the function
thing, which receives as parameters the name of the API. In this project, the name Sensors was used,
this API has three resources which are: temperature, humidity, and luminosity, which receive
the values measured through the sensors. It's important to mention that the names chosen here are
important, since the columns of our database automatically receive the same name
dosresources.
Right after (lines 21 to 28) there is the function WiFi.status, which is responsible for verifying the
connection to the WiFi network, this function is within a while loop, that is, as long as the microcontroller
If the device is not connected to the WiFi network, the program will get stuck at this point. It was defined within
In the while block, while the connection does not occur, the LED will remain on indicating this failure, this happens
through the command digitalWrite(5, 1), where the number 1 represents the high logic level and the number 5
represents the microcontroller pin where the LED connection was made. When the connection is
Once the program is executed, it will exit the block while and the LED will be turned off, through the same command, but
changing the number 1 to the number 0 to represent the low logic level.
In the final part (lines 29 to 37) of the setup function, the call to the server.begin() function occurs and there are
several lines of code started with the expression serial., this function is directly related
the possibility of working with the ESP8266 in access point operating mode, as mentioned
previously this server started by laser server.begin can contain a web page for transmission
two dice. The lines of code that start with serial are responsible for the communication of the microcontroller.
controller with the serial monitor of the Arduino IDE. During the initial development of the project, the
The serial monitor tool was widely used because it was the easiest way to check the communication.
of the microcontroller with the sensors.
It's important to highlight that the serial monitor is also a very important tool for the
operation on access point, as it is through it that the user can discover the IP address of the
server created.
27
The function loop, which can be seen in Appendix C, as its name exemplifies, once
when the program reaches this part of the code, this function keeps being executed infinitely until
The feeding should be turned off. It is in the function loop (lines 3 to 8) that all the data collection part occurs.
Because every time it is executed, there is an update of the values of the magnitudes.
Just like in the setup function, tests are also performed in the loop function to verify the
operation of the project. Again, the function WiFi.status(line 21) tests the connection with the
WiFi network and when using the ESP8266 in access point mode, it is tested using the function
server.available(line 13) the operation of the server is through the function client.available(line 18)
the user's connectivity test with the server is performed.
Another important point of the loop function is that by choosing not to use an IoT platform for the
data transmission, we must create the web page within the function, this is done through a
combination of the C++ language with the HTML language. The intention of this project was not to work
with such a resource, but as an example, the final part of the code present in Appendix C shows a
example of a webpage to provide the brightness value to the user.
Since the output of the digital signal from the A/D converter is a number between 0 and 1024, being
this interval represents the voltage range between 0 and 3.3V, calibration was necessary
from this sensor so that the output would be expressed in a quantity that is easy to understand. The quantity
the chosen one was the lux, and the calibration was carried out as follows: using a lux meter from the brand
Using model 204 and with the help of Microsoft Excel software, a curve was raised relating
the resistance value of the LDR sensor, with the value shown on the luxmeter. As the resistance curve
due to light it is an exponential, it was necessary to perform a conversion of the axes to the scale
logarithmic and draw a trend line using a feature of Microsoft Excel itself, to
determine the luminosity equation of the LDR. The result of this procedure can be observed
in Figure 10.
28
It is worth remembering that it was necessary to calculate the resistance value of the LDR before carrying out the process.
For calibration, the calculation was made based on equations (1) and (2):
(9860*3.3-V outLdr)
(2)
V outLdr
The equation (1) represents the conversion of the digital value (ValorLdr) to the analog value (VoutLdr).
The connection of the LDR with the microcontroller represents a voltage divider, so equation (2) deals with it.
of a voltage divider, where 9860 is the real value of the resistor, which was measured with the help of a
multimeter.
3.4.1 Dashboard
This project uses an IoT platform so that data can be accessed from anywhere.
Thinger.io allows the user to configure a dashboard to facilitate the visualization of their data.
the user can choose from display type components, which are graphics, progress bars and the
text boxes, or device control types where it can define states such as ON or OFF.
29
As can be seen in Figure 11, the dashboard of this project contains several elements, including
There is: a clock set to the same time zone where the device is located, the location
approximate of the device, three graphs to show the variation of temperature, luminosity and
of humidity, with the first two being line type and having labels that facilitate the visualization of the
data, and the last of the threaded type.
Thinger.io has its own database system, this system is known on the platform.
Comodata buckets. Osdata buckets allow the measured data to be stored.
on this platform there is a restriction that the minimum period for which data can be stored is
every minute. From the platform it is possible to send all stored data to the email
user's personnel, the data is saved in files with the .csv extension (Comma Separated Values File)
by Commas ), this file format can be opened using Microsoft Excel. In addition to the option of
export all data, the platform allows the user to export by specifying a period of days
and hours, as the platform space is limited, the user will have to use the function at some point
clear, where again he can choose the clear all option, which will delete all the data from the database,
you specify a period for the cleaning.
30
4.1 DATABASE
Various tests were conducted with this data acquisition system and in addition, the data
were compared with data collected by equipment manufactured by major companies in the sector
of instrumentation and the difference is irrelevant.
Due to this project using the free version of thinger.io, the system is limited to storing the
information with a minimum time of one minute. Even with this limitation, the amount of data
The stored data was large, therefore, only a sample of the monitoring will be shown in Table 1.
from November 9, 2017, from the CVD Diamond Laboratory at the Renewable Energy Center.
Date/Time Luminosity
2017-11-09T11:41:45.339 494,674 24.9 57.9
2017-11-09T11:43:33.644 49,817 24.9 57.9
2017-11-09T11:44:44.120 598,666 24.9 58
2017-11-09T11:45:54.631 54,257 24.9 58
2017-11-09T11:47:05.102 54,257 24.9 58
2017-11-09T11:48:15.547 489,486 24.9 58
2017-11-09T11:49:25.988 572,852 24.9 58
2017-11-09T11:50:36.490 49,817 24.9 58
2017-11-09T11:51:47.203 49,817 24.9 58
2017-11-09T11:52:57.648 501,696 24.9 58
2017-11-09T11:54:08.091 50,347 24.9 58.1
2017-11-09T11:55:18.547 49,817 24.9 58.1
2017-11-09T11:56:28.979 552,432 24.9 58.1
2017-11-09T11:57:39.610 521,639 24.9 57.7
2017-11-09T11:58:50.110 544,524 24.9 57.8
November 9, 2017, 12:01:08.729282,647
PM 25.2 58.6
2017-11-09T12:02:01.373 288,849 25.4 58.5
2017-11-09T12:04:04.522 288,849 25.6 58.5
2017-11-09T12:05:22.135 295,321 25.9 57.6
2017-11-09T12:06:32.683 292.05 26 57.2
2017-11-09T12:07:43.208 265,504 26.1 55.9
2017-11-09T12:08:53.732 292.05 26.1 54
2017-11-09T12:10:04.258 309,157 26.1 52.3
2017-11-09T12:11:15.777 305,581 25.9 51
2017-11-09T12:12:26.339 309,157 25.7 50.4
2017-11-09T12:13:36.863 305,581 25.6 52.6
2017-11-09T12:16:37.541 650,148 25.6 55.4
2017-11-09T12:17:40.266 589,895 25.7 54.5
2017-11-09T12:18:42.995 585,573 25.6 54.9
2017-11-09T12:19:50.587 592,072 25.6 55.2
2017-11-09T12:20:53.270 600,885 25.6 56.1
Source: Production by the Author.
31
The complete data can be viewed through the graphs in Appendix D; this was selected.
sample of the data to show some interesting aspects. For example, between 12:13:36.863
at 12:16:37.541 there is a difference of more than a minute, this implies two possible causes,
failure in connecting to the WiFi network or failure in powering the microcontroller. Noting that
at 12:16:37.541 the brightness nearly doubled, it is concluded that the main cause
It was probably a power outage for a change in the position of the LDR sensor.
regarding the light source. Another interesting aspect is that when we have very values
low lighting, it is concluded that the laboratory has the lighting turned off, this type of
Monitoring allows for a study on the electricity consumption of the laboratory in question.
In addition, another interesting fact concerns the construction of the laboratory, as it is
made of eco-brick, the internal temperature of the laboratory remains practically constant not
importing the temperature in the outdoor environment, which on the day in question was at 30◦ C during this
time period.
The sample from Table 2 serves to demonstrate a common error that occurred during the early
tests. As can be observed at 17:53:13.769 on October 16, 2017, a value occurred
very low light, this indicates a problem with poor contact between the LDR sensor and the
NodeMCU microcontroller, this problem was solved through proper soldering.
Date/Time Brightness
2017-10-16T17:09:22.396 305,581 25.8 54.3
2017-10-16T17:10:25.138 359,549 25.8 52.2
2017-10-16T17:11:27.875 369,575 25.8 52.6
2017-10-16T17:31:21.593 309,157 26.3 49.5
2017-10-16T17:32:32.336 320,399 26.2 48.1
2017-10-16T17:45:16.022 279,642 26.3 53.3
2017-10-16T17:46:18.772 220,492 26.3 54.1
2017-10-16T17:47:22.139 247,886 26.3 52.7
2017-10-16T17:48:21.695 282,647 26.2 51.7
2017-10-16T17:49:24.445 192,296 26.1 49.8
2017-10-16T17:50:27.203 161,228 25.9 49.0
2017-10-16T17:51:29.957 260,229 25.9 50.2
2017-10-16T17:53:13.769 0.156843 26.2 52.5
Source: Production of the Author Itself.
Table 3 provides an estimate of the cost to set up this project. The values of the
sensors and resistors were based on local trade, in case they are purchased in stores
buying online in large quantities, the price decreases considerably.
32
R$43.80
Source: Production by the Author.
The main difficulty in working with the NodeMCU microcontroller is that it does not
It was designed to fit into breadboards. Due to its width, it takes up all the space.
protoboards need to have the connections made underneath them, which ends up being the main cause
of poor contact problems. The ideal is to assemble the project on a perforated board, this allows for a
better organization of the components in addition to providing a better aesthetic for the system.
Another difficulty is that there are few support materials about NodeMCU, and the best
materials are in other languages, most of the research related to this microcontroller is
being developed in India.
It was very common when uploading the project to the microcontroller to encounter some
errors, such as not identifying the USB port to which the microcontroller is connected. Another
a very common error is when reading the data on the serial monitor, by default it is configured
at a rate of 9600 baud, the NodeMCU needs to be at a rate of 115200 baud. Among others
compilation errors often due to programmer failure.
It can be pointed out as future work to look for solutions for powering the microcontroller.
that we make the system more remote. In the current process, it is possible to use an alkaline battery to
its diet, however, has a durability of only 20 hours of work,
it would be interesting to think about the concept of renewable energies and power the microcontroller from
photovoltaic panels.
Another detail of the project is that currently the LDR is not able to accurately measure the amount.
of luxury, in outdoor environments, the most plausible explanation for such a fact is the saturation of the component,
a new sensor could be considered to be used instead of the LDR, or even some adjustment so that
the component would be able to perform such measurements. It is also worth noting the usefulness of this
The system has various aspects, for example, one can take advantage of the verification of the connection with the
WiFi network to generate a database of how many times the connection has dropped or to monitor it.
How long do the lights in the laboratory stay on?
33
5 CONCLUSION
The present work described all the stages of development of an acquisition system.
data to be used in research centers, capable of verifying temperature, humidity and
luminosity, with the aim of verifying how these factors influence the experiments conducted.
All tests were conducted at the CVD Diamond Laboratory, of the Renewable Energy Center.
from UNESP - Guaratinguetá Campus.
The final measurement system is based on a circuit composed of sensors, a microcontroller.
It is an IoT platform, however, the initial proposal included the use of an Arduino Uno and the
ESP8266 microcontroller, during the development of this project this Arduino and ESP8266 set,
was replaced by NodeMCU, which in addition to having the same characteristics as this set, has
more practicality in the circuit assembly part, in addition to making the project cheaper by using
fewer components.
Due to the limitation of the LDR sensor, this project works only for indoor environments, being
it is necessary to replace the sensor so that it can be used in outdoor environments.
Another point that can be mentioned is that in this project there was a great concern.
with the way the user has access to the data collected by the sensors, due to this concern-
instead of using a webpage created by
NodeMCU.
In general, the main objective of the project was successfully achieved. All the collected data
They were sent by the IoT platform and can be viewed and analyzed by the user at any time.
moment and from anywhere.
34
REFERENCES
CLINE, G.Industry 4.0 and Industrial IoT in Manufacturing:a sneak peek. Available at:
The provided text does not contain translatable content.
sneak-peek/>. Accessed on: November 25, 2017.
GREEN, Jim. Building the Internet of Things: an IoT reference model. In: INTERNET OF
THINGS WORLD FORUM, 2014, Chicago.Electronic Notes...2014. p. 1-19. Available-
Well at: <https://www.slideshare.net/Cisco/building-the-internet-of-things-an-iot-reference-model>.
Accessed on: November 26, 2017.
KODALI, R. K; MAHESH, K. S. Low cost ambient monitoring using ESP8266. In: INTERNATIONAL
CONFERENCE ON CONTEMPORARY COMPUTING AND INFORMATICS, 2., 2016, Greater
35
RODRIGUES, J.Data security mechanisms for IoT platforms. 2016. 169 f. Dis-
thesis (Master's in Computer Engineering and Telematics) - University of Aveiro, 2016.
Available at: <https://ria.ua.pt/bitstream/10773/17273/1/Diss-JoaoRodrigues.pdf>. Accessed on: 20
Nov. 2017.
ŠKRABA, A. et al. Prototype of group heart rate monitoring with NODEMCU ESP8266. In: MEDI-
TERRANEAN CONFERENCE ON EMBEDDED COMPUTING, 6th, 2017, Bar.Electronics Anais...
Bar: IEEE, 2017. Available at: <http://ieeexplore.ieee.org/stamp/stamp.jsp?ar number=7977151>.
Accessed on: August 21, 2017.
ŠKRABA, A. et al. Streaming pulse data to the cloud with Bluetooth LE or NODEMCU ESP8266. In:
MEDITERRANEAN CONFERENCE ON EMBEDDED COMPUTING, 5th, 2016, Bar.Anais He-
electronics...Bar: IEEE, 2016. Available at: <http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=
Accessed on: August 21, 2017.
STROUSTRUP, B.The C++ programming language. 3rd ed. Murray Hill, New Jersey: AT&T Labs,
1997. 912 p.
VITHLANI, R. et al. An open source real time IoT based environmental sensor monitoring system.
INTERNATIONAL CONFERENCE ON RESEARCH AND INNOVATIONS IN SCIENCE, ENGI-
ENGINEERING & TECHNOLOGY, 2., 2017, Vallabh Vidyanagar. Electronic Annals. . . Vallabh Vidya-
nagar: Kalpa Publications in Computing, 2017. Available at: <https://easychair.org/publications/
accessed on: November 21, 2017.
36
1void setup() {
2
3dht.begin();
4thing.add_wifi(wifi_name, wifi_password);
5Serial.begin(115200);
6delay(10);
7
8Serial.println("");
9Serial.println("");
10Serial.print(Connecting to
11Serial.print(name_redewifi);
12
13WiFi.begin(wifi_name, wifi_password);
14
15 thing["Sensores"] >> [](pson& out){
16 temperature
17 humidity
18 ldrluxc
19 };
20
21while(WiFi.status() != WL_CONNECTED) {
22delay(500);
23Serial.print(".");
24pinMode(5, OUTPUT);
25digitalWrite(5, 1);
26
27pinMode(5, OUTPUT);
28digitalWrite(5, 0);
29Serial.println("");
30Serial.print(Connected to the wireless network
38
31Serial.println(name_redewifi);
32server.begin();
33Serial.println(Server started
34
35Serial.print(IP to connect to the server
from the NodeMCU board:
36Serial.print("http://");
37Serial.println(WiFi.localIP());
38
39
1voidloop() {
2
3valorldr = analogRead(A0);
0.00322265625 *
5rldr = (9860 * (3.3 - voutldr) / voutldr;
6ldrluxc = 10^5.0459 * (pow(rldr,-0.8729));
temperature = dht.readTemperature();
dht.readHumidity();
9
10delay(3000);
11
12thing.handle();
13WiFiClient client = server.available();
14if(!client) {
15return;
16}
17Serial.println(New customer connected!
18while(!client.available()){
19delay(1);
20
21while(WiFi.status() != WL_CONNECTED) {
22delay(500);
23Serial.print(".");
24pinMode(5, OUTPUT);
25digitalWrite(5, 1);
26
27pinMode(5, OUTPUT);
28digitalWrite(5, 0);
29String request = client.readStringUntil('\r');
30Serial.println(request);
40
31client.flush();
32client.println(HTTP/1.1 200 OK
33client.println(Content-Type: text/html
34client.println("");
35client.println(<!DOCTYPE HTML>
36client.println(<html>
37client.println(<head> <meta charset='UTF-8'>
38client.println(<META http-equiv= refresh CONTENT=3