Connecting the ADICUP3029 to the Medium One IoT Cloud
By Greg Toth for Mouser Electronics
The Analog Devices® EVAL-ADICUP3029 is an IoT development platform featuring an ultra-low power
Arm® Cortex®-M3 based mixed-signal microcontroller, Bluetooth®
and Wi-Fi connectivity, and expansion headers for Arduino® and Pmod™ add-on
boards. 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 ADICUP3029 to read a hardware sensor 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
- 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
- Personal computer (PC) running Windows®
Accounts and Software
- Web browser for accessing software download sites and Medium One IoT Prototyping Sandbox
- Login account for the Medium One IoT Prototyping Sandbox
- Analog Devices CrossCore® Embedded Studio™ integrated development
environment (IDE)
- Application project files available in a GitHub repository here
- Wi-Fi access point connection details including SSID and password
Project Technology Overview
Analog Devices EVAL-ADICUP3029
The ADICUP3029 (Figure
1) is an Arduino-like development platform based on the ADuCM302x family of
ultra-low power, integrated mixed-signal microcontroller systems for processing, control and connectivity. It
offers Bluetooth and Wi-Fi connectivity options for creating Internet of Things (IoT) applications that
communicate wirelessly with other systems and devices. The combination of board, microcontroller and onboard
components offer developers:
- ADuCM3029 32-bit ARM Cortex-M3 microcontroller
- 256kB flash memory
- 64kB SRAM memory
- Wi-Fi connectivity
- Bluetooth 5.0 connectivity
- Multiple analog and digital input/outputs
- Serial UART
- I2C
- Multiple SPI buses
- Onboard Serial Wire Debug (SWD) port for programming and debugging application code through a USB cable; can
also provide a virtual serial port connection to the ADuCM3029
- Two onboard LEDs
- Arduino Uno Rev3 compatible connectors
- 4-pin I2C Grove I/O connector
- I2C and SPI PMOD I/O connectors
- Battery holder
- DC power jack accepting 7V to 12V DC supply voltage
Technical documentation on the ADICUP3029 can be found here and here.
Figure 1: EVAL-ADICUP3029 Development Board (Source: Mouser
Electronics)
Analog Devices EVAL-ADT7420-PMDZ Temperature Sensor
The EVAL-ADT7420-PMDZ (Figure 2) is a high-accuracy digital temperature sensor that can
interface to the ADICUP3029 through its I2C PMOD connector. In can measure temperature in degrees Celsius with
an accuracy of +/- 0.25°C and is rated for operation over -40°C to 150°C temperature range.
Figure 2: EVAL-ADT7420-PMDZ Temperature Sensor (Source: Mouser
Electronics)
Technical documentation on the EVAL-ADT7420-PMDZ can be found here and here.
Analog Devices CrossCore Embedded Studio
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 ADICUP3029 can be programmed using Analog Devices CrossCore Embedded Studio, an Eclipse-based IDE that runs
on Windows and Linux computers. It connects to the ADICUP3029 using a USB cable that supports programming and
debugging. CrossCore Embedded Studio can be downloaded for free from the CrossCore Embedded Studio site.
Project Application Source Code Files
For this project CrossCore Embedded 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
CrossCore Embedded Studio IDE where they’ll be compiled and downloaded to the ADICUP3029 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 either a REST API or MQTT. More detailed information about
the Medium One IoT Prototyping Sandbox 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, security type, and security credentials
to be used later when configuring the board’s Wi-Fi module.
ADICUP3029 and EVAL-ADT7420-PMDZ
Unbox the ADICUP3029 board and Wi-Fi module and connect them together as described in the ADICUP User Guide found
here.
Connect the EVAL-ADT7420-PMDZ temperature sensor to the ADICUP3029 8-pin PMOD connector (P9), making sure to
match up the pin numbers correctly. The S2 UART switch should be in the WI-FI position and the S5 POWER switch
should be in the WALL/USB position.
Connect the ADICUP3029 board to the PC using the USB cable. You can verify your connection by checking to see if
a “DAPLINK” drive is displayed in on your local devices and drives list.
The Setup (Software)
Download and Install CrossCore Embedded Studio (CCES)
Download and install CrossCore Embedded Studio on your PC by following the instructions in the EVAL-ADICUP3029 User Guide and CrossCore Embedded Studio Quickstart User Guide. Use the registration
Serial Number printed on the card included in the ADICUP3029 box. Be sure to install the Device Family Pack,
Board Support Pack, Sensor Software Pack and Wi-Fi Software Pack as described in the CCES Quickstart Guide. You
can run the blink_example program to verify your hardware and software is working.
Download and Import the Project Application Source Code Files
Web browse to the GitHub
repository and find the ADuCM3029_ MediumOne_1.0.0.zip file. Click the .zip file, then click
Download to download it to your computer.
In CCES select File > Import… > 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 ADuCM3029_MediumOne project is checkmarked and click Finish.
After completing the import, the Project Explorer tab should look like Figure 4.
Figure 4: After Importing the Project Source Code Files into CrossCore
Embedded Studio (Source: Mouser Electronics)
We’ll come back to the source code files 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 an initial dashboard resembling
Figure 3. 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 checkmarked, 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
Open project file src/ADuCM3029_MediumOne.h in the editor. Find these variables and set them to
your own Wi-Fi SSID and password strings:
Set Medium One Connection Parameters
In the same src/ADuCM3029_MediumOne.h file, find these variables and set them to your own Medium
One MQTT parameter strings as described earlier:
- aMQTTTopicName
- aMQTTUsername
- aMQTTPassword
*** NOTE *** The ADI-WifiSoftware CMSIS Pack (version 1.0.1) is not able to connect to the Medium One
MQTT broker over TLS and this project uses unencrypted MQTT communications between the ADICUP3029 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 and then build the project. Verify the code compiles without errors. If you see
compilation errors, check the changes you made to src/ADuCM3029_MediumOne.h.
Run the Application
Make sure the ADICUP3029 board is connected to the PC through USB. Set up a debug configuration as described in
the CCES Quickstart User Guide and then run the program under the debugger. The program should be downloaded to
the board and the debugger should stop on the first line of the main() function. Use menu command Run
> Resume to start program execution. Monitor the CCES Console tab for messages about the program
starting, connecting to Wi-Fi, and transmitting data to Medium One.
How the Application Program Works
This program is derived from the Analog Devices ADuCM3029_IBMWatson_Greenhouse example application with the
following changes and enhancements:
- Interface with the EVAL-ADT7420-PMDZ temperature sensor
- Remove unused I/O functions
- Connect to the Medium One MQTT broker
- Periodically read the temperature sensor
- Add timestamp and loop count data elements
- 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":{"tempf":77.89999389648438,"timestamp":19193,"iteration":1}}
Fields:
- tempf = temperature in degrees Fahrenheit
- timestamp = board tick clock
- iteration = application loop counter
Try 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
ADICUP3029. 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.iteration, raw.tempf, and
raw.timestamp, 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 checkmark raw:iteration,
raw:tempf, and raw:timestamp values, 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 towards the upper right corner to save the updated dashboard.
Figure 10: Last Value Table Widget Display (Source: Mouser Electronics)
Now let’s add dashboard widgets for the temperature sensor and counters. Click Single User Real
Time Gauge and select the mydevice user. Click the widget’s Tag
Config icon and checkmark the raw:iteration, raw:tempf and
raw:timestamp 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 to see the gauge values change.
Figure 11: Real Time Gauge Widgets Added to Dashboard (Source: Mouser
Electronics)
At this point your ADICUP3029 board is running continuously, periodically reading the temperature and
transmitting data measurements to the Medium One cloud. Remember to power off the ADICUP3029 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 Prototyping Sandbox. 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 ADICUP3029 documentation and
studying the source code
- Add more widgets to the Medium One dashboard, such as a real-time line chart of temperature readings
- 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 ADICUP3029 application source code
- Connect other types of sensors to the ADICUP3029 board and include the data in MQTT messages
- Enhance the MQTT communications to support MQTT over TLS
Don’t forget to let us know if you tried this project out for yourself. How well did the project work for
you? Would you expand upon it? Have questions? If so, let us know on Facebook, Twitter, or LinkedIn.
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.