Esp8266 based cooling fan project

ESP8266 based Automatic Cooling Fan project with touch LCD control

Automatic cooling machines are widely used in the industries. And in this post, you will learn how to make such a cooling fan using LCD as the display and a temperature sensor with esp8266. The Stepper Motor is used as an actuator(cooling mechanism) here. The temperature sensor and esp8266 communicate through single line communication, whereas the communication mode between esp8266 and the intelligent display is serial communication.

 

Block Diagram and Principle of the Cooling Machine:

Block diagram of ESP8266 based cooling fan
Block diagram of ESP8266 based cooling fan

The function of the cooler is divided into automatic mode and manual mode.

Automatic Mode

In the automatic mode, the temperature threshold can be set on the TFT LCD screen. The current ambient temperature is measured using a DS18B20 temperature sensor and is compared with the set temperature threshold. When it is higher than the current ambient temperature range, esp8266 starts the stepper motor as a cooling function. We can also stop the motor by pressing the STOP button on the LCD display.

Manual Mode

In manual mode, we can use the LCD screen directly and set the rotation speed/ time of the cooling motor. After the setting is made, just click the start button. And just like automatic mode, you can click the stop button to stop the motor instantly.

 

Components Required for the Cooling Machine

In terms of device selection, this project requires a temperature sensor to detect the environmental temperature change. An esp8266 as the main control, one stepper motor as a cooler, and LEDs as indicators. But the most important is the TFT LCD screen used to communicate with the ESP8266.

  1. DS18B20
  2. Esp8266 module
  3. LED lamp X 3
  4. Stepper motor
  5. Stone TFT LCD screen

 

TFT LCD Functions:

  1. For the function of the button switching interface.
  2. The stone TFT LCD can automatically jump to the main interface.
  3. The time setting function.
  4. Data variable distribution
  5. Variable input function.
  6. To display the menu bar selection function.

Esp8266 Functions:

  1. For LED control;
  2. DS18B20 data reading and analysis;
  3. Control the speed and rotation control of the stepper motor.

 

Circuit Diagram

Circuit Diagram of ESP8266 based cooling fan project
Circuit Diagram of ESP8266 based cooling fan project

Introduction to Modules/Components

DS18B20 Temperature sensor

DS18B20 Temperature sensor
DS18B20 Temperature sensor

Temperature sensor DS18B20 is used here which is a commonly used digital temperature sensor. Its:

  • Output is digital
  • Size is small
  • low hardware overhead
  • has a strong anti-interference ability
  • has high precision characteristics

To use the DS18B20 temperature sensor interface, you need to install the one wire library Dallas temperature library.

ULN2003 for Stepper Motor control

Stepper Motor controlled using ULN2003
Stepper Motor controlled using ULN2003

ULN2003 is a Darlington pair driver IC and have high voltage and high current capability. It can be directly connected to TTL and CMOS circuits under 5V working voltage. It can directly process the data that needs a standard logic buffer. Here we are using a DIP-16 package ULN2003 and a 4-phase 5-wire 5V stepper motor.

LED Array

LED Array
LED Array

This is a galloping lamp display module with 8 LEDs. The external voltage is 3 – 5.5 V, and the corresponding LED can be lighted by giving it a LOW or 0 voltage signal. It is suitable for the IO test of a single-chip microcomputer to realize the control of indicator light.

ESP8266 Board

ESP8266 board with ULN2003 module
ESP8266 board with ULN2003 module

Esp8266 can be started directly from the external memory when it is equipped with an application and is the only application processor in the device. The built-in cache memory can improve system performance and reduce memory requirements. In addition, esp8266 has a powerful on-chip processor and storage capacity. This enables it to integrate sensors and other application-specific devices through the GPIO port.

STVC101WT-01 LCD Display

STVC101WT-01 STONE LCD Display
STVC101WT-01 LCD Display

Features of the display:

  • 10.1 inch 1024×600 industrial grade TFT panel and 4-wire resistance touch screen
  • Brightness is 300cd / m2, LED backlight
  • RGB color is 65K
  • Visual area is 222.7mm * 125.3mm
  • Visual angle is 70 / 70 / 50 / 60
  • Working life is 20000 hours. 32-bit cortex-m4 200Hz CPU
  • CPLD epm240 TFT-LCD controller
  • 128MB (or 1GB) flash memory
  • USB port (U disk) download
  • toolbox software for GUI design, simple and powerful hex instructions.

Basic functions of the display

  • Touch screen control / display image / display text / display curve / read and write data / play video and audio. It is suitable for various industries.
  • UART interface is RS232 / RS485 / TTL;
  • Voltage is 6v-35v;
  • power consumption is 3.0w;
  • working temperature is – 20 ℃ / + 70 ℃;
  • air humidity is 60 ℃ 90%.

STVC101WT-01 module communicates with MCU through a serial port, which needs to be used in this project. We only need to add the designed UI picture through the upper computer through the menu bar options to buttons, text boxes, background pictures, and page logic, then generate the configuration file, and finally download it to the display screen to run.

The manual can be downloaded from the official website:

https://www.stoneitech.com/support/download

In addition to the data manual, there are user manuals, common development tools, drivers, some simple routine demos, video tutorials, and some for testing projects.

 

Design and production

Download Arduino IDE:

For programming ESP, Arduino IDE is used to develop and compile the code. First, you need to install the Arduino environment from the link given below:

https://www.arduino.cc/en/Main/Software

After the installation, create a new project. Here we will write the logic code, and then formulate the serial port protocol with TFT LCD, mainly to receive BUF.

 

PC development software tool 2019 for TFT display

To develop our TFT LCD, we need to use a PC development software tool 2019. All operations are carried out on this PC software, which needs to be downloaded from the official website given below:

https://www.stoneitech.com/support/download

1.  Create a New project

Double click on TOOL 2019.exe. To start this project, a new project needs to be created.

  • Click File -> new
  • then in the pop-up new project box, select my screen model as STV, size 1024 * 600
  • set the project name as stone
  • and finally, select the project saving path, and then click OK
  • After that, it will jump to the Blue interface, which is the default background image of the new project.

2.  Add pictures

After creating the new project, it is necessary to add the pictures created in advance. The size of the background image needs to be consistent with the actual size of the screen i.e, 1024 * 600.

Right-click on the picture file and all the 11 pictures required by the project into the pop-up selection box.

3.  Interface settings:

a) RTC: Real-time clock

For displaying the time, we need to add an RTC control here. The screen has the RTC timing function, which can be used to display the local time. The initial time can be written by the MCU, and then the screen can be independently timed.

  • In the first step, select the RTC control clock setting as the button to set the initial test time
  • In the second step, add a time display and place it in the upper right corner.

In the clock setting, the button effect uses picture 2, which requires a keyboard, so the keyboard is set to the eighth picture, and then the eighth keyboard is set.

Select the keyboard area. This area is the keyboard area that pops up when you click the set time button. Other non-selected areas are not visible.

In the customization of the keyboard, take the number 1 as an example, and define the key value in the pop-up keyboard box, and select page 10 for the button effect.

This completes the RTC time setting production.

b) Pop up menu:

In manual mode, it is necessary to set the motor speed in three gears: high, medium, and low. Here is the pop-up menu. The design process is given below:

Click the image tool. Select three small icons under the icon file generator. Then click generate icon file. Finally, an ICO file will appear under the icon file.

After the ICO file is finished, open picture No.6. Click Touch Configuration->Pop up menu.

In the third step, you need to select the “can” area, which is the effect of the actual operation. After that, the value of each icon needs to be calibrated on page 7. There is a one-to-one correspondence between the keys value and the image, and the value of 1 corresponds to the No. 1 Icon.

After that, add a variable icon to the original location. Note that the storage address of the icon should be consistent with the address of the pop-up control. The initial value is set to 1 to display the No. 1 Icon. The icon library uses the 1.ico generated just now and sets the upper and lower limits.

This completes the pop-up menu settings.

c) Page Jump settings:

Here I have made the boot interface effect and the design process is as follows:

Click screen config and change the number in the boot page box to 0, which corresponds to image No. 0. In this way, image No. 0 will be displayed each time the machine is turned on.

After selecting the completion time, you have to enter the mode selection interface. In the mode selection interface, add two-button controls, click the button icon to add. And then set button effect to interface 4, page switch in intelligent mode to corresponding interface 5, and manual mode to interface 6.

This completes the Graphical User Interface design of the project.

 

Program:

if(dataflag == true)
  {
    if(datalen == 13)
    {
        memset(RecievedTemp, 0 , 13);
        for(cout_i = 0; cout_i < 13; cout_i ++)
        {
          RecievedTemp[cout_i] = Serial.read();
        }
        Serial.write(RecievedTemp, 13);
        memset(RecievedTemp, 0 , 13);
        dataflag = false;
    }       
  }
  else if(datalen == 9)
  {
    memset(RecievedTemp, 0 , 9);
    for(cout_i = 0; cout_i < 9; cout_i ++)
    {
      RecievedTemp[cout_i] = Serial.read();
    }
      Serial.write(RecievedTemp, 9);
    switch(RecievedTemp[5])
    {
    case 0x39://temp
      if(HeadStepper.isRunning() == true)
      {

        HeadStepper.stop();    
      }
    StepperStart = false;
//    TempStartStop = true;
    Temperatue = RecievedTemp[8];
      break;
    case 0x2B://temp start
      TempStartStop = true;
      StepperStart = false;
//        HeadStepper_Setting_Run(speed_str[0], 5);
    break;
    case 0x2A://temp stop
      if(HeadStepper.isRunning() == true)
      {
        HeadStepper.stop();  
      }
      TempStartStop = false;
      StepperStart = false;
//      terstop = true;
    break;
    case 0x2E://mode gear
        if(HeadStepper.isRunning() == true)
      {
        HeadStepper.stop();  
      }
        settingbuf[0] = speed_str[RecievedTemp[8]];
        if(RecievedTemp[8] == 3)
      {
      digitalWrite(ledPin_1, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_2, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_3, HIGH);   // turn the LED on (HIGH is the voltage level)
      }
      else if(RecievedTemp[8] == 2)
      {
      digitalWrite(ledPin_1, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_2, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_3, HIGH);   // turn the LED on (HIGH is the voltage level)
      }
      else 
      {
      digitalWrite(ledPin_1, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_2, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_3, LOW);   // turn the LED on (HIGH is the voltage level)
      }
      break;
    case 0x34://mode timing
      if(HeadStepper.isRunning() == true)
      {
        HeadStepper.stop();  
      }
      
        settingbuf[1] = RecievedTemp[8];
        break;
    case 0x2C://mode start
      if(settingbuf[1] == 0)
      {
        settingbuf[1] = 5;
      } 
      TempStartStop = false;
      StepperStart = true;
      HeadStepper_Setting_Run(settingbuf[0], settingbuf[1]);
        break;
    case 0x2D://mode stop
      if(HeadStepper.isRunning() == true)
      {
        TempStartStop = false;
        StepperStart = false;
        HeadStepper.stop();    
      }
        break;
    default:
        break;
    }
   }

 

PROJECT IMAGES

Leave a Reply

Your email address will not be published. Required fields are marked *