Infineon XENSIV™ Sensors - Getting Started Box
Connecting Infineon XENSIV™ Sensors Getting Started Box IoT to Medium One IoT Platform
Image Source:
metamorworks/shutterstock.com
By Greg Toth for Mouser Electronics
Published March 10, 2020
The Infineon Technologies XENSIV™ Sensors - Getting Started Box IoT is an Internet of Things
development kit featuring ARM® XMC™ and ESP32 microcontrollers, security chips, Wi-Fi and
Bluetooth® Low Energy (BLE) connectivity, and multiple sensors in standardized
form factors that allow rapid connection and configuration for prototyping and evaluating IoT applications. The
Medium One IoT Platform 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 Getting Started IoT Box to read temperature, barometric pressure, and rotation sensors and send the
data to the Medium One cloud using 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
The project BOM lists components used in this project. Additional hardware and software development tools are
also identified.
Project BOM
Hardware
- 802.11 Wi-Fi access point with a DHCP server, Internet connectivity, and without a firewall or proxy that
blocks outgoing traffic to the internet
- Personal computer (PC) running Microsoft Windows® or MacOS
Accounts and Software
- Web browser for accessing software download sites and Medium One IoT Platform
- Login account for the Medium One IoT Platform
- Arduino Integrated Development Environment (IDE)
- Arduino add-on libraries that are downloaded and installed through the Arduino IDE
- Application project files available in a GitHub repository
- Wi-Fi access point connection details including SSID and password
Project Technology Overview
Infineon Technologies XENSIV™ Sensors - Getting Started Box IoT
The Xensiv™ Sensors - Getting Started Box IoT (Figure 1)
is
an IoT development kit featuring sensors, microcontrollers, and security chips. The hardware concept of
Shield2Go
uses a standardized form factor, pin layout, and solderless connectors that allow boards and sensors to be
easily connected together for multiple prototyping scenarios. The kit includes a Wi-Fi connectivity module for
creating IoT applications that communicate through the Internet. The combination of sensors, microcontrollers,
security chips and accessories offer developers a number of features for prototyping IoT designs:
- One XMC™ ARM® Cortex®-M0 Microcontroller base board in Arduino Uno form factor with
onboard J-Link debugger
- Two XMC™ ARM® Cortex®-M0 Microcontroller base boards in Shield2Go form factor with
onboard J-link debugger
- An ESP32-based Wi-Fi and BLE connectivity module in Wemos form factor
- XENSIV™ TLV493D-A1B6 3D Magnetic Hall Sensor with rotate knob and joystick add-ons
- XENSIV DPS310 Barometric Pressure Sensor, including temperature sensor
- XENSIV
TLI4970-D050T4 Current Sensor
- XENSIV IM69D130 Digital MEMS
Silicon Microphone
- OPTIGA™ Trust X Security Chip
- Dual Adapter board for connecting the ESP32-based Wi-Fi and BLE module (Wemos form factor) to
XENSIV™ sensors (Shield2Go form factor)
- My IoT Adapter for connecting Shield2Go boards and Arduino Uno compatible boards
- USB cable and solderless connectors
Technical documentation for the Getting Started Box IoT can be found here, here, and here, which includes detailed information about the boards and sensors
included in the kit.
Figure 1: Xensiv™ Sensors - Getting Started Box IoT
(Source: Mouser Electronics)
The boards are supported by the Arduino Integrated Development Environment (IDE) and connect to a PC using a USB
cable that supports programming from the IDE as well as microcontroller serial port connectivity. Arduino Uno
compatible boards and libraries can be used with the kit to enable a wide range of IoT prototyping capabilities.
Arduino Integrated Development Environment (IDE)
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, and a mechanism
for transferring binary program images to the microcontroller.
The microcontrollers in the Getting Started Box IoT can be programmed using the Arduino IDE which runs on
Windows, Mac, and Linux computers. It connects to the microcontroller boards using a USB cable that supports
programming as well as serial console printing from application programs. The Arduino IDE can be downloaded for
free from the Arduino web site.
Project Application Source Code Files
For this project, the Arduino IDE was used to create a project source code file that uses Infineon and Arduino
libraries to read the physical sensors and transmit the data to the Medium One IoT Platform through a Wi-Fi
connection to the Internet. The project files have been put in a GitHub repository that you can download and use
for this project. The project files will be opened in the Arduino IDE where they'll be compiled and downloaded
to the MH-ET Live ESP32 Minikit board that provides Wi-Fi connectivity to the Internet.
Medium One IoT Platform
The Medium One IoT Platform (Figure 2) 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 various formats. Medium One's iOS and Android
apps allow you to build simple mobile app dashboards that can communicate with your devices through the
platform.
Figure 2: Medium One IoT Platform (Source: Mouser Electronics)
IoT devices can exchange data with Medium One through either a REST API or MQTT. More detailed information about
the Medium One IoT Platform can be found here and on the Medium One site.
The Setup (Hardware)
While setting up the hardware, be sure to remember that electronic components are static-sensitive, so handle
accordingly.
Personal Computer (PC)
Power up the personal computer and allow it to boot up.
Wi-Fi Access Point
Make sure your Wi-Fi access point is running with an active connection to the Internet and a DHCP server that
assigns IP addresses. You'll need to know the access point SSID and password to be used later when configuring
the Wi-Fi connection.
Getting Started Box IoT
Unbox the Getting Started Box IoT and read through the Quick Start Guide found here
- MH-ET Live ESP32 MiniKit board
- Dual Adapter board equipped with OPTIGA™ Trust X
- TLV493D-A1B6 3D Magnetic Hall Sensor
- DPS310 Barometric Pressure Sensor
- Rotate knob
- Solderless connectors
- USB cable
Connect the solderless pin strips to the bottom side of the TLV493D-A1B6 board, being sure to omit three pins
near the screw hole (see Quick Start Guide). Attach the Rotate Knob to the TLV493D-A1B6 board and secure
from below using the included screw. Connect the solderless pins to the bottom side of the DPS310 board,
then plug the TLV493D-A1B6 board into Socket 1 of the Dual Adapter board and the DPS310 board into Socket 2.
Finally, plug the Dual Adapter board into the MH-ET Live ESP32 MiniKit board. The completed board assembly
should look like Figure 3 with the MH-ET Live ESP32 MiniKit board on bottom, the Dual
Adapter board in the middle, and the sensor boards on top.
Use the USB cable to connect the MH-ET Live ESP32 MiniKit board to the PC. LEDs should illuminate indicating
the boards are powered.
Figure 3: Assembled Board Stack (Source: Mouser Electronics)
The Setup (Software)
Download and Install the Arduino IDE
Download the Arduino IDE from the Arduino site and install on your PC. Be sure to select the correct version
for your type of PC (Windows, Mac, or Linux).
Download and Install the Board and Sensor Libraries
During this step, we'll be downloading code libraries for the ESP32 board and XENSIV sensors and installing
them into the Arduino IDE.
In the Getting Started Box IoT Quick Start Guide, follow the instructions for downloading
and installing the software for these components:
- ESP32 WEMOS D1 MINI
- TLV493D-A1B6 - 3D Magnetic Sensor
- DPS310 Digital Barometric Pressure Sensor
The quick-start guide instructions include links to GitHub repositories containing more detailed information
about the sensors.
Make sure you have selected the MH ET LIVE ESP32MiniKit board from the Arduino IDE
Tools→Board menu as described in the Quick Start Guide.
Next, install the PubSubClient library in the Arduino IDE by going to Sketch→Include
Library→Manage Libraries... and searching for PubSubClient. Once you
locate the library click Install to install the latest version. Note that other libraries
may also appear in search results; be sure to install the one named PubSubClient.
Download and Open the Project Application Source Code Files
Web browse to the GitHub repository https://github.com/IoTDevLabs/ma11_files and find the Infineon_MediumOne_1.0.0.zip
file. Download that file to your computer and unzip to create a directory named infineon_mediumone. Move
that entire directory to be under the Arduino project folder on your PC.
Open the infineon_mediumone project in the Arduino IDE using
File→Open...→infineon_mediumone > infineon_mediumone.ino. If infineon_mediumone
doesn't show appear in your File Open list, make sure you moved the infineon_mediumone directory from the
downloaded ZIP file to your Arduino project directory.
After opening infineon_mediumone.ino, the Arduino IDE should look like Figure 4. We'll come
back to the source code later after setting up Medium One.
Figure 4: After Opening the infineon_mediumone Project in Arduino IDE
(Source: Mouser Electronics)
Set Up the Medium One IoT Platform
Web browse to the Medium One IoT Prototyping Sandbox and log in, after which you should see
an initial dashboard resembling Figure 2. Click Setup→Manage Users→Add
New User. Set Username to mydevice, create a password of your
choosing 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 = mydevice and an
auto-generated user MQTT ID like Figure 5.
Figure 5: 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 6.
Figure 6: 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 mydevice, make sure Enabled is
check-marked, and click Save. The result should look like Figure 7.
Figure 7: Newly Created API Key (Source: Mouser Electronics)
The MQTT password is created by combining the API Key, a forward slash, and the mydevice user password. For
example, if the API Key is "PZxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMBQ" and the mydevice 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 "mydevice" 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/mydevice".
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 Medium One Account Parameters
Set Wi-Fi Connection Parameters
In the Arduino IDE source code window, find these constants and set them to your own Wi-Fi SSID and password
info:
Set Medium One Connection Parameters
In the Arduino IDE source code window, find these constants and set them to your own Medium One MQTT
parameter strings as described earlier:
- MQTT_USERNAME
- MQTT_PASSWORD
- MQTT_PUB_TOPIC
Verify that MQTT_PORT matches the port number you saw in the Medium One MQTT info screen (Figure
6) and update it if necessary.
Save the modified file and then build the project. Verify the code compiles without errors. If you see
compilation errors, check the changes you made to the Wi-Fi and MQTT configuration constants.
Run the Application
Make sure the ESP32 board is connected to the PC through USB. Compile the program and transfer it to the
board using the Upload button in the Arduino IDE (icon on toolbar or Sketch > Upload). The program should be
transferred to the board and start running.
Monitor the board serial port output in the Arduino IDE using Tools > Serial Monitor with baud rate set to
115200. You should see informational messages in the serial monitor as the board software runs.
How the Application Program Works
The application code performs these steps:
- Initialize serial port and sensor hardware
- Connect to Wi-Fi network and get IP address
- Initialize MQTT client
- Connect to Medium One MQTT broker
- Check whether it's time to get new sensor readings
- read sensors
- Generate a JSON formatted MQTT payload message and send to Medium One MQTT broker
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":{"timestamp":10000,"rot":163,"temp":72.64,"pres":29.32}}
Fields:
- timestamp = milliseconds since the application started
- rot = knob rotation in degrees ranging from -180 to +180
- temp = temperature in degrees F
- pres = barometric pressure in inches of mercury
Try rotating the knob and heating or cooling the temperature sensor to see the data 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 8) being received from the board.
Click the "+" sign to view message details.
Figure 8: 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 mydevice. You should now see messages
appearing in the Real Time Events Stream widget (Figure 9). Click the save icon in the
upper right corner to save your modified dashboard.
Figure 9: 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.pres, raw.rot, and
raw.temp, 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
mydevice user within the widget. Click the widget's Tag Config icon to the
right of the mydevice user selection and check-mark raw:pres, raw:rot, and
raw:temp, then click Save. The Last Value Table should now populate with
the most recent received values for each field (Figure 10). Click the Save icon toward the
upper right corner to save the updated dashboard.
Figure 10: Last Value Table Widget Display (Source: Mouser
Electronics)
Now let's add gauge-style dashboard widgets for the temperature, pressure, and rotation sensors. Click
Single User Real Time Gauge and select the mydevice user. Click the
widget's Tag Config icon and check-mark the raw:pres,
raw:rot, and raw:temp rows, then click Save The updated
dashboard should look like Figure 11. Click the dashboard save icon to save the updated
dashboard. Try heating or cooling the temperature sensor and rotating the knob to see the gauge values
change.
Figure 11: Real Time Gauge Widgets Added to Dashboard (Source: Mouser
Electronics)
At this point, your boards are running continuously, periodically reading the knob rotation, temperature and
pressure sensors, and transmitting data measurements to the Medium One cloud. Remember to power off the
board when you're done, otherwise, the board will continue to send messages to Medium One and consume daily
message allotments.
Where to Go Next
This project created an end-to-end sensor-to-cloud application that sends real-time sensor data to the Medium
One IoT Platform. It can be modified and extended in a number of ways and here are a few examples:
- Dive deeper into the application code and board hardware by reading the Getting Started Box IoT
documentation and studying the source code.
- Add more widgets to the Medium One dashboard, such as a real-time line chart of temperature and pressure
readings.
- Use the joystick accessory on the 3D Magnetic Sensor and modify the sensor and MQTT code to send
joystick position readings to Medium One.
- 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 application source code.
- Connect other types of sensors to the Dual Adapter board and include the data in MQTT messages.
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.