RZ/G2L - Home Automation
Introduction
The user guide outlines the procedures and instructions for deploying the Home Automation use case on the RZ/G2L evaluation kit using AWS Greengrass.
The Home Automation application on the RZ/G2L facilitates the monitoring and control of light and fan devices, while also regularly measuring temperature and relative humidity. The application sends the collected temperature and humidity data to the AWS cloud database using internet from USB wireless or ethernet interface. Users can be able to manage appliances remotely using a web user interface.
Assumption:
Before going through the following steps, please make sure that RZ Gateway Linux environment preparation was completed.
Architecture Description
The architecture diagram presented below illustrates the AWS services utilized in the cloud and the RZ/G2L EVK. This diagram features two environments: the AWS cloud and the RZ/G2L EVK. Both environments are interconnected through internet communication protocols, like MQTT.
Peripheral Setup
a. Insert the previously prepared microSD card into the microSD card slot.
b. Connect the LAN cable to the Ethernet connector.
c. Connect the USB serial cable to the serial port. The other end is to be connected to a Windows PC.
d. Connect US082-HS3001EVZ PMOD sensor to PMOD1 - Type-2A connector.
e. Connect Wi-Fi USB module (TP-Link Archer TX1U nano) to USB 1 connector [optional].
f. Enable SW3 and SW4 switches to enable I2C communication to read sensor data.
g. Connect the Type-C USB cable to the power connector port. Two green LED will light up.
h. Power up the board by pressing 1 second the Power button.
After successfully booting up the board, on serial console, log in under root account:
smarc-rzg2l login: rootNote: if using Wi-Fi connectivity, please refer to RZ/G2L - Home Automation section.
Optional Setup: LED Light and Fan control
With Home Automation sample demo user can control LED light and Fan motor control.
An external circuit is necessary for the application to simulate light with an LED from GPIO-12 and to control a fan using a DC motor from GPIO-13.
The LED can be operated directly via GPIO-12, but the DC motor requires a greater current from GPIO-13 to operate.
The system requires an increased voltage for current amplification through the use of an external circuit. As illustrated below, modify the jumper CN4 from positions 2 - 4 to 4 - 6 in order to adjust the voltage from 3.3V to 5V
Use the below Darlington pair connections with resistors, transistors and diodes to amplify the load current to drive DC motor.
Required Components:
No. | Component Name | Quantity |
1 | BC547 Transistor | 2 |
2 | LED (1.8V) | 1 |
3 | DC Motor (3.3V - 12V) | 1 |
4 | 1K Resistor | 2 |
5 | Diode 1N4007 | 1 |
Step 1 - Infrastructure Setup
Step 1.1 - AWS Credentials Preparation
AWS Credentials are necessary to establish the Home Automation use case environment on the cloud and the RZ/G2L EVK. The user must create an AWS account and log into the AWS Management Console using either the root account or an existing IAM user with administrative rights. If the user does not have an IAM user, follow the steps outlined below to create one:
Navigate to the IAM service.
Create a new IAM user (if not have) and ensure Programmatic access is enabled during creation. This will provide an AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
Attach appropriate policies to this IAM user to grant the necessary permissions.
Install AWS CLI on Host machine from AWS Documentation.
Export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables on Host Machine.
Run following AWS cli command to generate AWS_SESSION_TOKEN for 36 hours duration
On Host Machine:
$ aws sts get-session-token --duration-seconds 129600Command result:
{
"Credentials": {
"AccessKeyId": "123...",
"SecretAccessKey": "...",
"SessionToken": "...",
"Expiration": "2025-07-30T23:47:00Z"
}
}Copy and save the temporary AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN for further use.
Step 1.2 - Setup Home Automation use case infrastructure
The Home automation application requires the setup of infrastructure on the AWS cloud and on the RZ/G2L Device. On the RZ/G2L device, the application collects temperature and relative humidity data and stream them to cloud database through Greengrass v2 component and device shadow service. On the AWS Cloud, use the web UI interface to interact with the application using an EC2 instance. The web UI interface monitor and manages the appliances remotely through device shadow service. Device shadow updates state change to Home automation application by publishing the desired states via an MQTT topic. Similarly, reports the home appliance manual change state to cloud via device shadow MQTT topics from the Greengrass component. The entire infrastructure is configured using the Ansible tool, which requires AWS credentials for access and setup on the AWS cloud.
On the RZ/G2L EVK:
Download from GitHub page, the ha-g2l-vlp-v1.1.zip file
Copy ha-g2l-vlp-v1.1.zip file to RZ/G2L /home/root
Extract the zip file and remove the zip file
# unzip ha-g2l-vlp-v1.1.zip
# rm ha-g2l-vlp-v1.1.zipNote: If you created your AWS account before June 20, 2025 and would like to use AWS Timestream for Live Analytics instead of InfluxDB 3, please replace ha-g2l-vlp-v1.1.zip with ha-g2l-vlp-v1.0.zip.
ha-g2l-vlp-v1.1.zip: for AWS accounts created after June 20, 2025.
ha-g2l-vlp-v1.0.zip: for AWS accounts create before June 20, 2025 and want to use AWS Timestream for Live Analytics instead of InfluxDB 3.
Change directory to scripts
cd ~/ home_automation/scripts/Open config.yaml configuration file and configure the aws parameters. If required, user can change the names of iot parameters.
Run home_automation.sh
./home_automation.shNote: script can also be executed by providing AWS credentials and AWS region as arguments.
./home_automation.sh <AWS_ACCESS_KEY_ID> <AWS_SECRET_ACCESS_KEY> <AWS_SESSION_TOKEN> <AWS_REGION>The script will execute 30 to 40 minutes to setup the infrastructure on RZ/G2L Device and AWS cloud.
During the execution of the script, it generates logs for each step. The user can review the logs sequentially as outlined below and validate the installation.
Setup on RZ/G2L EVK:
Check the configuration details
Verifying and installing dependencies packages required for setup
Install Greengrass v2 on RZ/G2L EVK
Create IoT policy, IAM role, IAM policies and attach policies to IAM role
Below log shows the summary of Home Automation client installation setup on AWS cloud
Starts executing step-2, Setting up Home Automation server using Ansible
Create EC2 instance key pair
Create and Launch EC2 instance
Associate elastic IP to EC2 instance
Connect EC2 instance with ssh
Create Timestream database
Deploy FastAPI server into EC2
Deploy React app to EC2
Create S3 bucket policies to access S3 bucket
Deploy home automation Greengrass component
On Successful completion of Step-2, the below output is shown
If the installation is successful, the above message will be shown on RZ/G2L EVK UART console.
Step 2 - Execute Home Automation use case
This section details the steps to execute Home automation application on the RZ/G2L EVK. The RZ/G2L EVK should be connected with web UI application through AWS Greengrass V2. The web UI application shows the appliances and sensor data if and only if the RZ/G2L is actively connected with AWS cloud.
In order to access the Home automation devices, we must use the web UI interface through a browser. To launch the web UI application, a public IP address is required. Once the infrastructure has been established, the Ansible tool records the public IP in home_automation/scripts/ansible_start/instance_ip.txt.
On RZ/G2L EVK:
cat ~/home_automation/scripts/ansible_start/instance_ip.txt98.89.148.129 (for e.g.)
Open the browser and type the URL: <http://<instance_ip>>
For e.g. http:// 98.89.148.129
The web application opens log-in page. Enter username as “user” and Password as “1234” and click on log-in.
Upon opening, if the RZ/G2L device is actively connected to cloud the web application presents
• Appliances and its states
• Sensors and its data.
Upon opening, if the RZ/G2L device is actively not connected to cloud the web application won’t show devices status.
Users can toggle the appliances light and fan using toggle button and see the ON/OFF state change from web UI application from remote location. Similarly, users can observe the appliances state change when the appliances are ON/OFF locally at home.
Users can observe the temperature and relative humidity sensors data from web UI graphs.
• Temperature Sensor graph
• Relative humidity sensor graphUsers can observe logs from /greengrass/v2/logs/HomeAutomationGreengrassComponent.log
Note - USB Wi-Fi Device Connection
On RZ/G2L EVK, when the TP-LINK Archer TX1U Nano USB Wi-Fi device is connected, the drivers are loaded automatically and creates wlan0 interface. When wlan0 interface is created, usb-wifi@wlan0.service service will be started and reads SSID and password from /opt/usb-wifi/wifi_credentials.txt and try to establish connection.
Follow below steps to setup Wi-Fi connectivity after the system boots up
Power on the RZ/G2L device and login.
Connect TP-Link USB Wi-Fi adapter to RZ/G2L.
Configure SSID and Password in /opt/usb-wifi/wifi_credentials.txt file.
Reboot the RZ/G2L device.
In the next boot, the device connects to Wi-Fi.