Monitoramento de temperatura e umidade por meio de robô em movimento

Temperature and humidity monitoring using a moving robot

Robots are designed to facilitate and automate the work of humans. They are useful for deploying in hard-to-reach places. In this tutorial, a humidity and temperature monitoring rover based on IoT robotic application is designed. Humidity and temperature are the most common physical environments that need to be monitored. The four-wheeled robot designed in this project can be operated within a range of 30 meters and withstand temperatures of up to 150 degrees Celsius.
The robot can be controlled via a cell phone that will have a customized application installed. The cell phone will connect to the robot via Bluetooth. For Bluetooth connectivity, the electronic circuit that controls the robot has the HC-05 Bluetooth module connected to it. To control the robot, any Android smartphone will be required to pair with the HC-05 Bluetooth module and launch the custom app designed for this project. The application can be downloaded from this tutorial.
The electronic circuit also has ESP8266 Wi-Fi module connected to it. The Wi-Fi module is used to connect to any available Internet hotspot and transfer temperature and humidity data to a remote server. An IoT platform is used to receive and record data. The same platform is used to monitor real-time data. To record temperature and humidity information, DHT-11 humidity and temperature sensor is used in the circuit.
Protótipo de robô ThingSpeak IoT baseado em Arduino para monitoramento de temperatura e umidade
Figure 1: Arduino-based ThingSpeak IoT robot prototype for temperature and humidity monitoring
The robot's control circuit is built around the Arduino Pro Mini. The Arduino board is preferred because it is the most popular controller board and has great community support. The Pro Mini is used in the circuit due to its rich features packed into a compact size. Furthermore, it is useful to install such a small controller board on any robotic body. The robot is driven by geared DC motors which are controlled through the L293D motor driver IC. The Arduino sketch running in the control circuit is written and compiled in the Arduino IDE, while the custom application used to send control commands is built using MIT App Inventor 2. The IoT platform used to monitor the sensor data is ThingSpeak.

Required components –

Lista de componentes necessários para o robô ThingSpeak IoT baseado em Arduino usado para monitoramento de temperatura e umidade
Fig. 2: List of components required for Arduino-based ThingSpeak IoT robot used for temperature and humidity monitoring

Block diagram –

Diagrama de blocos do robô ThingSpeak IoT baseado em Arduino para monitoramento de temperatura e umidade
Fig. 3: Block diagram of Arduino-based ThingSpeak IoT robot for temperature and humidity monitoring

Circuit Connections

The robot's control circuit is built around the Arduino Pro Mini.
Imagem do circuito IoT ThingSpeak baseado em Arduino conectado ao corpo do robô
Fig. 4: Image of Arduino-based ThingSpeak IoT circuit connected to the robot body
The circuit is constructed by integrating the following sections –
Power Source – In the circuit, Arduino Pro Mini, Bluetooth module and Wi-Fi module need regulated 5V DC for their operation, while the motor driver IC needs 12V DC. A 12V NIMH battery is used as the primary power source. The battery power is regulated to 5V and 12V using 7805 and 7812 ICs. Pin 1 of both voltage regulator ICs is connected to the battery anode and pin 2 of both ICs is connected to ground. The respective voltage outputs are taken from pin 3 of the respective voltage regulator ICs. An LED along with a 10K Ω pull-up resistor is also connected between the common ground and the output pin to get a visual cue of power continuity. Despite using a 12V battery, the 7812 is used to provide a regulated and stable power supply to the motor driver IC.
Arduino ProMini – Arduino Pro Mini is a microcontroller board based on Atmega 168. It has 14 GPIO pins, 6 analog inputs, 6 PWM pins, 2 external interrupts and integrated UART, SPI and I2C. The board is just 1.3 inches by 0.7 inches in size, six times smaller than the Arduino UNO. With these features packed into a small size, this board is ideal for any robotics project. In this project, 4 input and output pins of the Pro Mini are used to interface with the motor driver IC and the Bluetooth module interfaces with the RX and TX pins available for serial communication via UART. One of the pins is used to interface the DHT-11 sensor and two GPIO pins are used to interface the ESP8266 Wi-Fi module.
HC-05 Bluetooth Module – The HC-05 Bluetooth module is a serial port protocol module. Operates in the 2.4 GHz ISM band with V2.0+EDR (enhanced data date). It can work in Master and Slave modes. The Bluetooth module has six pins – Enable, VCC, Ground, Transmit Data (TxD), Receive Data (RxD) and State. The Enable and State pins are unused and therefore not connected to the circuit. The VCC and Ground pins are connected to common VCC and Ground. The TxD and RxD pins of the module are connected to the RX and TX pins of the Arduino Pro Mini respectively. These connections are summarized in the table below –
Tabela listando a configuração dos pinos do módulo Wi-Fi ESP8266 ESP-12
Fig. 5: Table listing the pin configuration of the ESP8266 ESP-12 Wi-Fi module
ESP8266 Wi-Fi Module – The ESP8266 Wi-Fi module is used to connect to any available Internet hotspot and transfer sensor data to the ThingSpeak platform via Wi-Fi. The ESP8266 Wi-Fi Module is a standalone stack-powered SOC built-in TCP/IP protocol that can provide any microcontroller with access to a Wi-Fi network. The ESP8266 is capable of hosting an application or offloading all Wi-Fi networking functions from another application processor.
Each ESP8266 module comes pre-programmed with AT command set firmware. So, one can simply connect it to an Arduino device. Here it uploads the monitoring data to the cloud. The module is available in two models – ESP-01 and ESP-12. The ESP-12 has 16 pins available for interfacing, while the ESP-01 only has 8 pins available for use. The ESP-12 has the following pin configuration –
Tabela listando a configuração dos pinos do IC do driver do motor L293D
Fig. 6: Table listing the pin configuration of the ESP8266 ESP-12 Wi-Fi module
The ESP-12 model is used in the project. The module's Reset and VCC pins are connected to 5V DC while the Ground pin is connected to common ground. The Tx and Rx pins of the module are connected to pins 11 and 10 of the Arduino Pro Mini. Arduino pins 11 and 10 are configured for serial receiver and transmitter through the software's serial function.
DHT-11 Temperature and Humidity Sensor – The DHT -11 sensor reads the ambient temperature and humidity and relays the data to the microcontroller as digital data. The data pin of the DHT11 temperature and humidity sensor is connected to pin 12 of the Arduino Pro Mini. VCC and ground are connected to common VCC and ground.
L293D DC Motor Driver IC – The L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as current amplifiers in that they receive a low current control signal and supply a higher current signal. This higher current signal is used to drive the motors. It has 16 pins with the following pin configuration:
Tabela listando a configuração dos pinos do IC do driver do motor L293D
Fig. 7: Table listing the pin configuration of the L293D motor driver IC
There are two DC motors used to make the robotic car. DC motors interface between pins 3 and 6 and pins 14 and 11 of the motor driver IC.
IC L293D controls DC motors according to the following truth tables:
Captura de tela da interface do usuário da plataforma ThingSpeak
Fig. 8: Truth table of L293D motor driver IC
Tabela verdade do IC do driver do motor L293D
Fig. 9: Screenshot of the ThingSpeak platform user interface
Pins 4, 5, 13 and 12 of the L293D are grounded while pins 1, 16 and 9 are connected to 5 VDC and pin 8 is connected to 12 VDC. Pins 15, 2, 7 and 10 of the motor driver IC are connected to pins 8, 2, 3 and 7 of the Arduino board. The DC motor connected to the right wheel is connected to pins 11 and 14, while the motor connected to the left wheel is connected to pins 3 and 6 of the motor driver IC.
Geared DC Motors – In this robot, 12V geared DC motors are attached to the wheels. Geared DC motors are available with a wide range of RPM and Torque, which allows a robot to move based on the control signal it receives from the motor driver IC.

How the circuit works –

After assembling the robot, it can be used by attaching a battery to the circuit. As the robot powers on, it begins fetching data from the DHT-11 temperature and humidity sensor and searches for any available Internet access points to connect to the ThingSpeak platform. ThingSpeak is an IoT analytics platform service that allows you to aggregate, visualize and analyze live data streams in the cloud. ThingSpeak provides instant views of data posted by IoT devices to the ThingSpeak server. With the ability to run MATLAB code in ThingSpeak, you can perform online analysis and processing of data as it arrives.
The DHT11 detects water vapor by measuring the electrical resistance between two electrodes. The moisture sensing component is a substrate that traps moisture with electrodes applied to the surface. When water vapor is absorbed by the substrate, ions are released by the substrate, which increases the conductivity between the electrodes. The change in resistance between the two electrodes is proportional to relative humidity.
Higher relative humidity decreases the resistance between the electrodes, while lower relative humidity increases the resistance between the electrodes. The DHT11 measures temperature with a surface-mounted NTC temperature sensor (thermistor) built into the unit. The humidity and temperature measured by the sensor are monitored and recorded through the ThingSpeak IoT platform through the Wi-Fi module that is connected to the controller that provides serial communication for data transfer. The recorded data is visible in the platform UI.
Captura de tela da interface do usuário da plataforma ThingSpeak
Fig. 10: Screenshot of the ThingSpeak platform user interface
The robot can be moved by passing commands from a custom Android app installed on any smartphone. The custom Android app was designed using MIT App Inventor 2. Check out the programming guide to learn how the app was designed using MIT App Inventor. The custom app has buttons to move the robot forward, backward, left, right and to stop it. The user simply taps the direction buttons to transfer commands. Commands are passed by the application to the Bluetooth module connected to the control circuit in the form of single character sequences. The following strings are passed to transfer the control commands –
Comandos de string de listagem de tabelas usados ​​pelo IoT Robot
Fig. 11: Table listing string commands used by IoT Robot
These command strings are interpreted in the Arduino sketch to control the DC motors. The robot can be moved forward, backward, left or right by implementing the following input logic on the motor driver pins –
Tabela verdade do IC do driver do motor L293D
Fig. 12: L293D Motor Driver IC Logic Table for IoT Robot
Upon receiving the string commands, the Arduino sketch just changes the digital output on the input pins of the motor driver IC to control the movement of the robot.
Imagem mostrando o robô ThingSpeak IoT baseado em Arduino
Fig. 13: Image showing the Arduino-based ThingSpeak IoT robot

Programming guide –

The custom application used to control the robot's movement is built using MIT App Inventor. There are also many Bluetooth Android apps available on the Play Store that can be used. If any app available on Play Store is used, the Arduino sketch needs to be modified or changed accordingly. MIT App Inventor 2 is used to build the application.
Captura de tela do aplicativo personalizado projetado usando o MIT App Inventor
Fig. 14: Screenshot of custom application designed using MIT App Inventor
MIT Inventor app is an easy platform to create an Android app. The platform uses logic blocks to create an application. A guide for using the MIT app inventor 2 is provided on the platform's official website. There are also many YouTube tutorials available for reference. The robot control application created in this project has the following logics that are formed with the help of blocks –
Captura de tela dos blocos lógicos do aplicativo personalizado projetado usando o MIT App Inventor
Fig. 15: Screenshot of the logic blocks of the custom application designed using MIT App Inventor
Captura de tela dos blocos lógicos do aplicativo personalizado projetado usando o MIT App Inventor
Fig. 16: Screenshot of the logic blocks of the custom application designed using MIT App Inventor
Even more features can be added to the application by including additional logic blocks.
In the robot control circuit, the Arduino sketch running on the Pro Mini controls the robot mechanism. Arduino sketching starts with importing the header files. The following header files are included in the DHT-11 sensor code and software serial functionality –
#include
#include
The following #define directives are used to determine the Arduino pins that should be connected to the motor driver IC.
#define LM1 2
#define LM23
#define RM17
#define RM2 8
The following code block defines the function prototypes that are used to determine the engine's tasks.
character data = 0;
void advance ;
void rewind;
void turn left ;
void turn right ;
void robostop;
The following block of code defines the API key provided by ThingSpeak when creating the channel where data should be written. This API key must be replaced with the API key assigned to you by the ThingSpeak platform.
String apiKey = “9W6L82SPOZKQ1A1W”;
The following code defines the software serial pins used for Wi-Fi communication.
SoftwareSerial be(11,10); //RX,TX
The following block of code is the setup function where it is used to determine whether the connected pins are used as input or output and enable serial communication. Here Serial.begin(9600) is used to establish serial communication between bluetooth and arduino and Serial.begin(115200) is used for serial communication between Wi-Fi and arduino. It should be noted that the new version of the Wi-Fi module will be able to work with a transmission rate of 9600.
null configuration
{
Serial.begin(9600);
pinMode(LM1, OUTPUT);
pinMode(LM2, OUTPUT);
pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);
ser.begin(115200);
To learn about AT commands, see ESP8266 – AT Command Reference.
The complete Arduino Sketch for the IoT based Humidity and Temperature Monitoring Rover can be found in the source code tab.
Note : Please find the Bluetooth controlled application file below.

Project source code

###

 //Program to

 #include

 #include // include dht sensor library


 dht DHT;


 float t=0;

 float h=0;


 #define LM1 2

 #define LM2 3

 #define RM1 7

 #define RM2 8

 #define DHT11_PIN 12


 char data = 0;

 void moveforward;

 void movebackward;

 void turnleft ;

 void turnright ;

 void robostop;


 // replace with your channel's thingspeak API key

 String apiKey = "9W6L82SPOZKQ1A1W";


 // connect 10 to TX of Serial USB

 // connect 11 to RX of serial USB

 SoftwareSerial be(11,10); // RX, TX


 // this runs once

 void setup

 {

 // enable serial debug

 // Serial.begin(115200);
 
Serial.begin(9600);

 pinMode(LM1, OUTPUT);

 pinMode(LM2, OUTPUT);

 pinMode(RM1, OUTPUT);

 pinMode(RM2, OUTPUT);

 // enable serial software

 ser.begin(115200);



 // reset ESP8266 WiFi connection AT+CIPMUX=1 AT+CWJAP

 ser.println("AT");

 delay(1000);

 ser.println("AT+GMR");

 delay(1000);

 ser.println("AT+CWMODE=3");

 delay(1000);

 ser.println("AT+RST");

 delay(5000);

 ser.println("AT+CIPMUX=1");

 delay(1000);

 String cmd="AT+CWJAP="Gokul","22031994"";

 ser.println(cmd);

 delay(1000);

 ser.println("AT+CIFSR");

 delay(1000);

 }



 // the loop

 void loop

 {

 if(Serial.available >0)

 {

 data = Serial.read;

 Serial.print(data);

 Serial.print("n");

 if(data == 'F')

 {

 Serial.println("Forward");

 moveforward;

 }

 else if(data == 'B')

 {

 Serial.println("Backward");

 movebackward;

 }

 else if(data == 'L')

 {

 Serial.println("Left");

 turnleft ;

 }

 else if(data == 'R')

 {

 Serial.println("Right");

 turnright ;

 }

 else if(data == 'S')

 {
 
Serial.println("Stop");

 robostop;

 }

 }

 delay(1000);

 int chk = DHT.read11(DHT11_PIN);

 Serial.print("Temperature = ");

 t = DHT.temperature;

 Serial.println

 Serial.print("Humidity = ");

 h = DHT.humidity;

 Serial.println(h);

 esp_8266;


 }


 void esp_8266

 {

 // TCP connection AT+CIPSTART=4,"TCP","184.106.153.149",80

 String cmd = "AT+CIPSTART=4,"TCP","";

 cmd += "184.106.153.149"; //api.thingspeak.com

 cmd += "",80";

 ser.println(cmd);

 Serial.println(cmd);

 if(ser.find("Error"))

 {

 Serial.println("AT+CIPSTART error");

 return;

 }



 // prepare GET string GET

 String getStr = "GET /update?api_key=";

 getStr += apiKey;

 getStr +="&field1=";

 getStr +=String(h);

 getStr +="&field2=";

 getStr +=String

 getStr += "rnrn";

 // send data length

 cmd = "AT+CIPSEND=4,";

 cmd += String(getStr.length );

 ser.println(cmd);

 Serial.println(cmd);

 delay(1000);

 ser.print(getStr);

 Serial.println(getStr);


 delay(10000);

 }


 void moveforward

 {

 digitalWrite(LM1, HIGH);
 
digitalWrite(LM2, LOW);

 digitalWrite(RM1, HIGH);

 digitalWrite(RM2, LOW);

 }


 void movebackward

 {

 digitalWrite(LM1, LOW);

 digitalWrite(LM2, HIGH);

 digitalWrite(RM1, LOW);

 digitalWrite(RM2, HIGH);

 }


 void turnleft

 {

 digitalWrite(LM1, HIGH);

 digitalWrite(LM2, LOW);

 digitalWrite(RM1, LOW);

 digitalWrite(RM2, LOW);

 }


 void turnright

 {

 digitalWrite(LM1, LOW);

 digitalWrite(LM2, LOW);

 digitalWrite(RM1, HIGH);

 digitalWrite(RM2, LOW);

 }


 void robostop

 {

 digitalWrite(LM1, LOW);

 digitalWrite(LM2, LOW);

 digitalWrite(RM1, LOW);

 digitalWrite(RM2, LOW);

 }

###

Circuit diagrams

Circuit Diagram-Arduino-ThingSpeak-IoT-Robot-Temperature-Humidity-Monitoring

Project Technical Sheet

https://www.engineersgarage.com/wp-content/uploads/2019/10/ROBOT_CONTROL.apk_.zip



Project video

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.