Lab 4 - How to Integrate the WIxCS02 M.2 Wi-Fi® Module Card to an MPLAB® X IDE Project to Establish Wi-Fi Communication
Introduction
This guide outlines the process of integrating a WIxCS02 M.2 Wi-Fi® Module Card into an MPLAB® X IDE project using the SAM9X75 Early Access Curiosity Wireless Kit , which allows embedded systems to connect to wireless networks and enable cloud or local communication over standard protocols like TCP/IP, HTTP, or MQTT. This guide walks you through the steps required to interface an M.2 Wi-Fi module using Serial Peripheral Interface (SPI) with a SAM9X75 Curiosity Wireless Kit, and how to configure the necessary software components using MPLAB Harmony v3 and establish reliable Wi-Fi communication.
Whether you're building an Internet of Things (IoT) device, sensor hub, or connected appliance, understanding this integration process is essential for enabling wireless capabilities in your embedded project.
This application enables users to connect their device seamlessly to either a home or mobile Wi-Fi network, establishing internet connectivity. Once connected, the application communicates with a Simple Network Time Protocol (SNTP) server to retrieve the current date. The obtained time information is then accurately displayed on the serial console, allowing users or developers to monitor the synchronized system time in real-time.
Prerequisites
Follow steps mentioned below:
- Hardware Setup
- SAM9X75 Curiosity Wireless Kit - Wi-Fi Quick Start Guide for MPLAB® Harmony v3 (follow steps 1-6)
- Lab 1 - How to Create an MPLAB X IDE Project
- Lab 2 - How to Integrate A Temperature Sensor to an MPLAB X IDE Project
- Lab 3 - How to Integrate the RNBD Module to an MPLAB X IDE to Establish Bluetooth® Communication
Add Project Graph and Develop an MPLAB Harmony Application
Follow the steps in Lab 1 and ensure you have cloned all the necessary libraries to create this thermostat MPLAB Harmony application.
Before continuing this lab, learn how to transmit the temperature value read from Temp&Hum13 Click boardTM by following Lab 3.
In this training module, you will learn how to connect to home or mobile Wi-Fi, read the current date from SNTP server and print it in the serial console.
The next step is to add WINCS02 drivers to the project graph. To do this, from the Device Resources pane, expand Wireless and add WINCS02.
Now add a dependency for Timer by right-clicking on TMR and adding available satisfier as TC0 as shown in the accompanying image:
From the "SAM9X75-Curiosity User Guide", note that the M.2 WINCS02 SPI is interfaced to the SAM9X75 Curiosity board via FLEXCOM4 as shown in the accompanying image:
Now add a dependency to WINCS02 as FLEXCOM4. Right-click on WINCS02 and select Available Satisfiers > FLEXCOM4 to add FLEXCOM4 to the Project Graph.
Now add SYS_CONSOLE to the Project Graph to print system console messages as shown in the accompanying image:
Now add RNWF WINCS Wi-Fi Service to the Project Graph as shown in the accompanying image:
The next step is to configure the WINCS02 module added in the Project Graph.
Observe and verify the WINCS02 and FLEXCOM4 configurations are the same as in the accompanying image.
The next step is to configure the RNWF WINCS Wi-Fi service added in the Project Graph.
In this example, WINCS02 is configured to Station mode with the required Wi-fi access point as given below:
- SSID: DEMO_AP
- Security type: WPA2
- Password: password
- Auto Connect: enabled
- Host: SAM9X75
- Wi-Fi device: WINCS02
- Interface Mode: SPI
- Country Code: GEN
- SNTP Server address: 162.159.200.1 (162.159.200.1 is a SNTP/NTP server IP operated by Cloudflare®)
Add the pin configurations. To do this, go to Project Graph > Plugins > Pin Configuration.
For SAM9X75 Curiosity, WINCS02 is connected as follows:
Now, configure the pins as shown in the accompanying image:
Save and then click the Generate button. This will generate code for all the device resources that have been added in the Project Graph.
Up to this point you used MPLAB Code Configurator (MCC) to configure and generate code to initialize the device (SAMA9X75). All that is left is for you to do is to write the application code in the main.c and app.c file.
Documentation for each of the peripheral libraries or driver libraries can be accessed as follows:
- BSP libraries APIs can be found in bsp.h
- Debug peripheral libraries APIs description and usage, see "2.27 Debug Unit (DBGU)"
- MPLAB Harmony Wireless Wi-Fi API documentation
In this example, you can learn how to connect to home or mobile Wi-Fi, read the Greenwich Mean Time from SNTP server and print it in the serial console.
See the example application source files.
APIs used for this application are as follows:
- SYS_WINCS_WIFI_CallbackHandler();
- SYS_WINCS_WIFI_SrvCtrl
- SYS_WINCS_SYSTEM_SrvCtrl();
Download and add the source file to the project as shown in the accompanying image:
Similarly, add the header file as shown in the accompanying image:
The app_wincs02_task should be called periodically to connect to Wi-Fi and to read date over SNTP server. Refer to the sample app.c source files.
Now clean and build the code. Refer to the sample application project source files.
To debug this application, follow steps 1-13 in Lab 7.
Run the application from the MPLAB X IDE.
Turn on the mobile hotspot/home Wi-Fi configured with
Username: DEMO_AP
Password : password.
The WINCS02 module will auto detect the Wi-Fi and read the time from the SNTP server and print the debug log.
To boot the application from microSD™ card follow the below steps:
Create harmony.bin file by following step 14 in Lab 7.
Now copy the generated harmony.bin file from your project directory and boot.bin file to the microSD card.
Insert the microSD card into the SD card J14 slot. Power the board on. Press the rest button (sw3) on the board.
Observe the output as mentioned in the previous step.
Summary
In this training, you developed, configured, and built an MPLAB Harmony v3 application that will connect to the mobile hotspot or home Wi-Fi and read the current date from the SNTP server for the SAM9X75 Curiosity Wireless Kit.
Learn More
- SAM9X75 Curiosity Wireless Kit - IoT Thermostat Application Using Embedded Wizard GUI+ WINCS02+ RNBD+ MQTT Training With Hands-on Labs
- Lab 5 - How to Integrate MQTT to an MPLAB® X IDE Project to Publish and Subscribe Data To/From a Cloud Broker
- Lab 6 - How to Integrate an Embedded Wizard GUI Project With an MPLAB® X IDE Project
- Lab 7- Debugging and Testing the IoT MPLAB® Harmony Application
- Lab 8 - Running the Pre-built MPLAB® Harmony IoT Application From the SD Card