Article Directory
- foreword
- 1. Play with lOT dynamic real-time large screen (offline actual operation)
-
- 1. Astro Light Application Instructions
- 2. Operation steps
-
- 2.1 Activate the device access service
- 2.2 Create a product
- 2.3 Registering Devices
- 2.4 Purchasing a cloud database instance
- 2.5 Purchase an elastic public IP and bind it to a database instance
- 2.6 Configure data forwarding rules
- 2.7 Data reporting and verifying whether the data is forwarded successfully
- 2.8 Data reporting and verifying whether the data is forwarded successfully and the AstroZero service is activated
- 2.9 Build Astro light application
- 2.10 Simulation data reporting and result verification
- 2.11 Resource release
- 2. Playing with the lOT dynamic real-time large screen (sandbox experiment)
- Summarize
foreword
1. What is a charging pile
A charging pile is a device that provides charging services for electric vehicles. Since electric vehicles need to store a large amount of electrical energy to operate, they need to be recharged periodically. Charging piles are equipment produced to meet the charging needs of electric vehicles.
The origin of charging piles can be traced back to the early 1980s, when charging facilities for electric vehicles were very limited. With the popularity of electric vehicles, the demand for charging piles is gradually increasing. The function of the charging pile is to provide electric energy, so that the electric vehicle can be charged, and increase the cruising range of the electric vehicle on the road. Now, charging piles have become one of the important infrastructures for the operation of electric vehicles.
In addition to providing charging services, charging piles also have many other functions. For example, charging piles can monitor electric vehicles to ensure the safety and reliability of the charging process; charging piles can also be connected to the Internet to realize intelligent charging and remote control; in addition, charging piles can also provide various customized services for electric vehicles, For example, time limit, power limit, etc.
2. What is IOT
IOT refers to the Internet of Things (Internet of Things). The Internet of Things refers to the combination of various physical devices, sensors, software, Internet and other technologies. It connects and communicates with each other through the Internet to realize the interconnection and intercommunication between devices, and transmits data to the cloud for processing and analysis, so as to realize the interconnection between devices. Automatic interaction, remote monitoring and control functions.
Simply put, the Internet of Things is to connect all items and devices to the Internet, so that they can communicate and interact with each other, so as to realize more intelligent functions and services. Through the Internet of Things, we can get more accurate, timely, and comprehensive data and information to better meet people's needs and improve production efficiency. For example, smart homes, smart factories, smart cities, etc. are all application scenarios of the Internet of Things.
loT is the bridge from the physical world to the digital world, and the core competitiveness of building industry solutions
3. What is device, edge, cloud and application collaboration
Device, edge, cloud, and application collaboration is a new type of computing architecture that supports computing and data collaboration from device to edge and edge to cloud. Under this architecture, different devices (such as sensors, smart terminals, etc.) can work together with edge computing devices, cloud platforms, and applications to jointly process, store, and analyze data to achieve intelligent decision-making and applications.
Specifically, end refers to devices such as smart terminals and sensors, edge refers to edge computing devices, gateways, etc., cloud refers to cloud computing platforms, and applications refer to various applications. Under this architecture, the end device can upload data to the cloud platform for processing and storage through the edge computing device; it can also obtain data and calculation results from the cloud platform through the edge computing device, and the edge computing device can preprocess the data and Screening, reducing the load of data transmission, and improving data transmission efficiency; applications can obtain data uploaded by edge devices and end devices through the cloud platform, analyze and make decisions, and feed back the results to edge devices and end devices to achieve intelligence control.
The advantage of this architecture is that it can effectively integrate the computing and processing capabilities of different devices, make full use of the advantages of each device, improve the efficiency and accuracy of data processing, and realize intelligent decision-making and applications.
4. What is Astro light application
Astro Light Application is the world's first intelligent light application platform that focuses on user task scenarios. It aims to quickly match user needs with task scenarios through machine learning and other technologies, and provide lightweight application services to help users be more efficient Complete various tasks in work and life efficiently. For example, users can quickly find and use various tools, services and applications through the Astro light application platform, such as booking hotels, ordering meals, buying movie tickets, etc. At the same time, Astro light applications can also help users simplify business processes, improve work efficiency, and achieve a more intelligent working style.
1. Play with lOT dynamic real-time large screen (offline actual operation)
1. Astro Light Application Instructions
1.1 Scenario Description
In IoT solutions, the number of "things" as data subjects may be very large, and the generated data cannot be processed by traditional data processing services. How to analyze and utilize this huge IoT device data is another new challenge for IoT companies.
The HUAWEI CLOUD IoT platform provides the rule engine capability and supports forwarding the data reported by the device to other cloud services of HUAWEI CLOUD. It can store massive data through the cloud database (RDS), and then the Astro light application (AstroZero) can read the data and combine them. Visual components are presented to realize one-stop collection, processing and analysis of data.
In this case, we implement the following scenario: the device reports data to the IoT platform, the IoT platform dumps the data to the cloud database (RDS), and the Astro light application (AstroZero) reads the data from the cloud database (RDS) and combines Visual components for display.
- Device access platform: use a device simulator to connect to the Huawei Cloud loT platform and report data;
- Dump to RDS: Purchase an RDS instance of the cloud database and configure data forwarding rules;
- Build an Astro large-screen application: import project resource packages, modify data sources, and configure component data;
- Linkage verification: The device simulator reports the charging pile order data, and checks the Astro large-screen application data update;
1.2 Tariff Description
The details of Astro tariffs are as follows, and the specific fees are calculated based on the duration of use. This case is expected to be completed in two hours. In order to avoid blocking the experiment due to arrears, you can recharge in advance. After the case is over, please release resources in time to avoid continuous charges.
cloud service | Specification | Billing (¥/h) |
---|---|---|
Device access to IoTDA | Standard Edition Instance - Free Unit - 1 | ¥0.00/h |
ApsaraDB for RDS for MySQL | MySQL-5.7-stand-alone-universal-2-core 4GB / SSD cloud disk- 40GB | ¥0.40/h |
Elastic public IP | Exclusive - full dynamic BGP - billed by bandwidth - 1Mbit/s - 1 | ¥0.08/h |
Cloud Log Service LTS | Pay-as-you-go - within the free quota (500MB/month) | ¥0.00/h |
Application O&M Management AOM | free | ¥0.00/h |
Unified identity authentication service IAM | free | ¥0.00/h |
total | - | ¥0.48/h |
1.3 Overall process
- Create MQTT protocol products, develop product models, and register devices.
- Create data forwarding rules to dump data to the cloud database (RDS).
- Build an Astro light application (AstroZero) to read data from the cloud database (RDS) and display it with visual components.
- Use the device simulator to report data to verify that the Astro light application component data is refreshed in near real time.
2. Operation steps
2.1 Activate the device access service
步骤 1
: Visit the home page of the device access service product , and click "Free Trial".
步骤 2
: According to the interface prompts, enter the instance name and click "OK" to activate the free unit of the standard version instance.
Instance name: custom, such as "freeStandardInstance"
2.2 Create a product
步骤 1
: Enter the device access console , select "Products" in the left navigation bar, click "Create Product" in the upper right corner of the page, fill in the parameters and click "OK".
- Belonging resource control: select the default resource space
- Product name: charging pile
- Protocol type: MQTT
- Data format: JSON
- Device Type Selection: Custom Type
- Device Type: Charging Pile
步骤 2
: A pop-up window prompts "Product creation successful", click "View Details" to enter the product details page.
步骤 3
: Click "Upload Model File", select to add the charging pile model file, and then click "OK" to complete the upload.
Model file file download address: https://mp.csdn.net/mp_download/manage/download/UpDetailed
步骤 4
: The upload is successful, check the definition details of the charging pile model.
View the order attributes defined under the ChargingInfo service, as shown in the figure below.
View the basic properties of the device defined under the BasicInfo service, as shown in the figure below.
2.3 Registering Devices
步骤 1
: Enter the device access console , select "Device > All Devices" in the left navigation bar, click "Register Device" in the upper right corner of the page, fill in the parameters and click "OK".
- Belonging resource space: select the default resource space
- Product: Select "Charging pile"
- Equipment identification code: custom, such as charging_machine_001
- Equipment name: charging pile 001
- Device ID: It is composed of the string prefix automatically generated by the platform + the device identification code, which is automatically filled and does not need to be modified
- Device Authentication Type: Key
- Key/confirmation key: custom, not less than 8 digits, such as 12345678
步骤 2
: A pop-up window prompts "Device created successfully", click "Save and Close" to return to the device list.
The device ID and key information are recorded in the DEVICES-KEY.txt text file downloaded and saved, please keep it safe.
步骤 3
: View the newly registered charging pile device, which is displayed as "inactive".
2.4 Purchasing a cloud database instance
步骤 1
: Visit the product homepage of ApsaraDB for RDS for MySQL , and click Buy Now.
步骤 2
: Purchase a database instance: Fill in the parameter information, and click Create Now.
- Billing mode: Select "Billing on Demand"
- Region: Select "North China-Beijing 4"
- Instance name: custom, such as "rds-charging-demo"
- Database Engine: Select "MySQL"
- Database version: select "5.7"
- Instance Type: Select "Standalone"
- Storage type: SSD cloud disk
- Availability zone: default
- time zone: default
- Performance Specifications: Select "General Purpose" | 2 vCPUs | 4 GB
- Storage space (GB): 40
- Disk Encryption: Select "No Encryption"
- Virtual Private Cloud: Select the default vpc and subnet under the current account, such as "vpc-default" | "subnet-default"
- Database port: fill in the default port, which is "3306"
- Security group: Select the default security group under the current account, such as "Sys-default"; check the security group to confirm that port 3306 has been released.
If the inbound rule of the default security group does not allow port 3306, click Add Rule to allow port 3306.
- Set Password: Select "Set Up Now"
- Administrator account name: root
- Admin Password/Confirm Password: Custom, such as "AstroZero@12#$"
- Parameter template: default, such as "Default-MySQL-5.7"
- Table name case: Select "Case Sensitive"
- Enterprise project: If this option is available, select the default project, such as "default".
- Purchase Quantity: 1
- Read-only instance: not available for purchase
步骤 3
: Login to the database instance:
① It is expected to wait for about 5 minutes, the database instance initialization is complete, and it shows that it is running normally, click "Login".
② Enter the login user name and password, and after the test connection is successful, click "Login" to enter the DAS home page.
- Login user name: the administrator account name created in step 2, such as "root"
- Password: the administrator password created in step 2, such as "AstroZero@12#$"
- Timing acquisition: select "Enable"
- SQL execution record: select "Enable"
步骤 4
: Create a new database: Click "New Database", enter the database name in the pop-up window, and click "OK".
-
Database name: custom, such as "iotda_notify_all"
-
Character set: select "utf8mb4"
步骤 5
: New database table:
① After the database is created, click "New Table" in the database operation column.
② Fill in the basic information and click "Next".
- Table name: custom, such as "charging_order"
- Storage engine: default, namely "InnoDB"
- Charset: default, ie "utf8mb4"
- Validation rules: default, namely "utf8mb4_general_ci"
③ Add fields and click Create Now.
serial number | column name | type | length | empty | primary key | Extended Information |
---|---|---|---|---|---|---|
1 | id | int | 11 | - | √ | autoincrement: on, number options: unsigned |
2 | orderID | varchar | 32 | √ | - | - |
3 | area | varchar | 32 | √ | - | - |
4 | orderTime | varchar | 32 | √ | - | - |
5 | usingPort | varchar | 32 | √ | - | - |
6 | amount | decimal | 32 | √ | - | Default: 0 , number option: unsigned |
7 | receive_time | timestamp | - | - | - | Default value: CURRENT_TIMESTAMP , Update according to current time: ON |
2.5 Purchase an elastic public IP and bind it to a database instance
步骤 1
: Visit the EIP product homepage and click "Use Now".
步骤 2
: According to the interface prompts, after filling in the parameters, click "Buy Now".
- Billing mode: Select "Billing on Demand"
- Region: Select "North China-Beijing 4"
- Line: Select "Full Dynamic BGP"
- Public network bandwidth: select "Based on bandwidth billing"
- Bandwidth size (Mbit/s): 1
- IPv6 conversion: disabled
- DDos protection: default value, that is, "DDoS native basic protection"
- Elastic public IP name: user-defined, optional
- Enterprise project: If this option is available, select the default project, such as "default".
- Purchase Quantity: 1
步骤 3
: After the purchase is complete, enter the web console , and check the elastic public IP you just purchased in the elastic public IP list.
The elastic public network IP resource is shown in the following figure:
步骤 4
: Enter the ApsaraDB for RDS console , click "Instance Name" to enter the instance details page.
步骤 5
: Select "Connection Management" in the left navigation bar, click "Bind" in the public network address bar in the right connection information area, select the elastic public network IP you just purchased in the pop-up window, and click "Yes" to complete the binding Certainly.
The binding is completed, and the result is as shown in the figure below:
2.6 Configure data forwarding rules
步骤 1
: Enter the device access console , select Rules > Data Forwarding in the left navigation bar, and click Create Rule.
步骤 2
: Set forwarding data.
① Fill in the basic information:
- Rule name: Charging pile dumps MySQL
- Data source: device properties
- Trigger event: device attribute reporting
- Resource space: select the default resource space, such as "DefaultApp_xxx***"
Note: Only if a single resource space is selected here, the "Quick Configuration" option will appear in the "Data Filter Statement" area.
② Configure data filtering statement:
Click "Quick Configuration", check "Data that meets the following selected conditions", select "Charging Pile" for "Product", and click "OK".
③ Click "Create Rule", a pop-up window will prompt "Rule Created Successfully", click "Continue Setting" to enter the setting of forwarding target.
步骤 3
: Set forwarding target.
① Click "Add", fill in the forwarding target information, and then click "Next: Forwarding Data Configuration", and the database will be connected.
- Forwarding target: select "MySQL database"
- Database instance address: Fill in the elastic public network IP bound to the database instance in Purchase elastic public IP and bind the database instance and the database instance access port configured when purchasing the cloud database instance, such as 121. . .67 : 3306
- Database name: fill in the newly created database when purchasing the cloud database instance, such as iotda_notify_all
- Access account: Fill in the login account of the database instance configured when purchasing the cloud database instance, such as root
- Access password: fill in the login password of the database instance configured when purchasing the cloud database instance, such as AstroZero@12#$
- SSL: It is not enabled in this experiment, that is, it is turned off. When choosing to connect via SSL, you need to set SSL data encryption in the database instance first
② Select the transfer table, configure the mapping relationship between the transfer data and the database table, and then click "OK".
- Transfer to table: select the data table used to store data in the database, such as charging_order
- Dump configuration:
forward field | target storage field |
---|---|
Description: The parameter path that needs to be dumped in the transfer data. | Description: The field of the database table, after selecting the target storage field, it will automatically match the field type. |
notify_data.body.services[0].properties.orderID | orderID |
notify_data.body.services[0].properties.area | area |
notify_data.body.services[0].properties.orderTime | orderTime |
notify_data.body.services[0].properties.usingPort | usingPort |
notify_data.body.services[0].properties.amount | amount |
③ A pop-up window prompts "Operation successful", click "Setting complete".
步骤 4
: Click Start Rule to activate the configured data forwarding rule.
The interface displays "rule running", click the return arrow in the upper left corner to return to the rule list.
Click the small arrow in the upper left corner to return to the list of data forwarding rules and view the rules just created, as shown in the following figure:
2.7 Data reporting and verifying whether the data is forwarded successfully
步骤 1
: Connect to the platform using the MQTT simulator.
① Download the simulator and double-click to run it to start the device simulator.
Download address: https://obs-pipeline.obs.cn-north-4.myhuaweicloud.com/sdkDeploy/simulator/MQTT_Simulator.zip
② Configure the connection parameters, and then click "Connect". If the log prompts "connect to mqtt server success...", it means the connection is successful.
- SSL Connection: Use port 1883 if unchecked, and port 8883 if checked. Tick in this case.
- Server Address: Obtained from the device access console, instance access information page, such as ***.st1.iotda-device.cn-north-4.myhuaweicloud.com
- Device ID: The device ID obtained after successfully registering the device.
- Device Secret: The device key obtained after successfully registering the device.
步骤 2
: Use the simulator to report attributes.
In the input box at the bottom of the simulator window, fill in the report content, and then click "Publish". If the log prompts "... is published success", it means the report is successful.
Examples of reported content are as follows:
{
"services": [{
"properties": {
"orderID": "0000005",
"area": "武汉",
"orderTime": "20230117T192335Z",
"usingPort": "07",
"amount": 32.5
},
"service_id": "ChargingInfo",
"event_time": null
}]
}
步骤 3
: Go to the device access console , select "Device > All Devices" in the left navigation bar, and click the device identification code to enter the device details page.
You can see that the device is online, and the attribute values reported by the device are normally displayed in the "Latest Reported Data" area.
步骤 4
: Go to the ApsaraDB for RDS console , log in to the database instance, open Database > Data Table, and check whether a record is generated in the forwarding target data table.
① Click "Login" to jump to the "Instance Login" window.
② Enter the login user name and password, check "Remember Password", click "Test Connection", and click "Login" after the prompt "Connection is successful".
- Timing collection: Enable on demand, select Enable in this case.
- SQL Execution Record: Enable as needed, select Enable in this case.
③ Click the database name to enter the database management interface.
④ Click "Open Table" to open the database table.
⑤ You can see that a record has been generated in the database table, which is consistent with the property value reported by the device.
2.8 Data reporting and verifying whether the data is forwarded successfully and the AstroZero service is activated
步骤 1
: Visit the homepage of the Astro light application product , click "Use Now" to enter the Astro light application console.
步骤 2
: Click "Free Trial" in the upper right corner of the page, and confirm "Free Trial" in the pop-up window.
步骤 3
: Wait for the free version of the shared instance to be opened successfully, and click "Enter the homepage" to enter the homepage of Astro light application development.
The preview of the home page of Astro light application development is shown in the following figure:
2.9 Build Astro light application
步骤 1
: Enter the Astro light application console , on the example page, click "Enter Home" to enter the new version of the application development environment.
步骤 2
: On the "Application Development" page, click "Business Screen" on the left navigation bar to enter the Astro Canvas interface.
步骤 3
: Import project: Click "Import Project Package", select the "AstroCanvas_Smart Charging Station" project package, and "Open".
AstroCanvas_Smart charging pile file download address: https://mp.csdn.net/mp_download/manage/download/UpDetailed
The project package is imported successfully, and the preview of the project card is shown in the figure below:
步骤 4
: Modify the data source: Switch to the "Data Center" tab, select "Data Source Management" in the left navigation bar, and click the "iot-mysql-data" data source card.
After modifying the parameters, click "Connection Test" first, and then click "Save" after confirming that the connection is successful.
- Data source: relational database
- Data source name: custom, such as "iot-mysql-data"
- Database type: MySQL
- Domain name: Fill in the elastic public IP that is bound to the database instance in Purchase elastic public IP and bind the database instance, such as 121. . .67
- Port: Fill in the database instance access port configured when purchasing the cloud database instance, such as 3306
- Username: fill in the login account of the database instance configured when purchasing the cloud database instance, such as root
- Password: Fill in the login password of the database instance configured when purchasing the cloud database instance, such as AstroZero@12#$
- Database name: fill in the newly created database when purchasing the cloud database instance, such as iotda_notify_all
步骤 5
: Modify dataset: Select "Dataset Management" on the left navigation bar, and click the dataset card to modify.
① Modify the "Total Order Amount" data set, fill in the parameters, and refresh the data preview OK, then click "Save".
-
Data source: relational database
-
Data source connection: the data source just created in step 5, such as "iot-mysql-data"
-
Dataset name: custom, such as "total order amount"
-
Category: Select "Order Amount"
-
Data Configuration: Select "SQL Mode"
-
Select the data table: select "charging_order"
-
SQL query statement:
select sum(amount) as totalCoast, count(amount) as totalNum from charging_order
② Modify the "Daily Order Amount" dataset, fill in the parameters, and refresh the data preview OK, then click "Save".
-
Data source: relational database
-
Data source connection: the data source just created in step 5, such as "iot-mysql-data"
-
Dataset name: custom, such as "daily order amount"
-
Category: Select "Order Amount"
-
Data Configuration: Select "SQL Mode"
-
Select the data table: select "charging_order"
-
SQL query statement:
select substring(orderTime, 1, 8) as orderDate, count(orderTime) as orderNum, sum(amount) as orderCoast from charging_order group by orderDate
③ Modify the "regional order amount" data set, fill in the parameters, and refresh the data preview OK, then click "Save".
-
Data source: relational database
-
Data source connection: the data source just created in step 5, such as "iot-mysql-data"
-
Dataset name: custom, such as "regional order amount"
-
Category: Select "Order Amount"
-
Data Configuration: Select "SQL Mode"
-
Select the data table: select "charging_order"
-
SQL query statement:
select area, count(area) as num, sum(amount) as coast from charging_order group by area
步骤 6
: Configure component data: switch back to the "Project List" tab, click the project card, and select the "Smart Charging Pile Operation Monitoring Large Screen" page, and then click "Edit Page" to enter the editing state.
Refer to the numbering sequence in the figure below, select components in turn, and click to enter the component data configuration page to complete the data configuration.
① Configure the "City Charging Times/Amount" component data:
- Data Type: Dataset | Select "Regional Order Amount"
- Component preview-configuration: X-axis data-area | Y-axis data-coast&num | Refresh period-10 seconds
② Configure the component data of "City Charging Times Proportion":
- Data Type: Dataset | Select "Regional Order Amount"
- Component preview-configuration: data-num | data category-area | refresh cycle-10 seconds
③ Configure the component data of "City Settlement Amount Ratio":
- Data Type: Dataset | Select "Regional Order Amount"
- Component preview-configuration: data-coast | data category-area | refresh cycle-10 seconds
④ Configure the "daily charging times/amount" component data:
- Data Type: Dataset | Select "Daily Order Amount"
- Component preview-configuration: X-axis data-orderDate | Y-axis data-orderNum&orderCoast | Refresh period-10 seconds
⑤ Configure the "Accumulated Charging Times" component data:
- Data Type: Dataset | Select "Total Order Amount"
- Component Preview-Configuration: Baseline Number-totalNum | Refresh Period-10s
⑥ Configure the "Accumulated Settlement Amount" component data:
- Data Type: Dataset | Select "Total Order Amount"
- Component Preview-Configuration: Baseline Number-totalCoast | Refresh Period-10s
步骤 7
: After editing, click "Save", and then click "Preview" to view the effect on the large screen.
"Save (Ctrl+S)" and "Preview (Ctrl+P)" buttons on the top menu bar, as shown by the arrow marks in the figure below.
View the large-screen display effect, as shown in the following figure:
2.10 Simulation data reporting and result verification
步骤 1
: Refer to data reporting and verify whether the data is forwarded successfully, and report more charging pile order data.
- Please customize and modify the sample value before reporting. For example, the orderID is changed to 0000002, the area is changed to Changsha, the orderTime is changed to 20230515T171215Z, the usingPort is changed to 11, and the amount is changed to 28.5.
- In order to present the diversity of data in the Astro large-screen application, please make custom modifications and report no less than 5 pieces of sample data.
Sample report content:
{
"services": [{
"properties": {
"orderID": "0000002",
"area": "长沙",
"orderTime": "20230515T171215Z",
"usingPort": "11",
"amount": 28.5
},
"service_id": "ChargingInfo",
"event_time": null
}]
}
步骤 2
: Wait for about 10 seconds, check the large screen of the Astro light application, and the data refresh display is normal.
2.11 Resource release
After the experiment is completed, please release the billing resources in time to avoid unnecessary charges.
2.11.1 Delete device
Enter the device access console , select "Device > All Devices" in the left navigation bar, select the registered device, click "Delete", and click "Yes" in the pop-up window to complete the deletion.
2.11.2 Delete a product
Enter the device access console , select "Products" in the left navigation bar, select the created product, click "Delete", and click "Confirm" in the pop-up window to complete the deletion.
2.11.3 Delete EIP
步骤 1
: Enter the ApsaraDB for RDS console , click "Instance Name" to enter the instance details page.
步骤 2
: Select "Connection Management" in the left navigation bar, and in the connection information area on the right, click "Unbind" in the public network address bar, and click "Yes" in the pop-up window to complete the unbind.
After the elastic public network IP is successfully unbound, as shown in the following figure:
步骤 3
: Enter the network console , select the elastic public IP purchased in this experiment in the elastic public IP list, click "Unbind > Release", and click "Yes" in the pop-up window to complete the release.
2.11.4 Delete the cloud database instance
Enter the ApsaraDB for RDS console , select "Instance Management" in the left navigation bar, click "More > Delete Instance", and click "Yes" in the pop-up window to complete the deletion.
2.11.5 Delete Astro light application
Enter the Astro Canvas interface , select the "Smart Charging Station" project card, click the "Delete" button, and click "Confirm" in the pop-up window to complete the deletion.
2. Playing with the lOT dynamic real-time large screen (sandbox experiment)
Cloud experiment platform address: https://lab.huaweicloud.com/testdetail_2312?ticket=ST-8521673-Y1iBbVulXQ16TdWUYY3ZirlY-sso
First, the experimental environment must be preset
Enter [Experimental Operation Desktop], open a browser and enter the HUAWEI CLOUD login page. Select [IAM user login] mode, and enter the HUAWEI CLOUD experimental account and password assigned by the system to log in to HUAWEI CLOUD in the login dialog box, as shown in the figure below: Note: For account information, see the top of the experiment manual, do not use your own Log in with a HUAWEI CLOUD account.
1. Device access platform
1.1 Open the standard version free unit
① On the console overview page, enter the keyword "iotda" to search, select "Device Access IoTDA" in the result list, and enter the device access console.
② On the left navigation bar, click "Switch", select the standard version, and click "Activate Free Unit".
Note: If you have subscribed to the IoTDA Standard Edition free unit, please go to the instance details page to unsubscribe, and then re-activate.
③ A pop-up window prompts "Standard Edition instances are free to use", click "OK" to complete the activation.
√ Instance name: Just use the default value, namely freeStandardInstance
④ Click "Switch Instance" on the right side of the Standard Edition instance tab to switch and use the Standard Edition instance.
1.2 Create a product
① Select "Products" in the left navigation bar, click "Create Product" in the upper right corner of the page, fill in the parameters and click "OK".
√ Belonging resource control: select the default resource space
√ Product Name: Charging Pile
√ Protocol type: MQTT
√ Data format: JSON
√ Device type selection: custom type
√ Equipment type: charging pile
② A pop-up window prompts "Product creation successful", click "View Details" to enter the product details page.
1.3 Import product model
① Go back to the experimental desktop and double-click "Xfce Terminal" to open Terminal, and enter the following command to download and save the product model file to the local desktop.
cd Desktop/
wget https://iot-tools.obs.cn-north-4.myhuaweicloud.com/charging-station/Charging_Profile.zip
The downloaded and saved product model files are as follows:
② Go back to the product details page, click "Upload Model File" on the "Model Definition" tab, select to add the charging pile model file, and click "OK" to complete the upload.
③ The upload is successful, check the definition details of the charging pile model.
View the order attributes defined under the ChargingInfo service, as shown in the figure below.
View the basic properties of the device defined under the BasicInfo service, as shown in the figure below.
1.4 Registering Devices
① Select "Device > All Devices" in the left navigation bar, click "Register Device" in the upper right corner of the page, fill in the parameters and click "OK".
√ Belonging resource space: select the default resource space
√ Product: Select the product created in the previous step, that is, the charging pile
√ Equipment identification code: custom, such as charging_machine_001
√ Equipment name: charging pile 001
√ Device ID: It is composed of the string prefix automatically generated by the platform + the device identification code, which is automatically filled and does not need to be modified
√ Device Authentication Type: Key
√ Key/confirmation key: custom, not less than 8 digits, such as 12345678
② A pop-up window prompts "Device created successfully", click "Save and Close" to return to the device list.
The device ID and key information are recorded in the DEVICES-KEY.txt text file downloaded and saved, please keep it safe.
③ Check the newly registered charging pile device, which is displayed as "inactive".
1.5 Devices report data
① Go back to the experimental desktop and double-click "Xfce Terminal" to open Terminal, enter the following command to download and save "HubSimulator.jar" to the local desktop.
cd Desktop/
wget https://sandbox-expriment-files.obs.cn-north-1.myhuaweicloud.com:443/20221019/HubSimulator.jar
② Continue to execute the following command to open the device access simulator (HubSimulator.jar), and then switch to the MQTT device simulator tab.
/usr/local/share/jre1.8.0_181/bin/java -jar HubSimulator.jar
③ Under the MQTT Device Simulator tab, after configuring the following parameters, click the "Establish Connection" button.
√ Service IP: Enter the device access console, select "Overview" in the left column, click "Access Information", and copy the domain name using MQTT/MQTTS access information.
√ Device ID/Device Key: The device ID and key returned after successfully registering the device. Go back to the experimental desktop and double-click "Xfce Terminal" to open Terminal, and enter the following command to obtain:
cat /home/user/Downloads/DEVICES-KEY.txt
After the connection is successfully established, the log on the right shows that the MQTT service connection is successful. Back to the list of all IoT devices, the status of the device changes to "Online", as shown in the figure below:
④ On the Send Message tab in the emulator window, fill in the Topic and the reported message sample, and then click "Send Message".
Enter the following code in the Topic column under the Send Message tab:
$oc/devices/{
device_id}/sys/properties/report
where {device_id}
needs to be replaced with the actual device ID.
Enter the following code in the message editing field, that is, an example of the reported content is as follows:
{
"services": [{
"properties": {
"orderID": "0000005",
"area": "武汉",
"orderTime": "20230117T192335Z",
"usingPort": "07",
"amount": 32.5
},
"service_id": "ChargingInfo",
"event_time": null
}]
}
Click Send Message. After the message is sent successfully, the log on the right shows that the message is pushed successfully (the picture is only for illustration, please refer to the actual reported data).
⑤ Return to the device list page, click the device identification code to enter the device details page. You can see that the device is online, and the attribute values reported by the device are normally displayed in the "Latest Reported Data" area.
2. Dump data to RDS
2.1 Log in to the database instance
① On the console overview page, enter the keyword "rds" to search, select "Cloud Database RDS" in the result list, and enter the cloud database RDS console.
② The initialization of the database instance is completed, and it shows that it is running normally, click "Login".
③ Enter the login user name and password, and after the test connection is successful, click "Login" to enter the home page of the data management service DAS.
√ Login user name: the user name of the cloud database RDS instance in the preset experimental environment, such as "root"
√ Password: the password of the cloud database RDS instance in the preset experimental environment
√ Timing acquisition: select "Enable"
√ SQL execution record: select "Enable"
2.2 Import database table
① Go back to the experimental desktop and double-click "Xfce Terminal" to open Terminal, and enter the following command to download and save the database resource package to the local desktop.
Note: Be sure to double-click "Xfce Terminal" to open a new Terminal window, and prohibit operations in the Terminal window running the device emulator.
cd Desktop/
wget https://iot-tools.obs.cn-north-4.myhuaweicloud.com/charging-station/DAS_Imexport_Export_all_sql.tar.gz
Continue to execute the following commands to decompress and obtain the SQL import script.
tar -zxvf DAS_Imexport_Export_all_sql.tar.gz
Unzip the obtained SQL script file, as shown in the following figure:
② Go back to the DAS home page, click "New Database", enter the database name in the pop-up window, and click "OK".
√ Database name: custom, such as "iotda_notify_all"
√ Character set: select "utf8mb4"
③ In the top navigation bar, select "Import·Export > Import", click "New Task", fill in the parameters and create an import task.
√ Import type: sql
√ File source: Upload file
√ Attachment storage location: Click "Create OBS Bucket" on the right and fill in the bucket name in the pop-up window, such as obs-xxx, to complete the creation; then select the newly created OBS bucket
√ Select attachment: upload the SQL execution script file just downloaded and decompressed
√ Database: Select the newly created database, such as iotda_notify_all
√ Character Set: Select "Auto Detect"
√ Options: Both items can be ticked
④ The pop-up window prompts as follows, click "OK".
⑤ After the import task is completed, return to the home page, click the library name to enter the library management list, and the preview of the expanded table is shown in the figure below:
2.3 Bind the elastic public network IP
① Switch to the ApsaraDB for RDS console, and click "Instance Name" to enter the instance details page.
② Select "Connection Management" in the left navigation bar, click "Bind" in the public network address bar in the right connection information area, select the preset elastic public network IP in the pop-up window, and click "Yes" to complete the binding Certainly.
The binding is complete, and the result is shown in the figure below:
③ Scroll down to the security group rules, select the "sg-hce" tab, view the inbound rules, click "Add Inbound Rules", and select "MySQL (3306)", and then click OK to release.
2.4 Configure data forwarding rules
① Switch to the device access console, select "Rules > Data Forwarding" in the left navigation bar, and click "Create Rule".
② Set forwarding data: After filling in the basic information and configuring the data filtering statement, click "Create Rule".
√ Rule name: charging pile dump MySQL
√ Data source: device attributes
√ Trigger event: device attribute reporting
√ Resource space: select the default resource space, such as "DefaultApp_xxx***"
Note: Only if a single resource space is selected here, the "Quick Configuration" option will appear in the "Data Filter Statement" area.
√ Data filtering statement: Click "Quick Configuration", check "Data that meets the following selected conditions", select "Charging Pile" for "Product", and click "OK".
③ A pop-up window prompts "The rule was created successfully", click "Continue to setup" to enter the setting of the forwarding target.
④ Set forwarding target: Click "Add" to fill in the forwarding target information.
√ Forwarding target: select "MySQL database"
√ Database instance address: fill in the elastic public network IP bound to the database instance and the database instance access port (ie 3306), such as 121. . .67:3306
√ Database name: Obtain the database name from the DAS console of the data management service, such as iotda_notify_all
√ Access account/access password: fill in the login account and password of the database instance, and obtain it from the preset environment information
√ SSL: It is not enabled in this experiment, that is, it is turned off.
After the configuration is complete, click "Next: Forwarding Data Configuration" to connect to the database. Select the transfer table, configure the mapping relationship between the transfer data and the database table, and click OK.
√ Transfer to table: select the data table used to store data in the database, such as charging_order
√ Transfer configuration: first select the target storage field, and then fill in the forwarding field, the corresponding relationship is as follows:
The target storage field is orderID, and the corresponding forwarding fields are as follows:
notify_data.body.services[0].properties.orderID
The target storage field is area, and the corresponding forwarding fields are as follows:
notify_data.body.services[0].properties.area
The target storage field is orderTime, and the corresponding forwarding fields are as follows:
notify_data.body.services[0].properties.orderTime
The target storage field is usingPort, and the corresponding forwarding fields are as follows:
notify_data.body.services[0].properties.usingPort
The target storage field is amount, and the corresponding forwarding fields are as follows:
notify_data.body.services[0].properties.amount
⑤ A pop-up window prompts "Operation successful", click "Setting complete".
⑥ Click "Start Rules" to activate the configured data forwarding rules.
The interface displays "rule running", click the return arrow in the upper left corner to return to the rule list.
2.5 Verify data forwarding results
① Go back to the MQTT device simulator window and report the data again.
Enter the following code in the Topic column under the Send Message tab:
$oc/devices/{
device_id}/sys/properties/report
where {device_id}
needs to be replaced with the actual device ID.
Enter the following code in the message editing field, that is, an example of the reported content is as follows:
{
"services": [{
"properties": {
"orderID": "0000005",
"area": "武汉",
"orderTime": "20230117T192335Z",
"usingPort": "07",
"amount": 32.5
},
"service_id": "ChargingInfo",
"event_time": null
}]
}
Click Send Message.
② Go back to the DAS homepage of the data management service, click the database name, and enter the database management page.
③ Click "Open Table" to open the database table.
You can see that a record has been generated in the database table, which is consistent with the property value reported by the device.
3. Build Astro large-screen application
3.1 Activate AstroZero service
① On the console overview page, enter the keyword "Astro" to search, select "Astro Light App" in the result list, and enter the Astro Light App console.
② Click "Free Trial" in the upper right corner of the page, and confirm "Free Trial" in the pop-up window.
Note: If you have opened the free trial of Astro Light App, just go to the next step and "enter the home page".
③ Wait for the free version of the shared instance to be opened successfully, click "Enter Homepage" to enter the homepage of Astro light application development.
The preview of the home page of Astro light application development is shown in the following figure:
3.2 Import project package
① On the "Application Development" page, click "Business Screen" on the left navigation bar to enter the Astro Canvas interface.
② Go back to the experimental desktop and double-click "Xfce Terminal" to open Terminal, and enter the following command to download and save the project package to the local desktop.
Note: Be sure to double-click "Xfce Terminal" to open a new Terminal window, and prohibit operations in the Terminal window running the device emulator.
cd Desktop/
wget https://iot-tools.obs.cn-north-4.myhuaweicloud.com/charging-station/AstroCanvas_ChargingSmartScreen.zip
③ Return to the Astro Canvas interface, click "Import Project Package", select the project package you just downloaded, and "Open".
The project package is imported successfully, and the preview of the project card is shown in the figure below:
3.3 Modify data source
① Continue on the Astro Canvas interface, switch to the "Data Center" tab, select "Data Source Management" in the left navigation bar, and click the "iot_mysql_data" data source card.
② After modifying the parameters, click "Connection Test" first, and then click "Save" after confirming that the connection is successful.
√ Domain name: fill in the elastic public network IP bound to the database instance, such as 121. . .67
√ Port: fixed to 3306
√ Username/Password: Fill in the login account and password of the database instance, obtained from the preset environment information
√ Database name: Obtain the database name from the DAS console of the data management service, such as iotda_notify_all
3.4 Modify the dataset
① Continue under the "Data Center" tab, select "Dataset Management" in the left navigation bar, and click the dataset card to modify.
② To modify the "Total Order Amount" data set, click "Refresh Data" directly, the data preview on the right is OK, and then click "Save".
√ SQL query statement:
select sum(amount) as totalCoast, count(amount) as totalNum from charging_order
Note: The data preview results in the legend are just samples, please refer to the actual data.
③ To modify the "Daily Order Amount" dataset, click "Refresh Data" directly, the data preview on the right is OK, and then click "Save".
√ SQL query statement:
select substring(orderTime, 1, 8) as orderDate, count(orderTime) as orderNum, sum(amount) as orderCoast from charging_order group by orderDate
Note: The data preview results in the legend are just samples, please refer to the actual data.
④ Modify the "Regional Order Amount" data set, click "Refresh Data" directly, the data preview on the right is OK, and then click "Save".
√ SQL query statement:
select area, count(area) as num, sum(amount) as coast from charging_order group by area
Note: The data preview results in the legend are just samples, please refer to the actual data.
3.5 Configure component data
① Continue on the Astro Canvas interface, switch back to the "Project List" tab, click the "Smart Charging Pile" project card, and select the "Smart Charging Pile Operation Monitoring Large Screen" page, and then click "Edit Page" to enter the editing state .
② Referring to the number identification in the figure below, check each component in turn, and the order data has been loaded and displayed.
Note: If the components marked in the figure below do not load and display order data, please enter the component data configuration page, and refer to "Questions and Answers" to correct the associated data set.
Take the data configuration of the "City Charging Times/Amount" component data as an example, the preview is as shown in the figure below:
√ Data Type: Dataset | Select "Regional Order Amount"
√ Component preview-configuration: X-axis data-area | Y-axis data-coast&num | Refresh period-10 seconds
3.6 Check the big screen effect
① After editing, click "Save", and then click "Preview" to view the effect on the large screen.
"Save (Ctrl+S)" and "Preview (Ctrl+P)" buttons on the top menu bar, as shown by the arrow marks in the figure below.
② View the display effect on the large screen, as shown in the figure below:
Note: The following large-screen data is just a sample, please refer to the actual reported data presentation results.
4. Linkage test
① Go back to the MQTT device simulator window and report more charging pile order data.
In order to present the diversity of data in the Astro large-screen application, please make custom modifications and report no less than 5 pieces of sample data.
Enter the following code in the Topic column under the Send Message tab:
$oc/devices/{
device_id}/sys/properties/report
The {device_id} needs to be replaced with the actual device ID.
Enter the following code in the message editing field, that is, an example of the reported content is as follows:
√ Modify orderID to 0000002
√ Modify area to Changsha
√ Modify orderTime to 20230515T171215Z
√ Modify usingPort to 11
√ Modify the amount to 28.5
Tip: Please customize and modify, and report different content multiple times.
{
"services": [{
"properties": {
"orderID": "0000002",
"area": "长沙",
"orderTime": "20230515T171215Z",
"usingPort": "11",
"amount": 28.5
},
"service_id": "ChargingInfo",
"event_time": null
}]
}
② After clicking "Send Message", wait for about 10 seconds, check the large screen of the Astro light application, and the data refresh display is normal.
Note: The following large-screen data is just a sample, please refer to the actual reported data presentation results.
So far, the entire operation experience of quickly building the Astro large-screen application of the IoT charging pile has been completed.
Summarize
This article mainly uses HUAWEI CLOUD related services:
设备接入服务:
HUAWEI CLOUD device access service is a device access cloud platform service provided by HUAWEI CLOUD. Through this service, users can connect their devices to HUAWEI CLOUD to realize cloud storage, management and analysis of device data. HUAWEI CLOUD device access service provides a wealth of interfaces and protocol support to meet the access requirements of different types of devices, while providing safe and reliable data communication and storage guarantees. Users can also use other services of HUAWEI CLOUD, such as the Internet of Things platform, artificial intelligence platform, etc., to realize the development and deployment of intelligent equipment and applications.RDS云数据库:
HUAWEI CLOUD RDS (Relational Database Service) cloud database is a cloud-based computing technology that provides high availability, high scalability, secure and stable relational database services. Users can easily manage, configure, and use cloud databases through the console, API, or command line to realize functions such as rapid deployment, efficient backup and recovery, real-time monitoring, and automatic capacity expansion. Multiple database engines are supported, including MySQL, SQL Server, PostgreSQL, and PPAS. At the same time, HUAWEI CLOUD RDS can provide reliable disaster recovery backup, data encryption, and security audit functions, providing enterprises with a stable, secure, and efficient cloud database service.弹性公网IP:
HUAWEI CLOUD elastic public IP refers to a public IP address that can be dynamically bound to cloud resources such as cloud hosts and load balancing. It uses the BGP protocol to realize dynamic routing, which can realize flexible traffic management and load balancing, supports bandwidth expansion on demand, and can meet users' high availability and high bandwidth requirements for public network access. In addition, HUAWEI CLOUD elastic public network IP also supports IPv6 and IPv4 dual-stack mode, which can meet the network requirements of different users.Astro轻应用:
HUAWEI CLOUD Astro Light App is an application development framework based on the HUAWEI CLOUD PaaS platform, designed to help developers quickly build lightweight, efficient, flexible, and secure enterprise-level applications. With Astro Light Apps, developers can easily build web-based applications and quickly deploy them on Huawei Cloud to achieve fast launch, high availability, and elastic expansion. Astro light application also provides a wealth of development tools and development process support to help developers develop applications efficiently and reduce development costs.
Among them, the device access service is mainly responsible for receiving the data uploaded by the MQTT protocol of the IoT device, forwarding it to the RDS cloud database (elastic public network IP is required to receive it), and finally the Astro light application reads the data in the RDS cloud database for large-scale screen display.
The large screen for real-time monitoring of charging piles can monitor and manage the operation of charging facilities in real time, including:
-
Real-time monitoring of the usage of charging piles, statistics and analysis of charging piles, and operation data for operators to make decisions to optimize the layout of charging piles.
-
Display the location information of the charging pile, which is convenient for users to find and select the nearest charging station, improving user experience and convenience.
-
Through the real-time monitoring of the large screen, the management personnel can detect the faults and abnormalities of the charging pile in time, repair and deal with the charging pile in time, and improve the working efficiency and utilization rate of the charging pile.
-
The real-time monitoring large screen of the charging pile can count key indicators such as the charging amount and charging speed of the charging pile, and provide optimization and improvement plans for the operation of the charging pile.
-
Displaying the overall situation of urban charging stations has important implications for urban planning and bus station design.
The management and operation of charging piles can provide effective data support, provide users with a better service experience, provide a basis for enterprises to optimize services and management, and promote the popularization and development of new energy vehicles.