Lesson 4: Intelligent Environmental Monitoring Robot

Have you ever imagined what it would be like if the UNIHIKER K10 robot car became an intelligent environmental monitoring robot? It could not only display real-time environmental data such as temperature, humidity, and light levels, but also plot this data into line charts to help us visually observe trends in environmental changes. Now, let’s start from scratch and explore step by step how to bring this practical and fun idea to life!

Task Objective

Display real-time humidity data on the UNIHIKER K10 screen, store the collected humidity data, and plot a line chart to visually show the trend of data changes. Use the voice interaction feature to query the highest and lowest humidity values.

Knowledge Points

1. Learn how to collect and store environmental data.

2. Master chart drawing and visual representation.

3. Understand voice recognition and data interaction logic.

4. Explore trends in smart environmental monitoring.

Materials List

Hardware List:

HARDWARE LIST
1 Maqueen Plus V3
1 UNIHIKER K10

 

Software Used: Mind+ Programming Software (Version V1.8.1 RC1.0 or above) ×1

Download Link: https://mindplus.cc/

 

 

Practical Exercise

This project aims to collect humidity data detected by the humidity sensor and plot it as a line chart. By comparing the data, the maximum and minimum humidity values can be identified. Finally, voice commands will be used to retrieve the maximum and minimum humidity values, and the corresponding data will be displayed on the screen upon successful voice command recognition. To achieve this goal, the project is divided into the following two tasks.

 

Task 1: Plot a line chart of humidity data

Store the real-time monitored humidity data and plot it as a line chart to visually display the trend of data changes.

 

Task 2: Obtain humidity data via voice command

Add voice recognition functionality to enable responses to questions about humidity data. Use voice commands to obtain the maximum and minimum humidity values, and display the current maximum and minimum humidity on the screen upon successful recognition of the voice commands.

 

Task 1: Plot a line chart of humidity data

1. Hardware Connection

Use a USB 3.0 to Type-C data cable to connect the assembled robot car to the computer.

Note: The Type-C end should be connected to the UNIHIKER K10.

 

 

2. Software Preparation

Open Mind+ and complete the software setup as shown in the following illustrations.

 

 
3. Programming

Plotting a line chart, using humidity data as an example.

(1) Drawing the Cartesian coordinate system

To draw a line chart on the UNIHIKER K10 screen, you first need to construct a Cartesian coordinate system. The first step is to use the “set line width/border width to 2” command to set the line width of the coordinate system to 1. Of course, if you think the lines are too thin, you can also set it to 3, 4, and so on.

 

 

Draw the vertical (Y) axis using the "cache draw line from, X1 Y1 to X2 Y2, color" command to create a vertical axis on the screen. The starting coordinate of the Y-axis is (10, 80), and the ending coordinate is (10, 280). Set the line color to black to ensure the axis is clearly visible on the screen.

 

 

Draw the horizontal (X) axis using the same method. Set the starting point of the X-axis to (10, 280) and the ending point to (230, 280). Then use the "show cached content" command to update and show both the X and Y axes on the UNIHIKER K10 screen.

 

 

(2) Plotting Points

After constructing the Cartesian coordinate system, we can start plotting points. Before plotting, make sure to determine the X and Y coordinates of each point. First, create a new variable named “hum_x1” to store the X coordinate of the point, and initialize the value of “hum_x1” to 10.

 

 

 

The Y coordinate of the point represents the humidity data, but the humidity value cannot be used directly as the Y coordinate. This is because the humidity data range far exceeds the screen coordinate range, and the value scale is opposite to the screen’s Y-axis direction. To solve these issues, use the “map”operator to map the humidity value to a corresponding Y coordinate on the UNIHIKER K10 screen.

 

 

Create a new variable named “hum_y1” to store the mapped humidity data. Initialize the value of “hum_y1” with the mapped humidity value.

 

 

Next, use the "cache draw point at X Y color " command to plot the point. The point's X coordinate is the variable “hum_x1”, and the Y coordinate is the variable “hum_y1”. Finally, use the "show cached content" command to update and show the plotted point on the UNIHIKER K10 screen.

 

 

After plotting the first point, the corresponding X coordinate needs to move 10 units to the right. Use the "change hum_x1 by " command to increase the value of hum_x1 by 10.

 

 

(2) Drawing Lines

After successfully plotting the data points, the next step is to use these points to draw a line chart. Use the "cache draw line from X1 Y1 to X2 Y2 color" command to connect the points in sequence to form a polyline.

To determine the start and end coordinates of the line, create two new variables “hum_x2”、 “hum_y2”. The start coordinates of the line (X1, Y1) are the coordinates of the first data point, i.e., (hum_x1, hum_y1). The end coordinates of the line (X2, Y2) are the coordinates of the next data point, i.e., (hum_x2, hum_y2).

At the beginning of the program, under "unihiker k10 on start", initialize the value of “hum_x2” to the value of “hum_x1”, and “hum_y2” to the value of “hum_y1”.

 

 

After confirming both the start and end points of the line, use the "cache draw line from X1 Y1 to X2 Y2 color" command to draw the line. Then, use the "show cached content" command to show the line on the UNIHIKER K10 screen.

 

 

When the next point is updated, the end coordinates of the line also need to be updated. To do this, update the values of “hum_x2” and “hum_y2”.

 

Assign the value of “hum_x1” to “hum_x2”, so that “hum_x2” stores the X coordinate of the previous point.

 

Assign the value of “hum_y1” to “hum_y2”, so that “hum_y2” stores the Y coordinate of the previous point.

 

The purpose of this step is to set the starting point for the new line so that it connects to the previous point.

 

 

4. Program Execution

Before running the program, please make sure that the UNIHIKER K10 is properly connected to the computer via a USB cable. Once the connection is confirmed, click the“Run”button in the software. After the program executes successfully, a Cartesian coordinate system will be drawn on the UNIHIKER K10 screen, and the real-time monitored humidity data will be plotted and displayed as a line chart.

 

 

5. Give It a Try

During the process of drawing the line chart, you may encounter two issues:

 

1. The data points update too quickly, causing the line chart to change rapidly and making it difficult to observe.

 

2. When data points exceed the screen’s X-axis range, the chart continues to draw, which may result in a cluttered display. To solve these problems, you can take the following measures:

 

Slow down the data update speed: Add a suitable delay between data acquisitions to reduce the speed at which new data points are generated. For example, you can insert a short waiting time after reading the humidity value and plotting a new point.

 

Limit the drawing area: To ensure the line chart is drawn only within the coordinate system, you need to either limit the number of data points or restrict the X coordinate value.

 

Task 2: Obtain humidity data via voice command

1. Programming

This task builds upon the "Give It a Try" program from Task One by adding voice wake-up, voice command recognition, and the ability to recognize and report humidity data through voice interaction.

 

(1) Initialize Voice Recognition Function

Under "unihiker k10 on start," use the "set speech recognition wake time ms language" command to initialize the voice recognition mode to continuous, set the wake-up time to 6 seconds, and choose English as the language. This step ensures that the voice recognition module can start properly and enter listening mode after being awakened by the user.

Note: Currently, voice recognition only supports Chinese and English.

 

 

(2) Add Voice Command Keywords

Use the "add voice command id " instruction to assign a unique ID number to each voice command for later recognition and processing. For example:

The command "max humidity" is assigned ID 0.

The command "min humidity" is assigned ID 1.

 

 

(3) Get the Maximum and Minimum Humidity Values

At the beginning of the program, create two variables, “hum_min” and “hum_max”, to store the minimum and maximum humidity values. Use the "read humidity" command to get the initial humidity value and assign it to both “hum_min” and ”hum_max”.

 

 

Create a variable named “hum” to continuously acquire real-time humidity data within the loop.

 

 

Use the "if... then... else" command to compare the values of “hum” and “hum_max”. If “hum” is greater than “hum_max”, update “hum_max” with the value of “hum”.

 

 

Otherwise, when the condition is false, the maximum humidity data remains unchanged. Use the instruction "set  hum_max to" to assign the value of the variable "hum_max" to the variable "hum_max".

 

 

The method of comparing the minimum humidity value is the same as that of comparing the maximum humidity value.

 

 

(4) Obtaining the Maximum and Minimum Humidity Values through Voice Commands

To obtain the maximum and minimum humidity values through voice commands, it must be done after the line charts have been fully drawn. Use the "If... then" instruction to determine whether the "speech recognition awake?" instruction. When the user speaks the preset wake-up phrase "Hi, Telly," the voice recognition function enters the listening state, ready to receive the user's voice commands.

 

 

If the command word ID is detected as 0 (i.e., the user says "max humidity"), then use the "show cached content" instruction to show the highest value as "hum_max" on the screen.

 

 

If the command word ID is detected as 1 (i.e., the user says "min humidity"), then use the "show cached content" instruction to show the minimum humidity as "hum_max".

 

 

The complete program is as follows:

 

 

2. Program Execution

Before running the program, please ensure that the UNIHIKER K10 is correctly connected to the computer via the USB cable. After confirming that everything is correct, click the “Run” button in the software. Once the Program Execution is successful, the UNIHIKER K10 will draw a humidity line chart on its screen. After the line chart is fully drawn, you can wake up the voice recognition by saying “Hi, Telly” and then say the command word “max humidity,” and the screen will display “Max humidit : ”

Note: There are two voice wake-up phrases, which are “Hi, Telly” and “Hi, Jarvis.”

 

 

Knowledge Corner

1. Background and Significance of Intelligent Environmental Monitoring

(1) The Severity of Environmental Issues

With the rapid development of industrialization and urbanization, environmental problems have become increasingly prominent. Phenomena such as air pollution, water quality deterioration, and soil contamination occur frequently, posing serious threats to people's health and quality of life. For example, smoggy weather has led to an increase in the number of patients with respiratory diseases, and the discharge of industrial wastewater has caused severe damage to river ecosystems. Against this backdrop, intelligent environmental monitoring technology has emerged. It is capable of obtaining environmental data in real-time and accurately, providing a scientific basis for environmental governance and protection.

 

 

(2) Limitations of Traditional Environmental Monitoring

Traditional environmental monitoring primarily relies on manual sampling and laboratory analysis, which has many limitations. First, the sampling frequency is low, making it impossible to reflect the dynamic changes in environmental quality in a timely manner. Second, the distribution of sampling points is limited, making it difficult to comprehensively cover the entire monitoring area. Moreover, laboratory analysis takes a long time and cannot meet the needs of rapid decision-making. Intelligent environmental monitoring technology overcomes the shortcomings of traditional monitoring through the use of sensor networks, the Internet of Things (IoT), and big data analysis, achieving automation, intelligence, and real-time monitoring of the environment.

 

 

2. Development Trends of Intelligent Environmental Monitoring

(1) Miniaturization and Integration

With the development of microelectronics and nanotechnology, environmental monitoring sensors are moving towards miniaturization and integration. Miniaturized sensors have the advantages of small size, low power consumption, and low cost, making them easy to install in various locations and enabling the creation of large-area, high-density monitoring networks. Integrated sensor modules can measure multiple environmental parameters simultaneously, improving monitoring efficiency and data completeness. For example, integrating gas sensors, temperature sensors, and humidity sensors onto a single chip allows for comprehensive monitoring of the air environment.

 

 

(2) Intelligence and Adaptability

Future intelligent environmental monitoring systems will possess a higher level of intelligence, capable of automatically recognizing patterns of environmental changes and conducting adaptive monitoring. Through machine learning and artificial intelligence algorithms, the monitoring system can automatically adjust the monitoring frequency and parameters based on changes in environmental data. For example, it can increase the monitoring frequency in areas with poor air quality and decrease it when the environmental conditions are stable, thereby conserving energy and enhancing monitoring efficiency. At the same time, intelligent monitoring systems can also automatically diagnose sensor failures and perform self-repair, improving the system's reliability and stability.

 

(3) Interdisciplinary Integration

The development of intelligent environmental monitoring technology will involve the cross-integration of multiple disciplines, such as environmental science, physics, chemistry, biology, information science, and computer science. Through interdisciplinary collaboration, more advanced and efficient environmental monitoring technologies and equipment can be developed. For example, combining biosensor technology with computer vision technology can enable real-time monitoring of pollutants within living organisms; leveraging the achievements of environmental science and information science can help establish more accurate environmental quality prediction models and decision support systems.

 

 

Challenge Yourself

Since we have already mastered the skill of drawing humidity data line charts, let's challenge ourselves next and try to draw line charts for both light and temperature data at the same time. This will make the environmental monitoring system more comprehensive and practical. Just imagine how exciting it would be to intuitively observe the trends of these three key environmental parameters—temperature, humidity, and light—all on the same screen!

 

 

icon programa.zip 669KB Download(0)
License
All Rights
Reserved
licensBg
0