Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.
This shop-floor equipment activity monitor application is part of a series of how-to Intel® Internet of Things (IoT) code sample exercises using the Intel® IoT Developer Kit, Intel® IoT Gateway, Intel® Edison board, cloud platforms, APIs, and other technologies.
From this exercise, developers will learn how to:
- Connect the Intel® Edison board or Intel® IoT Gateway, computing platforms a computing platform designed for prototyping and producing IoT and wearable computing products.
- Interface with the Intel® Edison board or Arduino 101* (branded Genuino 101* outside the U.S.) board IO and sensor repository using MRAA and UPM from the Intel® IoT Developer Kit, a complete hardware and software solution to help developers explore the IoT and implement innovative projects.
- Run these code samples in the Intel® System Studio IoT Edition (Eclipse IDE for C/C++ and Java* development) for creating applications that interact with sensors and actuators, enabling a quick start for developing software for the Intel® Edison board or Intel® Galileo board.
- Store the equipment usage data using Azure Redis Cache* from Microsoft, Redis Store* from IBM Bluemix*, or ElastiCache* using Redis* from Amazon Web Services (AWS)*, different cloud services for connecting IoT solutions including data analysis, machine learning, and a variety of productivity tools to simplify the process of connecting your sensors to the cloud and getting your IoT project up and running quickly.
- Set up a MQTT-based server using IoT Hub from Microsoft Azure*, IoT from IBM Bluemix*, or IoT from Amazon Web Services (AWS)*, different cloud machine to machine messaging services based on the industry standard MQTT protocol.
What it is
Using an Intel® Edison board, this project lets you create a shop-floor equipment activity monitor that:
- tracks equipment usage by monitoring sound and vibration sensors.
- provides a visual notification whenever the equipment is in use.
- logs equipment usage data using cloud-based storage.
How it works
This equipment activity monitor checks for sound and vibration.
If both parameters cross a predefined threshold, the display is lit to indicate the equipment is in use.
Once the equipment is no longer being used, the monitor clears the display.
Optionally, equipment usage start/stop events can be stored using the Intel® IoT Examples Data store or on an MQTT server running in your own Microsoft Azure*, IBM Bluemix*, or AWS* account.
Grove* Starter Kit containing:
- Intel® Edison board with an Arduino* breakout board
- Grove Base Shield V2
- Grove Sound Sensor
- Grove Piezo Vibration Sensor
- Grove RGB LCD
DFRobot* Starter Kit for Intel® Edison board, containing:
- Intel® Edison board with an Arduino* breakout board
- Analog Sound Sensor.
- Digital Vibration Sensor
- LCD Keypad Shield
- Intel® System Studio (Eclipse IDE for C/C++ and Java* development)
- Microsoft Azure*, IBM Bluemix*, or AWS* account (optional)
How to set up
This sample is already one of the IoT examples included in Intel® System Studio. To start using it, follow these steps:
- From the main menu, select Intel® IoT > Import IoT Examples.
- Expand the tree view for C++ > How To Code Samples > Equipment Activity Monitor and click Import Example.
- Select your developer board from the selection window then select Next.
- Select Intel® IoT C/C++ project from the Select a project type window then click Next.
- Select Yocto from the Selct target OS dropdown menu then click Next.
- The next tab will ask for connection name and target name. If you do not know these click Search Target.
- Select your Edison from the dropdown list. Select OK.
- Your connection name and target name should be filled in. Select Finish.
- A new window will open for you and you will need to choose a name for your project and click Next.
- Your project source files will now be available on the on the upper left of your IDE by default.
Connecting the Grove* sensors
You need to have the Grove* Base Shield V2 connected to an Arduino* compatible breakout board to plug all the Grove devices into the Grove Base Shield V2. Make sure you have the tiny VCC switch on the Grove Base Shield V2 set to 5V.
- Plug one end of a Grove cable into the Grove Sound Sensor, and connect the other end to the AO port on the Grove Base Shield V2.
- Plug one end of a Grove cable into the Grove Piezo Vibration Sensor, and connect the other end to the A2 port on the Grove Base Shield V2.
- Plug one end of a Grove cable into the Grove* RGB LCD, and connect the other end to any of the I2C ports on the Grove Base Shield V2.
Connecting the DFRobot* sensors
You need to have a LCD Keypad Shield connected to an Arduino* compatible breakout board to plug all the DFRobot* devices into the LCD Keypad Shield.
Plug one end of a DFRobot* cable into Analog Sound Sensor, then connect the other end to the A3 port on the LCD Keypad Shield.
Plug one end of a DFRobot* cable into the Digital Vibration Sensor, then connect the other end to the A2 port on the LCD Keypad Shield.
Intel® Edison board setup
This example uses the restclient-cpp library to perform REST calls to the remote data server. The code can be found in the lib directory. The restclient-cpp library requires the libcurl package, which is already installed on the Intel® Edison board by default.
Intel® IoT Gateway setup
You can run this example using an Intel® IoT Gateway connected to an Arduino 101* (branded Genuino 101* outside the U.S.).
Make sure your Intel® IoT Gateway is setup using Intel® IoT Gateway Software Suite, by following the directions on the web site here:
The Arduino 101* (branded Genuino 101* outside the U.S.) needs to have the Firmata* firmware installed. If you have IMRAA installed on your gateway, this will be done automatically. Otherwise, install the StandardFirmata or ConfigurableFirmata sketch manually onto your Arduino 101* (branded Genuino 101* outside the U.S.).
Data store server setup
Optionally, you can store the data generated by this sample program in a back-end database deployed using Microsoft Azure*, IBM Bluemix*, or AWS*, along with Node.js*, and a Redis* data store.
For information on how to set up your own cloud data server, go to:
MQTT server setup
You can also optionally store the data generated by this sample program using MQTT, a Machine To Machine messaging server. You can use MQTT to connect to Microsoft Azure*, IBM Bluemix*, or AWS*.
For information on how to connect to your own cloud MQTT messaging server, go to:
Configuring the example for your hardware kit
To configure the example for the specific hardware kit that you are using, either Grove* or DFRobot*:
- From the main menu, select Project > Properties dialog box is displayed.
- Expand the section C/C++ General.
Click on the Paths and Symbols sub-section, and click on the Symbols tab.
- Now click on GNU C++, and click on the Add button.
- In the Name field, enter "INTEL_IOT_KIT". In the Value field, enter either "GROVEKIT" (this is the default) or "DFROBOTKIT", depending on which hardware kit you wish to use.
- Your new name symbol and value will now be displayed. Click OK.
- Another dialog box will appear asking to rebuild project. Click OK.
Connecting your Intel® Edison board or Intel® IoT Gateway to Intel® System Studio
- On the Target SSH Connections tab, right-click your device and select Connect.
If prompted for the username and password, the username is root and the password is whatever you specified when configuring the Intel® Edison board.
Running the example with the cloud server
To run the example with the optional backend data store, you need to set the
AUTH_TOKEN environment variables. You can do this in Eclipse as follows:
From the Run menu, select Run Configurations.
The Run Configurations dialog box is displayed.
Under C/C++ Remote Application, click doorbell.
This displays the information for the application.
In the Commands to execute before application field, add the following environment variables, except use the server and authentication token that correspond to your own setup:
chmod 755 /tmp/equipment-activity;export SERVER="http://intel-examples.azurewebsites.net/logger/equipment-activity"; export AUTH_TOKEN="YOURTOKEN"
Click Apply to save your new environment variables.
Now when you run your program using the Run button, it should be able to call your server to save the data right from the Intel® Edison board Intel® IoT Gateway.
Running the code on the Intel® Edison board or Intel® IoT Gateway
When you're ready to run the example, click Run at the top menu bar in Intel® System Studio.
This compiles the program using the Cross G++ Compiler, links it using the Cross G++ Linker, transfers the binary to the Intel® Edison board Intel® IoT Gateway, and then executes it on the board itself.
After running the program, you should see output similar to the one in the image below.
Successful output should be similar to the one in the image below.
The LCD should now display
IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments.