Connecting the SiLabs AMW007 Wi-Fi Module to Medium One IoT Cloud
By Greg Toth for Mouser Electronics
The Silicon Labs
Wireless Xpress AMW007 is a Wi-Fi module for adding wireless network connectivity to
microcontroller-based IoT product designs. It can be combined with a development board such as the SiLabs
EFM32 Pearl Gecko PG12 to provide a development environment for rapid prototyping and product
development. The Medium One IoT
Prototyping Sandbox is a cloud-based IoT platform designed to help early-stage developers’
prototype IoT projects or connect existing hardware to the cloud. In this project we’ll set up an IoT
development environment using the AMW007 Wi-Fi module and EFM32 Pearl Gecko PG12 to read hardware sensors and
send the data to the Medium One cloud using Message Queuing Telemetry Transport (MQTT). Once the data is in
Medium One, it can be processed and viewed using programmable workflows and configurable widget
dashboards.
Project Materials and Resources
Project BOM
Hardware
- 11 b/g/n Wi-Fi access point with a DHCP server, Internet connectivity, and without a firewall or proxy that
blocks outgoing traffic to the Internet
- Five jumper wires with pins on one end and sockets on the other
Accounts and Software
- Login account for Silicon Labs to download software
- Login account for Zentri Device Management Service (optional) to perform Over-the-Air (OTA) updates to the
AMW007 Wi-Fi module firmware
- Login account for the Medium One IoT Prototyping Sandbox
- Silicon Labs Simplicity Studio 4 Integrated Development Environment (IDE)
- Application project files available in a GitHub repository
- Serial terminal program such as Tera Term on the PC
- Wi-Fi access point connection details including SSID and password
Project Technology Overview
SiLabs Wireless Xpress AMW007
The AMW007 is a Wi-Fi module for adding wireless network connectivity to your IoT designs. It can connect to
802.11 b/g/n Wi-Fi access points as a client and also act as a Wi-Fi access point that other clients can connect
to. The module contains a built-in microcontroller with GeckoOS firmware that implements a command interface,
networking protocols, Over-the-Air (OTA) firmware updates, system management functions, and a file system for
storing files used by the module. It also contains input/output peripherals, a flash memory device, and
additional features you can view here.
Technical documentation on the AMW007 can be found here
and the GeckoOS firmware commands are described at https://docs.zentri.com/zentrios/wl/latest/
The GeckoOS firmware is accompanied by the Zentri Device Management Service (DMS), an online tool for performing
system management of individual AMW007 modules or entire fleets of modules. The DMS service allows you to
register and activate new modules, check their status, and perform GeckoOS firmware OTA updates through the
Internet.
Figure 1: AMW007-E04 Evaluation Board Containing AMW007 Wi-Fi Module
(https://www.mouser.com/images/marketingid/2018/img/141798045.png)
AMW007-E04 Evaluation Board
The AMW007-E04 Evaluation Board (Figure 1) has an AMW007 module plus onboard peripherals
connected to the GPIO pins, including two user-defined push buttons, two user-defined LEDs, a USB jack for
connecting to the module’s serial UART port, and an expansion header for connecting the Wi-Fi board to
other development boards. The board also contains a PCB trace antenna for the Wi-Fi module so that you
don’t need to provide a separate antenna.
When using the board in a stand-alone mode, you typically connect the board’s serial UART interface to a PC
through a USB cable and issue commands through a serial terminal program such as Tera Term. When using the board
in conjunction with another development board the USB jack is left unplugged so that the serial UART gets routed
to the other development board through the 20-pin expansion connector.
Silicon Labs SLSTK3402A EFM32 Pearl Gecko PG12 Starter Kit
For this project we’ll connect the AMW007-E04 evaluation board to an EFM32 Pearl Gecko PG12 board
(Figure 2). The Pearl Gecko PG12 is an IoT development board that contains more sensors and
peripherals along with an ARM® Cortex-M4® based Pearl Gecko microcontroller with RAM and flash memories.
More detailed information about the board can be found here.
Figure 2: EFM32 Pearl Gecko PG12 Board
(https://siliconlabs-h.assetsadobe.com/is/image/content/dam/siliconlabs/images/products/microcontrollers/32-bit_mcus/pearl_gecko/slstk3402a-pearl-gecko-pg12-stk.png)
Silicon Labs Simplicity Studio 4
Firmware programs that run on microcontrollers are typically developed and tested using an Integrated Development
Environment (IDE) running on a personal computer. The IDE provides an editor, compiler, linker, debugger, and a
mechanism for transferring binary program images to the microcontroller.
The Pearl Gecko can be programmed using SiLabs Simplicity Studio 4, an Eclipse-based IDE that runs on Windows,
Mac, and Linux computers. It connects to the Pearl Gecko using a USB cable that supports programming and
debugging. Simplicity Studio can be downloaded for free from the Simplicity Studio
site.
Project Application Source Code Files
For this project, Simplicity Studio was used to create an initial set of project source code files that have been
modified and extended to work with the Medium One IoT Prototyping Sandbox. The resulting files have been put in
a GitHub repository that you can download and use for this project. The project files will be imported into the
Simplicity Studio IDE where they’ll be compiled and downloaded to the Pearl Gecko board. The project files
consist of a main application program and supporting functions for MQTT and I/O processing.
Medium One IoT Prototyping Sandbox
The Medium One IoT Prototyping Sandbox (Figure 3) is designed to help early-stage developers
prototype their IoT project or connect their existing hardware to the cloud. It offers an IoT Data Intelligence
platform enabling customers to quickly build IoT applications with less effort. Programmable workflows allow you
to quickly build processing logic without having to create your own complex software stack. Configurable
dashboards allow you to visualize application data and view real-time data in a variety of formats. Medium
One’s iOS and Android apps allow you to build simple mobile app dashboards that can communicate with your
devices through the IoT Prototyping Sandbox.
Figure 3: Medium One IoT Prototyping Sandbox (Source: Mouser Electronics)
IoT devices can exchange data with Medium One through a REST API or MQTT. More detailed information about the
Medium One IoT Prototyping Sandbox can be found here.
The Setup (Hardware)
While setting up the hardware, be sure to remember that electronic components are static-sensitive.
AMW007-E04 and Pearl Gecko PG12 Boards
Remove both boards from their packaging and place on a suitable work surface. Both boards have a 20-position edge
connector intended for directly connecting the boards. However, for this project, we are only going to connect
specific pins between the boards and purposely leave the remaining pins unconnected. Using five Dupont jumper
wires, connect the following pin signals between the boards using their 20-position edge connectors:
- Pin 1 (GND)
- Pin 12 (UART_TX)
- Pin 14 (UART_RX)
- Pin 18 (5V)
- Pin 20 (3V3)
The Pearl Gecko should have the small slide switch set to the AEM position so the board will be powered through
the USB cable when connected.
Connect the included Type-A to Mini-B USB cable from the Pearl Gecko USB port (marked DBG) to the PC and connect
the included Type-A to Micro-B USB cable from the AMW007-E04 USB port to the PC. After the USB cables are
plugged in, you should see LEDs illuminate on the boards.
The AMW007 module communicates with either the PC or the Pearl Gecko microcontroller through a UART serial port.
The AMW007-E04 has an automatic switching circuit that routes the UART to either the micro USB port when
it’s connected, or the 20-pin edge connector when the USB is disconnected. We’ll start with the USB
cable connected to the PC so we can configure the Wi-Fi module. Later, we’ll disconnect the USB cable so
the Wi-Fi module can communicate with the Pearl Gecko microcontroller.
Configure AMW007 Wi-Fi Module Parameters
With the AMW007-E04 board connected to your PC with the USB cable, start your serial terminal program (e.g. Tera
Term) and set the connection parameters to 115200,N,8,1. Open the USB serial connection in the terminal and
press the Enter key a few times. You should see a command prompt like Figure
4. Run the “version” command to check the firmware version and use the
help command to see other available commands.
Figure 4: AMW007 GeckoOS Firmware Command Entry (Source: Mouser Electronics)
If your AMW007 module firmware is out of date or you are unsure whether it is the latest version, go through the
GeckoOS OTA update process described here https://docs.zentri.com/zentrios/wl/latest/update-and-recovery#secure-ota-update.
Set the Wi-Fi Connection Parameters
Enter the following commands to set the Wi-Fi connection parameters for your Wi-Fi access point:
set wlan.ssid YOUR_WIFI_SSID
set wlan.passkey YOUR_WIFI_PASSWORD
set wlan.auto_join.enabled on
save
reboot
The wlan.auto_join.enabled parameter controls whether the module automatically connects to the Wi-Fi access point
after each reboot. Use the ping command to ping an Internet address to verify you have
connectivity.
Switch the Module to Machine Mode
The module’s command interface works in either a “human” mode or a “machine” mode.
The human mode is meant for people to use and has a prompt and descriptive status messages. The machine mode is
meant for software applications to use if, for example, software sends commands to the module and parses the
responses. The machine mode turns off the prompt, character echo, and long descriptive messages and replaces
them with response codes that can be parsed by software.
Issue the following commands to switch the module to machine mode:
set system.print_level 0
set system.cmd.header_enabled 1
set system.cmd.prompt_enabled 0
set system.cmd.echo 0
save
reboot
In machine mode, you can still type commands through the USB connection though the interface will be much more
terse. You can switch back to human mode by running the factory reset command (see the GeckoOS documentation) or
by using these commands:
set system.print_level all
set system.cmd.header_enabled 0
set system.cmd.prompt_enabled 1
set system.cmd.echo 1
save
reboot
The Setup (Software)
There are four major parts to the software setup:
- Downloading and installing the Simplicity Studio IDE.
- Downloading the project application source code files and importing them into Simplicity Studio.
- Setting up the Medium One IoT Prototyping Sandbox.
- Updating the project application source code files to connect to your Medium One IoT Prototyping Sandbox
account.
Download and Install Simplicity Studio
Web browse to the Simplicity Studio web
site and download the installer for your type of PC (Windows Mac or Linux). If you don’t already
have a Silicon Labs login account, register for a new account (free) and complete the registration process. Run
the downloaded installer to install Simplicity Studio on your computer. If you’re using a Mac computer, be
sure to check for any special installation instructions.
Make sure both USB cables are connected between the Pearl Gecko and AMW007-E04 boards and the PC and the boards
have power.
Start Simplicity Studio and look for a popup message indicating that a Device Inspector package needs to be
installed. Click Yes to install the Device Inspector.
You should now see an Installation Manager dialog (Figure 5). Click Install by
Device.
Figure 5: Simplicity Studio Device Installation Manager (Source: Mouser Electronics)
The Install Wizard should appear with the “Selected devices” list initially empty. Highlight the two
items under “Connected devices” and then click the >> button to add them to
the Selected devices list (Figure 6).
Figure 6: Installing Components for AMW007 and EFM32PG12 Boards (Source: Mouser
Electronics)
Click Next. You should see several components selected and saying "Access Granted." You can
optionally log in using your Silicon Labs account to grant access to additional components.
Click Next and a list of recommended components should appear. Click Next to
install the components. Review and accept the license agreements, then click Finish. The
components should be automatically downloaded and installed, after which you’ll need to restart Simplicity
Studio.
After restarting Simplicity Studio you should see the Launcher perspective (Figure 7). If
you’re asked to sign into your Silicon Labs account, you can do that by entering your username and
password. If you don't see AMW007-E04 board under Debug Adapters, try un-plugging and re-plugging the AMW007-E04
USB cable.
Figure 7: Simplicity Studio Launcher Perspective After Installation & Setup (Source:
Mouser Electronics)
Select menu command Window > Perspective > C/C++ and the
perspective should change to C/C++ with an empty Project Explorer tab on the left side.
Download and Import the Project Application Source Code Files
Web browse to the GitHub repository https://github.com/Mouser-Electronics/ma5_files
and find the PearlGecko_MediumOne_1.0.0.zip file. Click the .zip file, then click Download to
download it to your computer.
In Simplicity Studio, select File > Import… > More Import
Options… > General > Existing Projects into
Workspace and click Next. Checkmark Select archive file and click
Browse… to pick the .zip file you downloaded from GitHub. Make sure the
PearlGecko_MediumOne project is check-marked and click Finish. After
completing the import, the Project Explorer tab should look like Figure 8.
Figure 8: After Importing the Project Source Code Files Into Simplicity Studio (Source:
Mouser Electronics)
We’ll come back to the source code files later after setting up Medium One.
Set Up the Medium One IoT Prototyping Sandbox
Web browse to the Medium One IoT Prototyping Sandbox and log in,
after which you should see a dashboard resembling Figure 3. Click Setup > Manage
Users > Add New User. Set Username to
pearlgecko, create a password of your choice and enter it in both password fields, then click
Save. In the Manage API Users list, you should see a new user account having Login ID
= pearlgecko and an auto-generated user MQTT ID like Figure 9.
Figure 9: Newly Created User ID With Auto-Generated MQTT ID (Source: Mouser
Electronics)
Click Setup > MQTT and you should see a Project MQTT ID and a set
of port numbers like Figure 10.
Figure 10: Project MQTT ID (Source: Mouser Electronics)
Medium One uses MQTT usernames and passwords for authentication. The MQTT username is created by combining the
Project MQTT ID, a forward slash, and the user MQTT ID. For example, if the Project MQTT ID is
“ZHxxxxxxx0Y” and the user MQTT ID is “sTxxxxxxx8w” the corresponding MQTT username
would be “ZHxxxxxxx0Y/sTxxxxxxx8w”.
Next we’ll create the MQTT password. Navigate to Setup > Manage API
Keys > Add New API Key. Set the description to pearlgecko,
make sure Enabled is check-marked, and click Save. The result should look like
Figure 11.
Figure 11: Newly Created API Key (Source: Mouser Electronics)
The MQTT password is created by combining the API Key, a forward slash, and the pearlgecko user
password. For example, if the API Key is “PZxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMBQ” and the
pearlgecko user password is “AaaaBbbb3” the corresponding MQTT password would be
“PZxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMBQ/AaaaBbbb3”.
The MQTT topic has the following format: “0/Project MQTT ID/User MQTT ID/Device ID”.
The Device ID field can be anything, and we’ll use “pearlgecko” as the Device ID. For example,
if the Project MQTT ID is “ZHxxxxxxx0Y” and the user MQTT ID is “sTxxxxxxx8w” the
corresponding MQTT topic would be “0/ZHxxxxxxx0Y/sTxxxxxxx8w/pearlgecko”.
The MQTT username, MQTT password and MQTT topic strings will get added to the project source code in the next
step.
Update Application Source Code Files for Your Medium One Account Parameters
In the Simplicity Studio Project Explorer tab, open the src/medium_one.h file and change the
string values for MQTT_USERNAME, MQTT_PASSWORD, and
MQTT_TOPIC to the corresponding strings generated in the previous step.
*** NOTE *** The current version of the AMW007 firmware is not able to connect to the Medium One MQTT
broker over TLS and this project uses unencrypted MQTT communications between the Pearl Gecko and Medium One
MQTT broker. The MQTT username and password are sent over the Internet in the clear and neither the
credentials nor the sensor data are encrypted.
Save the modified file, then right-click on PearlGecko_MediumOne under Project Explorer and
select Build Project. Verify the code compiles without errors. If you see compilation errors,
check the changes you made to src/medium_one.h.
Disconnect the EMW007-E04 Board USB Cable
Disconnect the USB cable from the AMW007-E04 board to the PC while leaving the Pearl Gecko USB cable connected.
Be sure to perform this step, otherwise the AMW007-E04 USB connection to the PC will block the Pearl
Gecko’s UART connection to the AMW007 module.
Run the Application
Right-click on PearlGecko_MediumOne under Project Explorer and select Debug As
> Silicon Labs ARM Program. The program should be downloaded to the board and the debugger
should be stopped on the first line of the main() routine. Use menu command Run > Resume to
start program execution.
How the Application Program Works
This program is derived from the PearlMQTT example application included in the GeckoOS documentation. The
following changes and enhancements were made for this project:
- Initialize the Pearl Gecko LEDs and push buttons.
- Initialize the Temperature & Humidity sensor on the Pearl Gecko.
- Initialize TCP/IP networking on the AWMW007 Wi-Fi board.
- Connect to the Medium One MQTT broker.
- Periodically read the user buttons and temperature/humidity sensor.
- Generate a JSON formatted MQTT payload message and send to Medium One MQTT broker.
- Flash LED0 on the Pearl Gecko during each MQTT transmission.
- Wait for the beginning of the next transmission interval (default is 10 seconds).
MQTT Payload Format
MQTT messages are formatted as JSON strings according to the Medium One MQTT payload specification. Here’s
an example message:
{"event_data":{"device":"pearlgecko","iteration":7,"clock":1101,"btn0":false,"btn1":false,"tempf":72.745,"humid"42.392:}}
Fields:
- device = the board name
- iteration = application loop counter
- clock = application timer tick counter
- btn0 = status of the BTN0 push button: true = pressed, false = released
- btn1 = status of the BTN1 push button: true = pressed, false = released
- tempf = temperature in degrees Fahrenheit
- humid = relative humidity in percent 0-100
Try pressing the Pearl Gecko's BTN0 and BTN1 buttons and heating or cooling the temperature sensor to see the
message values change.
View Data in the Medium One Dashboard
In the Medium One dashboard navigate to Data Viewer > Data Streams and click
raw Events. You should see raw messages (Figure 12) being received from the
Pearl Gecko. Click the “+” sign to view message details.
Figure 12: Raw Message Display (Source: Mouser Electronics)
Click Dashboard on the top left, then click Add Widget > Single User
Real Time Events Stream to add an event stream widget to the dashboard.
In the Select user dropdown, select pearlgecko. You should now see messages
appearing in the Real Time Events Stream widget (Figure 13). Click the save icon in the
upper right corner to save your modified dashboard.
Figure 13: Real Time Events Stream Widget Display (Source: Mouser Electronics)
Add More Widgets
To display more widgets, we need to enable specific data fields contained in the message payload. Navigate to
Config > Data Streams and click on raw Events. The Schema
Map should be pre-populated with fields detected in the incoming messages, however they are currently disabled.
Check-mark the Active box on raw.btn0, raw.btn1,
raw.clock, raw.humid, raw.iteration, and
raw.tempf, then click Save Data Stream. These fields are now available for use
in other dashboard widgets.
Back on the dashboard, click the Single User Last Value Table widget and select the
pearlgecko user within the widget. Click the widget’s Tag Config icon to
the right of the pearlgecko user selection and check-mark raw:btn0, raw:btn1,
raw:clock, raw:humid, raw:iteration and
raw:temp values, then click Save. The Last Value Table should now populate
with the most recent received values for each field (Figure 14). Click the
Save icon towards the upper right corner to save the updated dashboard.
Figure 14: Last Value Table Widget Display (Source: Mouser Electronics)
Now let’s add dashboard widgets for the temperature and humidity sensor. Click Single User Real
Time Gauge and select the pearlgecko user. Click the widget’s Tag
Config icon and check-mark the raw:humid, raw:iteration and
raw:tempf rows, then click Save. The updated dashboard should look like
Figure 15. Click the dashboard save icon to save the updated dashboard. Try heating or cooling
the temperature and humidity sensor on the Pearl Gecko board to see the gauge values change.
Figure 15: Real Time Gauge Widgets Added to Dashboard (Source: Mouser Electronics)
At this point your Pearl Gecko and AMW007-E04 boards are running continuously, periodically reading the
temperature/humidity sensor and buttons and transmitting data measurements to the Medium One cloud. Remember to
power off the Pearl Gecko and AMW007 boards when you’re done, otherwise the boards will continue to send
messages to Medium One and consume daily message allotments.
Where to Go Next
This project is an end-to-end sensor-to-cloud application that sends real-time sensor data to the Medium One IoT
Prototyping Sandbox. It can be modified and extended in a number of ways. Here are a few examples:
- Dive deeper into the application code and board hardware by reading the AMW007 and EFM32 Pearl Gecko PG12
documentation and studying the source code.
- Learn about the Medium One Workflow Studio, which lets you create data processing workflows to transform
your sensor data.
- Experiment with the Medium One mobile apps.
- Implement bi-directional communications with the Medium One cloud.
- Modify the sensor data publishing interval by modifying the Pearl Gecko application source code.
- Read other sensors on the Pearl Gecko board and include the data in MQTT messages.
- Display information on the Pearl Gecko’s LCD display.
- Enhance the MQTT communications to support MQTT over TLS.
Don’t forget to let us know how well this project worked for you. Would you expand upon it? If so, let us
know on Facebook, Twitter, LinkedIn, or Instagram
Greg is an architect, engineer and
consultant
with more than 30 years experience in sensors, embedded systems, IoT, telecommunications, enterprise systems,
cloud
computing, data analytics, and hardware/software/firmware development. He has a BS in Electrical Engineering
from
the Univ. of Notre Dame and a MS in Computer Engineering from the Univ. of Southern California.