Skip to content

Latest commit

 

History

History

wifi_asset_tracking

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Wi-Fi - Asset Tracking

Type badge Technology badge License badge SDK badge Required board Required board Required board Required board Build badge Flash badge RAM badge

Purpose-Scope

This application demonstrates how to configure the SiWG917 module as an Azure device endpoint and how to establish a connection with Azure IoT Hub. This project contains the development of a Wi-Fi tracker application on the SiWG917-PK6031A, that will be connected to Wi-Fi access point using WLAN APIs provided by the WiSeConnect 3 SDK. Communicates with Azure IoT Hub based on the configurations provided by the developer through the JSON messages containig the following fields.

  • Wi-Fi MAC ID (as identifier)
  • Current SSID and signal strength
  • Current timestamp
  • Latitude, longitude, elevation, and number of satellites visible
  • Current humidity and temperature readings
  • Values of accelerometer and gyroscope (X, Y, and Z-axis)

Overview

system_overview

System Overview

The following components should be set up to demonstrate Wi-Fi Asset Tracking end-to-end use-case using a SiWG917 device.

  • Azure Cloud

    This example requires to create an Azure cloud account and then configure and create an Azure IoT Hub resource to receive data from the SiWG917 device. The Azure IoT Hub resource should be configured so that messages received from the SiWG917 device at the Azure IoT hub device will be routed back to its subscribers.

    Azure Cloud Configuration Steps

  • Dashboard

    This application example provides a web-based dashboard application (frontend + backend) that subscribes to the Azure IoT Hub and receives and displays the sensor data on a frontend application in your browser. The frontend also provides an option to download session data and GPX files at dashboard application. You should sign in to the dashboard application using your Azure Cloud credentials to see the sensor data on the dashboard widgets.

    Dashboard Configuration Steps

  • SiLabs SiWG917 Device

    SiWG917 SoC will get connected to multiple sensor modules like: SparkFun humidity and temperature sensor (Si7021), SparkFun GNSS receiver (MAX-M10S) and SparkFun 6DoF IMU (BMI270) using Qwiic connectors over I2C bus. SiWG917 device application will capture sensor data according to configured sample interval using an I2C bus. SiWG917 device will get connected to configured Wi-Fi to access the internet, and then it will get connected to the Azure IoT Hub. After that, captured sensor data will be converted to JSON format and will be sent to the Azure IoT Hub using the Message Queueing Telemetry Transport (MQTT) protocol.

    Device Configuration Steps

Application Overview

Firmware application consists of three logical modules:

  • Sensor Module

    This module is responsible for reading sensor and GNSS receiver data at a configured interval. Each sensor data will be read in a separate thread/task. The sensor data queue holds data read from each sensor thread. The JSON format converter thread reads data from the sensor data queue, converts sensor data to JSON format, and pushes JSON formatted data to the MQTT message queue.

  • Wi-Fi and connectivity management module

    This module measures Wi-Fi parameters and pushes them to a message queue. It also forms keep-alive MQTT messages and sends them to the cloud at regular intervals. Depending on the complexity of the message interval, one or more threads can be used for message creation and connection management.

  • Message Queueing Telemetry Transport (MQTT) message sender module

    This module sends messages to the Azure cloud. It contains a single thread that reads data from the MQTT message queue and sends it to the Azure IoT Hub.

    application_overview

Hardware Requirements

Software Requirements

Setup

Setup Diagram

Sparkfun Qwiic boards can be easily connected to each other using Qwiic cables. Then connect it all back to the SiWx917 Wi-Fi 6 and Bluetooth LE 8 MB Flash SoC Pro Kit board as shown in the table below:

Description BRD4338A GPIO BRD4002 EXP Header SparkFun Qwiic boards
I2C_SDA ULP_GPIO_6 EXP_16 SDA
I2C_SCL ULP_GPIO_7 EXP_15 SCL

The final setup of the system is shown in the image below:

hardware_setup

To test this application, you can either create a project based on an example project or start with a "SL Si91x - Empty C Project SoC" project.

Create a project based on an example project

  1. From the Launcher Home, add the BRD4338A to My Products, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project filtering by "asset".

  2. Click Create button on the Wi-Fi - Asset Tracking example. Example project creation dialog pops up -> click Create and Finish and Project should be generated.

    create_demo

  3. From the project root folder, open file "config/sl_net_default_values.h" change 2 macros "DEFAULT_WIFI_CLIENT_PROFILE_SSID" and "DEFAULT_WIFI_CLIENT_CREDENTIAL" match with your WIFI SSID and WIFI PASSPHRASE.

    • "DEFAULT_WIFI_CLIENT_PROFILE_SSID" refers to the name with which Wi-Fi network that shall be advertised and Si91X module is connected to it.
    • "DEFAULT_WIFI_CLIENT_CREDENTIAL" refers to the secret key if the AP is configured in WPA-PSK/WPA2-PSK security modes.

    change_wifi_ssid_passphare

  4. From the project root folder, open file "sl_wifi_asset_tracking_demo_config.h" change 3 macros "DEMO_CONFIG_IOT_HUB_HOST_NAME", "DEMO_CONFIG_DEVICE_ID" and "DEMO_CONFIG_DEVICE_SYMMETRIC_KEY" match with your Azure Cloud configuration ("Refer to this document")

    change_azure_cloud

  5. Build and flash this example to the board.

Start with a "SL Si91x - Empty C Project SoC" project

  1. Create a SL Si91x - Empty C Project SoC project for BRD4338A using Simplicity Studio 5.

  2. Copy all of source files in "wifi_asset_tracking/src" and header files in "wifi_asset_tracking/inc" to the directory of the project root folder (overwriting the existing files).

  3. Install the software components:

    • Open the .slcp file in the project.

    • Select the SOFTWARE COMPONENTS tab.

    • Install the following components:

      • [WiSeConnect 3 SDK] → [Device] → [Si91x] → [MCU] → [Peripheral] → [I2C] → [i2c2]
      • [Third Party Hardware Drivers] → [Wireless Connectivity] → [MAX-M10S - GNSS Receiver Breakout - I2C]
      • [Third Party Hardware Drivers] → [Sensor] → [BMI270 - 6DOF IMU Breakout (Sparkfun)]
      • [WiSeConnect 3 SDK] → [Device] → [Si91x] → [Wireless] → [Buffer Manager] → [Memory Pool Buffers]
      • [WiSeConnect 3 SDK] → [Third Party] → [AZURE FreeRTOS Middleware]
      • [WiSeConnect 3 SDK] → [Service] → [Network Management] → [Configuration] → [Basic Network Configuration Manager]
      • [WiSeConnect 3 SDK] → [Device] → [Si91x] → [MCU] → [Hardware] → [Memory LCD SPI driver]
      • [WiSeConnect 3 SDK] → [Device] → [Si91x] → [MCU] → [Peripheral] → [Calendar]
      • [WiSeConnect 3 SDK] → [Device] → [Si91x] → [MCU] → [Hardware] → [Si70xx Humidity and Temperature Sensor]
      • [WiSeConnect 3 SDK] → [Device] → [Si91x] → [Wireless] → [Crypto] → [HMAC]
      • [WiSeConnect 3 SDK] → [Device] → [Si91x] → [MCU] → [Core] → [Peripheral] → [ULP Timer] → [timer0]
      • [WiSeConnect 3 SDK] → [Service] → [SNTP Client]
      • [WiSeConnect 3 SDK] → [Resources] → [WiSeConnect3 Resources]
      • [WiSeConnect 3 SDK] → [Device] → [Si91x] → [MCU] → [Service] → [Power Manager] → [ULP Peripheral] → [ULP SSI]
      • [Application] → [Utility] → [Assert]
      • [Platform] → [Driver] → [GLIB Graphics Library]
      • [RTOS] → [FreeRTOS] → [FreeRTOS Heap 4]
  4. From the project root folder, open file "config/sl_net_default_values.h" change 2 macros "DEFAULT_WIFI_CLIENT_PROFILE_SSID" and "DEFAULT_WIFI_CLIENT_CREDENTIAL" match with your WIFI SSID and WIFI PASSPHRASE

    • "DEFAULT_WIFI_CLIENT_PROFILE_SSID" refers to the name with which Wi-Fi network that shall be advertised and Si91X module is connected to it.
    • "DEFAULT_WIFI_CLIENT_CREDENTIAL" refers to the secret key if the AP is configured in WPA-PSK/WPA2-PSK security modes.

    change_wifi_ssid_passphare

  5. From the project root folder, open file "sl_wifi_asset_tracking_demo_config.h" change 3 macros "DEMO_CONFIG_IOT_HUB_HOST_NAME", "DEMO_CONFIG_DEVICE_ID" and "DEMO_CONFIG_DEVICE_SYMMETRIC_KEY" match with your Azure Cloud configuration (Refer to this document)

    change_azure_cloud

  6. Build and flash this example to the board.

How It Works

After you flash the code to your board and power the connected boards, the application starts running automatically. Use Putty/Tera Term (or another program) to read the values of the serial output. Note that your board uses the default baud rate of 115200. First, the main program initializes the driver, reads some information and checks communication with the sensors. After that, it tries to establish connection to your Wi-Fi access point (AP). If the connection is successfully established with the access point, the main program sends the data to the Azure Cloud periodically. Then, it is possible to use the dashboard to view the data (Refer to this document).

There is a periodic timer in the code, which determines the transmitting intervals; the default transmitting intervals rate is defined in "sl_wifi_asset_tracking_demo_config.h". If you need more frequent transmit, change the value of the corresponding parameters as follows.

  • The default Wi-Fi sampling interval is 60 seconds. To change the interval, add new value in the range of 60 and 600 seconds.

  • The default Si7021 Temperature and RH sensor sampling interval is 5 seconds. To change the interval, add new value in the range of 5 and 120 seconds.

  • The default BMI270 6DoF IMU sensor sampling interval is 1 second. To change the interval, add new value in the range of 1 and 60 seconds.

  • The default MAX-M10S GNSS receiver sampling interval is 60 seconds. To change the interval, add new value in the range of 60 and 600 seconds.

Note

  • When firmware application starts and connects to the Wi-Fi access point, the application fetches the current timestamp using the SNTP server. If the device failed to fetch the timestamp from the SNTP server within 7 seconds, the device configures a timestamp "2000-01-01T00:00:00.000Z". It is possible to reset the device or restart the application multiple times to get a valid current timestamp. The fetched timestamp is visible at the console logs and in the dashboard application.

  • In case when user started the firmware device before the dashboard aplication then all of those messages which has published before dashboard application started will be laps out and will not appear on dashboard. so till the time message were tackle by backend you might see idle dashboard.

Console Log

The screenshot of the console is shown in the images below:

Sensors Module Initialization

sensor_init

Wi-Fi Initialization

wifi_init

Keep-Alive and Wi-Fi Status

keep_alive_and_wifi_status

Temperature and Humidity Sensor

temp_and_humidity

GNSS Receiver Sensor

gps_data

6 Degrees of Freedom Breakout Sensor

imu_sensor_data

LCD Snapshot

lcd_screen

Dashboard Overview

dashboard

Report Bugs & Get Support

To report bugs in the Application Examples projects, please create a new "Issue" in the "Issues" section of wifi_applications repo. Please reference the board, project, and source files associated with the bug, and reference line numbers. If you are proposing a fix, also include information on the proposed fix. Since these examples are provided as-is, there is no guarantee that these examples will be updated to fix these issues.

Questions and comments related to these examples should be made by creating a new "Issue" in the "Issues" section of wifi_applications repo.