IoT Data Acquisition Using the Record Evolution Platform with MCC DAQ HAT 118
A step-by-step guide to connecting an MCC 118 board with a Raspberry Pi 4 and the IoT platform to read and extract analog measurement data.
Join the DZone community and get the full member experience.Join For Free
This tutorial guides you through the steps of connecting an MCC 118 board with a Raspberry Pi 4 and the Record Evolution platform to read to extract measurement data. In just a few steps, you set up a foundation for IoT data acquisition.
Here are the steps:
- Connect the MCC DAQ HAT 118 to a Raspberry Pi
- Connect the device to the Record Evolution Platform
- Build the app Data Logger MCC 118 onto the device
- Start collecting data
Connecting MCC 118 to Raspberry Pi to Measure Analog Voltage
It’s that simple: The MCC 118 header plugs into the 40-pin GPIO connector on Raspberry Pi.
Details About MCC 118
The MCC 118 is a voltage measurement DAQ HAT (Hardware Attached on Top) board made for use with Raspberry Pi. A HAT is an add-on board with a 40W GPIO (General Purpose Input/Output) connector conforming to the Raspberry Pi HAT specification. The MCC 118 HAT provides 8 single-ended (SE) analog inputs for voltage measurements.
Any analog sensor, e.g. temperature, sound, etc., can be used on the board. You can stack up to eight MCC HATs onto one Raspberry Pi. However, the onboard jumpers must be set in order to allocate the address to the MCC HATs.
Details about Raspberry Pi
Raspberry Pi is a tiny single-board computer. When used as an IoT device, Raspberry Pi offers a cost-efficient way to collect data. This is why we use Raspberry Pi as our default R&D device to acquire analog voltage data from the MCC 118 device with the help of an IoT app that is installed on the Raspberry Pi.
So to continue, you simply need to put the MCC 118 board onto a Raspberry Pi as shown below:
Connecting to The Record Evolution Platform For IoT & AI
Next, you need to connect the Raspberry Pi to the Record Evolution platform and bring it online. This is how you create the foundation for accessing and controlling the MCC 118 device via the Record Evolution platform.
In what follows, we will go through the following steps:
- Format/flash an SD card
- Connect your Raspberry Pi to the Record Evolution platform
- Bring your Raspberry Pi online
- Install an IoT app on the Raspberry Pi
This is what you need:
- An MCC 118 device
- A Raspberry Pi single-board computer (preferably a Raspberry Pi 4)
- An SD card (8 GB or higher)
- A Windows or a Mac computer with internet access
- Power supply
You may also want to use a self-powered USB hub.
Forming a Device Swarm and Establishing a Connection
From your homepage on the platform, go to Devices and click on ADD DEVICE SWARM to create your device management environment:
A swarm is your basic, compact, fully autonomous IoT device management environment on the Record Evolution platform. A swarm consists of a set of IoT devices, all device and device group settings, as well as the privilege structure specific to the assets of that swarm.
To add a new device, enter your newly created swarm and select NEW DEVICE from the menu. The first step is to create a virtual device on the platform:
To equip your physical device with the necessary system and configuration for the platform, you need to prepare and set up an individual SD card for that device.
The Flashing Process
To do that, download the Record Evolution Reflasher. This desktop app enables you to create bootable configured flash drives and is available for Windows, Linux, and macOS. If adding a device for the first time, you will trigger an automatic download of the Reflasher.
Now install the app on your computer and simply follow the instructions to go through the flashing process. Click on FLASH / FLASH ALL to continue. The app allows you to flash and configure multiple devices at once:
On the platform, you can connect to any Docker-capable device running on Linux from any location using a simple secure internet connection.
Build the Data Logger MCC 118 App on the Device
This app will take care of everything including the configuration of the MCC 118 device. Once built, the app can be run and the data can be collected either as a wave or binary files.
Using this app, you make voltage measurements of the MCC DAQ HAT channels and publish/log the data. The app continuously acquires blocks of analog input data for a user-specified group of channels and writes it into a user-specified file format.
Writing Data to a File
Depending on the parameter settings below, the data is written as a file into the configured folder. The data written to the file can be either of binary or wave format. Wave files are playable and written separately for each channel.
The binary file is written with an npz extension and contains important environmental variables as metadata. The metadata is saved under the params_mcc118 section whereas the sound data is saved under the data_mcc118 section. Below is an example of reading data from the binary file written by the app:
Installing the App
To use the app on the Raspberry Pi, simply retrieve the app from the Record Evolution app store and click on Install:
Once you hit Install, the device will start downloading the app. You will be redirected to your device swarm where you can observe the app status in the device settings:
In the group settings, click on the environmental variables and provide the environmental variables indicated in the app’s Readme file. If no environmental variables are provided, default values are used.
A Note For Developers
To develop and build the app, we are creating a Docker image you can run on the device. Detailed information about the installation of MCC DAQ HAT can be found in the git repository.
Published at DZone with permission of Zornitsa Dimitrova. See the original article here.
Opinions expressed by DZone contributors are their own.