The Raspberry Pi® is a single-board computer that runs the Linux® kernel-based operating system and provides easy connections to peripheral devices, including a monitor, mouse, keyboard, and MCC data acquisition devices. With a cost of less than $40, the Raspberry Pi provides a cost-effective way to perform data acquisition. You can acquire data from most Measurement Computing USB DAQ devices using the Raspberry Pi and UL for Linux.
Acquire data from an MCC DAQ device using a test application installed on a Raspberry Pi computer.
This document provides information about how to perform the following tasks:
- Format an SD card
- Install an operating system onto the Raspberry Pi
- Configure Raspberry Pi options
- Install Universal Library for Linux drivers and build the library
- Run an MCC Linux test app
This document is intended for application developers familiar with MCC DAQ devices who are interested in acquiring data on a Linux platform using a Raspberry Pi.
The following equipment is needed to perform the exercises:
- Raspberry Pi single-board computer – For this example, Raspberry Pi 3 model b is used, but you can use any Raspberry Pi model
- SD card (8 GB or higher)
- PC or Mac® with internet access
- Ethernet® cable or wireless adapter (The Pi model used here has built in WiFi)
- Monitor or television + HDMI cable
- Power supply
- Mouse or trackball
- MCC DAQ device – I'm using a USB-1808X to perform data acquisition tasks
Click here for a listing of MCC DAQ devices supported under Linux® and compatible with Raspberry Pi.
The image below shows the Raspberry Pi configuration used to perform these exercises.
Using an SD to Install the Operating System
You must install an operating system onto the Raspberry Pi before it can be used. This example uses Raspbian, which is a free operating system based on Debian, optimized for the Raspberry Pi hardware. NOOBS (New Out Of the Box Software) is an operating system install manager for the Raspberry Pi, and is used to install Raspbian in this example.
You use an SD card to transfer NOOBS onto the Raspberry Pi. The SD card must be formatted to remove all previous information. The following procedures show you how to perform these steps.
Watch the Video! Go to http://www.raspberrypi.org/help/noobs-setup/ to see a video showing how to format the SD card, download NOOBS, and install the Raspbian OS onto the Raspberry Pi.
Format the SD card
Perform the following steps to format the SD card:
- Go to www.sdcard.org and click SD Memory Card Formatter button.
- Scroll to the page bottom and select the SD formatter for Windows or Mac, follow the on-screen prompts, and then save the download on the computer.
- Install the SD card into your PC or Mac and run the SD_CardFormatter0500SetupEN.exe (SD formatter executable).
Install the Operating System onto the Raspberry Pi
Perform the following steps to download NOOBS and install the OS onto the Raspberry Pi:
- Go to www.raspberrypi.org and click Downloads.
Under the NOOBS section click Download Zip and save the file to your PC or Mac.
- Expand the zip file and copy all files to the SD Card.
- Remove the SD card from your PC or Mac, and install it into the Raspberry Pi.
- Connect the monitor, keyboard, mouse, and power.
Connecting power will boot the Raspberry Pi.
The Raspberry Pi Logo displays, followed by a NOOBS dialog box which shows a list of operating systems to install.
- Check the Raspbian checkbox and click Install, then select Yes on the Confirm dialog box to install Raspbian.
A dialog box notifies you when installation is complete.
- Click OK; the Raspberry Pi starts loading Raspbian.
If this is the first time booting Raspbian, a Setup Options menu appears. Use the keyboard arrow keys to navigate the menu.
- Set the configuration options, such as the language and regional settings to match your location.
- Tap <Finish> and press <Enter> when done setting configuration options.
The command prompt displays pi@raspberrypi~$
Congratulations! You have now installed the Raspberry Pi operating system.
Each time you boot up the Raspberry Pi you are prompted for the following login information:
raspberrypi login: pi
The command prompt displays pi@raspberrypi~$
Verify Internet Access
Before downloading UL for Linux, verify that the Raspberry Pi can access the internet. You can connect an Ethernet cable or connect a USB WiFi adapter to connect with a wireless network. This example uses the Pi’s built in WiFi adapter.
- Double-click the WiFi Config icon on the desktop to start the wireless configuration program. The Adapter: field lists the name of the USB wireless adapter (for example wlan0); the Network: field is empty.
- Click Scan to list the available wireless networks.
- Double click on the service set identifier (SSID) network name to which you want to connect.
- Verify the Authentication and Encryption fields on the connection window, and enter the password in the PSK (pre-shared key) field.
- Click Add.
The configuration program automatically connects to the newly configured network.
- Cycle the device power to reboot the Raspberry Pi and enter the login information above.
After logging in, the command prompt displays pi@raspberrypi~$.
Update the Raspberry Pi Package List
To ensure that you have the latest Raspberry Pi software versions for each package installed, enter the following code from the terminal window to update the Raspberry Pi package list.
$ sudo apt-get update
UL for Linux
To build and install the latest version of the library, refer to the instructions on GitHub at: https://github.com/mccdaq/uldaq
MCC example apps are developed on Linux and are available for Linux supported MCC devices in C and Python. The example apps perform all the device functions such as acquire analog, counter, and digital data (as supported), test device functionality, and display device information.
Refer to https://github.com/mccdaq/uldaq, click on the link for ULHELP and select Index.html for the names of each test/example app. Pick an appropriate test app for your device.
Example apps are located in the examples folder. Run the following commands to execute the analog input example:
There are example apps for each feature of supported devices, for example:
Each example performs a specific function of a supported device and is well commented for your review. Additional prompts appear if more information is needed, such as a channel number or frequency value. The examples run and the results displayed on the monitor.
Contact Measurement Computing Corporation if you have questions about acquiring data with the Raspberry Pi:
For more information about the Raspberry Pi, go to www.raspberrypi.org.
Measurement Computing Corporation and the Measurement Computing logo are either trademarks or registered trademarks of Measurement Computing Corporation.
Raspberry Pi is a trademark of the Raspberry Pi Foundation.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
All other trademarks are the property of their respective holders.
Additional TechTips are available on our Data Acquisition Technical Articles web page.