STONE + TFT LCD Module + Arduino + Smart Bathroom Monitoring System

Development Background

Nowadays, it is the time for intelligence, and people’s demand for quality of life is naturally higher and higher. A variety of intelligent products used in home life, while the bathroom is also the easiest place to relax and eliminate fatigue, here we developed a monitoring system through an intelligent LCD screen, we can monitor the temperature and humidity of the bathroom, according to the temperature and humidity can automatically open the ventilation fan or heating bathroom and other functions to provide a more comfortable and safe environment for bathing.

STONE Smart LCD Introduction

 

STONE Smart LCD is controlled by a 32-bit Cortex-M4 processor, which can be connected to any kind of processor of any model through a serial port and can display rich content with a few simple commands.

STONE provides developers with software called “TOOL BOX”, which can provide rich interactive interfaces such as text, numbers, icons, graphs, keyboards, progress bars, sliders, dials, clocks, data storage, etc. Thus, using STONE Smart LCD allows developers to develop colorful interactive interfaces very easily and with much less development time and cost.

STONE Smart Screen comes with its own software system, so developers do not need to pay attention to the rendering and updating of the screen, nor do they need to pay attention to how the font images are drawn into the layers, so in comparison, the serial screen is very suitable for industrial scenarios.

Product Parameters

Physical   Parameter
Model STVC050WT-01
Size (Inch) 5.0 inch
Resolution 480×RGB×272
Color 65536 colors (16 bit)
Viewing Area 110.9mm× 62.8mm
Pixel Spacing 0.1905mm×0.0635mm (H×V)
Overall Dimension 140mm×80.9mm×13.9mm(N)/15.2mm(T)
Net Weight 195g(N)/200g(T)
 TFT Panel A Class Industry Panel
Touch Screen Industry Level 4 wire   resistance
Or without touch screen is optional.
Backlight   Parameter 
Backlight Type LED
Brightness 350 cd/m2(Brightness can be adjustable in 100 levels.)
Contrast 500:1
Backlight life 20,000 hours
Viewing Angle 70°/ 70°/ 50°/   70°(L/R/U/D)
Working Temperature -20℃~ +70
Working Humidity 55°C, 85%
Storage Temperature -30°C ~ +80°C
Screen Mode Digital
Performance   Parameter
CPU CortexM4
LCD Controller CPLD EPM240
Refresh Rate 200MHz
Picture Switching Speed 19 ms/frame 53 images/s
Flash Memory Standard 128MB, Extension   1GB
Memory Amount for picture According to the   capability of the image, Suggest “JPG” format.
Interface RS232/ RS485/ TTL /USB Interface
Image downloading USB2.0 (12Mbps) & U   storage Disk downloading
Voltage Range DC6.0V ~ 35V (typical value: 12V)
Power 1.3 W
Test Report
MTBF 4,250,000H
Working   Temperature -20°C ~ +70°C
 Air   Humidity 60°C, 90%
Continuous Vibration   Testing 10-55Hz, 1.5mm, 10G
 Impact Acceleration   Testing 6ms, 100G
ESD Testing 10KV
Radiation Reliability   Testing 44W

Introduction to Arduino

Arduino can sense the environment through a variety of sensors, and give feedback and influence the environment by controlling lights, motors and other devices. The micro-controller on the board can be programmed through the Arduino programming language, compiled into a binary file, and burned into the micro-controller. Programming the Arduino is done through the Arduino programming language (based on Wiring) and the Arduino development environment (based on Processing). Arduino-based projects can contain only Arduino, or they can contain Arduino and some other software running on the PC, which communicate with each other (e.g. Flash, Processing, MaxMSP) to achieve this.

Arduino Functional Features

At the beginning of its development, Arduino specifies its application environment and designs an open source and platform to facilitate its secondary development. the main functional features of Arduino are as follows:

  • Open source circuit diagram design. The program development interface is free to download, and can also be modified according to their own needs.
  • Use of low-cost microprocessor controller (ATmega8 or ATmega128). Can use USB interface power supply, no external power supply, or can use external 9VDC input.
  • Supports ISP in-line burn-in to burn Bootloader firmware into the chip. The Arduino controller comes with a Bootloader program, which is the first piece of code that runs after the system is powered on, just like the program in the BIOS of a PC, which performs a self-test, configures the ports, etc. Of course, the micro-controller is set to boot from the boot area by burning the fuse bit. Using this program, you can directly store the program sent from the serial port into the flash area. So, when you use the Arduino compiler environment to download the program, you can first reset the micro-controller and start the Boodoader program to guide the program sent from the serial port to be written into the flash area smoothly, and the flash can be repeatedly burned, so it is very convenient to update the software. With Bootloader, you can update the firmware via serial port or USB to RS232 cable.
  • Based on the official PCB and SCH circuit diagram, the Arduino module can be simplified to complete the independent operation of the microprocessor control.

  • Easy to connect with sensors, various electronic components, such as infrared, ultrasonic, thermistors, photoresistors, servo motors, etc.
  • Support various interactive programs such as Flash, Max/MSP, VVVV, PurEDAta, C, Processin, etc. Use low-cost microprocessor controller.
  • application, using Arduino to breakthrough the past when it can only use the mouse, keyboard, CCD and other input devices of interactive content, now it can be more simple to achieve single or multiplayer game interaction. Arduino functional characteristics make it more and more widely used.

Hardware connection

  • First, disconnect or short J17 as needed, short means use RS232 level for serial communication, disconnect means use TTL level for communication, in order to link the development board more convenient, we use TTL level for communication, so we disconnect J17.

  • Immediately after we give the wisdom of the LCD module power, from the above product parameters can be seen, the wisdom of the LCD drive power range is very wide (6 ~ 35V), which provides great convenience to our hardware design, here we just have a 12V DC power supply, so we will use the 12V power module to the wisdom of the LCD power supply.

Connect the serial port of STM32 development board as shown in the figure, so the hardware connection is completed.

Software design

The software design is divided into two parts in total, one part is the development of the smart LCD module software and the other part is the STM32 program development.

LCD module development

Using the development tools provided by STONE, open “TOOL 2019.exe” with administrator privileges and create a new project, select the appropriate resolution according to your own wisdom LCD resolution, according to the product specifications we know that we use the screen resolution of 480 * 272.

After successful creation you see the following screen:

Right-click to remove the default created 0.jpg and add the four images we created for the background 0.jpg, 1 effect.jpg, 2.jpg, and 3 effect.jpg.

Add the jump button, overlapping on top of the word history, and set the property,  when the button effect button is pressed to display the content, we set it to 1 which is the second picture we draw, for displaying the updated content when the button is pressed, page switch is set to 2, 2 for displaying the history page.

Add two Data Variable controls to display temperature and humidity respectively. Set the temperature memory address to 0x000C, set the humidity memory address to 0x000E, set the integer part to 2-digit display, and set all the decimal parts since we don’t use decimal parts.

Add a real-time clock display, set the time format to year, month, day, hour, minute and second, and set the font size to 24.

Next we design the history page

Add two Real-time curve controls for plotting temperature and humidity history curves, and a back button for returning to the main page.

Set the Real-time curve control properties, Y_Central horizontal axis center coordinate, VD_Central data center value, set the temperature and humidity color to red and green respectively, vertical axis scaling according to the MUL_Y = ( Ye-Ys) * 256 / (Vmax-Vmin) in the  《TOOL2019-User-Devlopment-Guide-200327.pdf》 to calculate the value equal to 512 at this point.

So far the wisdom of the LCD side of the program design has been set up to complete, and then click compile, after the successful compilation, plug the J2 USB port

When the Smart LCD displays the following screen, it means that the screen is ready to download the program.

Click the Online Download button, and then the Download Configuration dialog box will pop up. Since we need to download all of them to the module, we leave all of them unchecked.

After the successful download, we proceeded immediately to the development of the STM32.

Arduino STM32 Development

Arduino IDE is a very convenient development environment, by functionalizing the underlying code, it allow users to develop software without much understanding of the underlying controls, shortening the code and greatly improving the development efficiency. Moreover, Arduino is based on C/C++, its language and development environment are easy to understand, so it is a good choice for beginners. However, the development board chip produced by Arduino is relatively old, the computing power is relatively low, and it is difficult to realize more complex operations. So it will be good to use the Arduino environment on STM32 series from ST semiconductor company. So we are going to use Arduino IDE to develop STM32 software.

Preparing the software

After downloading the Arduino IDE, since we downloaded the free installation version, we can unzip it and run it directly, then extract the Arduino STM32 to the hardware folder of the Arduino IDE

And go to \hardware\Arduino_STM32\drivers\win folder and run install_drivers.bat and install_STM_COM_drivers.bat with administrator privileges to install the driver.

After the installation is finished, you can see that the Arduino IDE has more options for STM32 development boards.

Since Arduino is a cross-platform integrated development environment and has a rich resource section, we directly add the downloaded DTH11 development kit

The specific code is as follows:

#include <dht11.h>

dht11 DHT11;  //Instantiate a DTH11 object

void setup() {

// put your setup code here, to run once:

pinMode(PB0, OUTPUT);         //  LED for status indication

pinMode(PA7, OUTPUT);         //  DHT11 communication pins

Serial1.begin(115200);        //  Initialize serial port 1 for debugging output

Serial2.begin(115200);        //  Initialize serial port 2 for communication with the screen

Serial1.println("HEY YOU");

}




void loop() {

// put your main code here, to run repeatedly:

char values[] = "\xA5\x5A\x05\x82\x00\x0C\x00\x34"; // Communication protocol, the next few bits are placeholders

char curve[] = "\xA5\x5A\x06\x84\x03\x00\x33\x00\x32";




DHT11.read(PA7);                                    // Read DHT11 temperature and humidity

int temp = (float)DHT11.temperature;

int humi = (float)DHT11.humidity;

Serial1.print("Temperature:");                   // print out temperature

Serial1.println(temp);                              // Print temperature results




Serial1.print("Humidity:");                            //Print out Humidity

Serial1.print(humi);                                     //Print out humidity results

Serial1.println("%");                                  //print out %

values[6] = ((temp >> 8) & 0xFF);                   // Temperature high 8 bits

values[7] = (temp & 0xFF);                          // Temperature low 8 bits

Serial2.write(values, 8);

values[5] = 0x0E;                                   // Humidity memory address

values[6] = ((humi >> 8) & 0xFF);                   // Humidity high 8 bits

values[7] = (humi &0xFF);                           //Humidity low 8 bits

Serial2.write(values, 8);

curve[5] = (((temp + 0x32) >> 8) & 0xFF);

curve[6] = ((temp + 0x32) & 0xFF);

curve[7] = (((humi + 0x32) >> 8) & 0xFF);           // Humidity high 8 bits

curve[8] = ((humi + 0x32) &0xFF);                   // Humidity low 8 bits

Serial2.write(curve, 9);

digitalWrite(PB0, HIGH);

delay(500);

digitalWrite(PB0, LOW);

delay(500);

}

After the development is completed, we compile and download, because our hardware is not connected to the USB port, so we use jlink to download, connect the development board and jlink, then upload method select jlink download:

STONE + TFT LCD Module + Arduino + Smart Bathroom Monitoring System Summary and effect picture

Through this project, we can see that STONE smart LCD module not only has a rich GUI development interface, but also can support users to write memory directly, which is convenient for developers to customize functions and greatly shorten the development cycle development cost.

This article submitted by Grey

 

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. I am a tech blogger and an IoT Enthusiast. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning! Follow and send tweets me on @harshvardhanrvm. If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee!

One thought on “STONE + TFT LCD Module + Arduino + Smart Bathroom Monitoring System

  • 1st March 2021 at 7:00 am
    Permalink

    I really like this project.

    Reply

Leave a Reply

%d bloggers like this: