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 guide describes the implementation of an industrial use case using Intel® IoT Gateway and the IBM Watson* IoT Platform running on IBM Bluemix*. The building blocks for implementing this use case are described in Connecting to the IBM Watson* IoT Platform with Intel® Gateway IoT Software Suites. That guide covers setting up an Intel IoT Gateway, connecting sensors, setting up the IBM Watson IoT Platform running on Bluemix, and connecting the gateway to the Watson IoT Platform so that you can send real-time sensor data to the cloud for storage and processing.
Use Case and Business Imperative
The use case is a facility for storing bulk sugar used in industrial baking. The ideal storage conditions for sugar are at a temperature of 20–25°C with a relative humidity (RH) of 55–60 percent. When stored under proper conditions, sugar has a shelf life measured in years. When conditions are outside ideal ranges, several issues arise:
- Temperature greater than 25°C promotes caking because water vapor is released.
- An RH less than 50 percent promotes caking, hardening, and loss of flowability.
- An RH greater than 70 percent promotes syrup formation, tackiness, and mold and yeast growth.
- Temperature variations up and down cause the release of water vapor and recrystallization, which results in agglomeration (sticking together). It also leads to crust formation on storage container walls.
The storage facility has traditionally used manual techniques to take periodic temperature and humidity measurements at the beginning and end of the work day, evaluate the readings to detect issues and take corrective actions, and maintain records for historical purposes. This process is labor intensive, doesn’t measure conditions 24 hours a day every day, and can fail to detect temperature up/down cycles that degrade the sugar. It’s also difficult to evaluate the storage conditions over long periods of time, which is important, as the amount of sugar stored fluctuates throughout the year due to variations in baking cycles.
The storage facility wants to expand its business but realizes that its current approach to managing storage conditions won’t scale. After conducting a series of business strategy sessions involving the marketing, sales, IT, and operations teams, the company identified several operational objectives to help grow and scale the business:
- Automate the process of continuously measuring temperature and humidity in the storage silo.
- Automatically detect temperature or humidity issues and alert the operations team so that it can take corrective actions.
- Have all the measurement data in one place so that up/down variations in temperature can be detected and evaluated over time (including as the seasons change).
- Be able to view current and historical measurement data.
- Have the data in a computerized format so it can be used to demonstrate to prospective customers how the company ensures a high-quality product through continuous monitoring of storage conditions.
Implementation Approach
To implement this use case, you’ll use the following components. Use Connecting to the IBM Watson* IoT Platform with Intel® IoT Gateway Software Suites to get these components up and running.
Intel® IoT Gateway and Temperature/Humidity Sensor
An Intel® NUC Kit DE3815TYKE gateway running an Intel® Atom™ processor will reside onsite at the storage facility. The gateway will be used to control an industrial temperature and humidity sensor (OMEGA* RH-USB) mounted in each storage silo. It has a stainless steel housing and is suitable for either wall or duct mounting. The sensor measures temperature from -17 to 49°C (±1°C accuracy). It measures RH from 2 percent to 98 percent (±3 percent accuracy). The sensor provides standard USB output, which you use to read temperature and humidity data using the gateway.
You will write the software on the gateway in Node-RED*, which is a graphical tool for wiring Internet of Things (IoT) applications. The gateway software will periodically read the sensors, format and combine readings into a measurement data set, and securely transmit the data to the IBM Watson* IoT Platform for further processing.
IBM Bluemix
Bluemix is a cloud platform for hosting scalable services, applications, and data. You will use it to run the IBM Watson IoT Platform and IBM Watson IoT Platform Analytics Real-Time Insights services.
IBM Watson IoT Platform
The IBM Watson IoT Platform allows you to connect devices and gateways securely to the Bluemix cloud so that you can exchange data with other services and applications. It also provides tools that allow you to view device status and monitor real-time device data feeds.
IBM Watson IoT Platform Analytics Real-Time Insights
This service allows you to monitor and contextualize data from your devices and gateways, visualize what’s happening in your operations, and respond through automated actions. You’ll use this service to create rules and automated actions driven by the temperature and humidity measurements coming from the gateway.
Prerequisites and Overview of Changes
Connecting to the IBM Watson* IoT Platform with Intel® IoT Gateway Software Suites provides step-by-step details for setting up your Intel® IoT Gateway with an RH-USB sensor, establishing a Bluemix account, and creating instances of the IBM Watson IoT Platform and IoT Real-Time Insights services on Bluemix. Complete those steps, and then verify that real-time temperature and humidity readings appear on the gateway’s Intel® IoT Gateway Developer Hub portal and real-time temperature appears on the Watson IoT Platform dashboard. That configuration will be the basis for changes and additions to implement this use case.
Gateway Changes
On the Intel® IoT Gateway, you’ll make the following changes to the base configuration described in Connecting to the IBM Watson* IoT Platform with Intel® IoT Gateway Software Suites:
- Modify the Node-RED flow to treat the RH-USB sensor as a separate device attached to the gateway.
- Report temperature and humidity in a combined data message sent from the gateway to The IBM Watson IoT Platform.
IBM Watson IoT Platform Changes
On the IBM Watson IoT Platform, you’ll make the following changes to the base configuration described in Connecting to the IBM Watson* IoT Platform with Intel® IoT Gateway Software Suites:
- Create a new device type for the OMEGA RH-USB sensor.
- Enable historical data storage in the IBM Watson IoT Platform.
- Send sensor data to IoT Real-Time Insights using a data schema.
- Create rules that monitor temperature and humidity thresholds and trigger actions when they are out of bounds.
- Create actions to send a text message and email when temperature or humidity readings are out of bounds.
Implementation Details
To implement the use case, you must make some changes and additions to both the gateway and the IBM Watson IoT Platform using what was covered in Connecting to the IBM Watson* IoT Platform with Intel® IoT Gateway Software Suites as the starting point. Log in to the Intel® IoT Gateway Developer Hub and your IBM Watson IoT Platform account using two separate browser sessions. You want to be able to access both systems quickly during these steps.
You make changes marked with Gateway on the Intel IoT Gateway. Make changes marked with IBM Watson IoT Platform on the IBM Watson IoT Platform service and changes marked with IoT Real-Time Insights on the IoT Real-Time Insights service.
Gateway: Your starting Node-RED flow in the Intel IoT Gateway Developer Hub looks like Figure 1.
This flow reads the RH-USB temperature and humidity sensor once per second, displays real-time temperature and humidity values in the Intel IoT Gateway Developer Hub portal, and sends the temperature readings to the IBM Watson IoT Platform, where they’re displayed on the IBM Watson IoT Platform dashboard.
Figure 1. The starting Node-RED flow in the Intel® IoT Gateway Developer Hub portal.
IBM Watson IoT Platform:
Complete the following steps:
- On the Devices page, click the device types tab, and then click Create Type.
- Click Create device type, and then set the name to RH-USB and the description to Temperature and humidity sensor. Click Next.
- On the template page, select the Manufacturer and Model check boxes, and then click Next.
- Set the manufacturer to Omega and the model to RH-USB, and then click Next.
- Leave the optional metadata blank, and then click Create.
You should now see two device types in the IBM Watson IoT Platform dashboard (Figure 2).
Figure 2. Your two devices in the IBM Watson IoT Platform dashboard.
- Click the browse tab, and then click Add Device.
- Choose the RH-USB device type, and then click Next.
- For Device ID, type RH-USB-1, and then click Next.
- Leave the optional metadata blank, and then click Next.
- For Security, you’ll use Auto-generated authentication token, so click Next to use that option.
- Review the summary page, and then click Add.
After adding the device, you see the device credentials. Copy the Organization ID and Authentication Token strings to a text file and save it for later use (Figure 3). After you close this page you won’t be able to see the auto-generated authentication token again, and you would have to re-create the device to get a new one.
Figure 3. Credentials for your RH-USB device.
You should now see two devices in your device list in the IBM Watson IoT Platform dashboard (Figure 4).
Figure 4. You have now added two devices to the IBM Watson IoT Platform.
Gateway:
On the Node-RED canvas, double-click the RH-USB node, and then click Edit flow. The details of the RH-USB node open in a new tab (Figure 5).
Figure 5. The details of your RH-USB node open in a new tab.
Click the plus sign (+) shown in callout 1 in Figure 5 to increase the number of outputs from 2 to 3. Doing so adds a third output that you can reposition to be below output 1 on the flow. Double-click the function node (see callout 2) to edit it. Increase the number of outputs to 3, add the extra code shown in Figure 6, and then click Ok.
Figure 6. Extra code for the new function node.
This change causes the third output of the RH-USB node to emit a combined temperature and humidity object that you’ll use to send temperature and humidity measurements to the IBM Watson IoT Platform. Wire the third output of the function to output 3, and then add a comment node to describe the third output. The resulting flow should look like Figure 7.
Figure 7. The flow after wiring the third output of the function node to output 3 and adding a comment node.
Deploy your flow changes to the gateway to make them active.
On Sheet 1 of your Node-RED flow, drag another IBM Watson IoT Platform output node onto the canvas and set its properties as follows (Figure 8):
- Connect as: Gateway (Registered)
- Credentials: Watson IoT Gateway Credential
- Device Type: RH-USB
- Device Id: RH-USB-1
- Event type: event
- Format: json
- Name: Send to Watson IoT Registered w/Device ID RH-USB-1
Figure 8. Properties for the new output node.
Click Ok. Note that you’re specifying the RH-USB device type and RH-USB-1 device instance that you created in the IBM Watson IoT Platform. You set up the Watson IoT Gateway Credential in Connecting to the IBM Watson IoT Platform with Intel® IoT Gateway Software Suites; it defines the name and device ID of the gateway itself.
Delete the Node-RED wires going into the Send to Watson IoT Quickstart and Send to Watson IoT Registered nodes, and connect a wire from the third output of RH-USB to the input of Send to Watson IoT Registered w/Device ID RH-USB-1. This path sends the temperature and humidity data to the IBM Watson IoT Platform. The updated flow should look like Figure 9.
Figure 9. The updated flow after connecting a wire from the third output of the RH-USB node.
Deploy the updated flow to make it active on the gateway.
IBM Watson IoT Platform
Navigate to the Devices page and click the RH-USB-1 device. In the Recent Events section you should see a series of events: These are the temperature and humidity readings coming from the gateway. Click an event to see the reported data.
At this point, you have live temperature and humidity data flowing from the RH-USB sensor to the gateway. The gateway combines and preprocesses the data, and then generates data packets that it sends to the IBM Watson IoT Platform. Next, you add functionality to the IBM Watson IoT Platform to process the data packets.
IoT Real-Time Insights
Go to your Bluemix dashboard, and then click IoT Real-Time Insights to access the IoT Real-Time Insights dashboard. You must define a schema that describes the data packet coming from the sensor. To do so, complete the following steps:
- In the navigation links toward the top, click Devices, and then click Manage Schemas.
- Click Add new message schema.
- On the Message Schema page, in Name, type Temperature_Humidity.
- Click Link data source, and then choose Intel IoT Gateway for Data source. For Device type, choose RH-USB. Leave Event set to + (All events), and then click OK.
- Click Add data points, and then choose Add from connected device. Select d, temperature, and humidity, and then click OK.
- Verify that your schema looks like Figure 10, then click OK to add it.
Figure 10. Your new message schema.
- Navigate to Devices, then click Browse Devices.
- Click RB-USB-1.
You should see live sensor data, which should match the readings on the gateway’s Intel® IoT Gateway Developer Hub portal (Figure 11).
Figure 11. The sensor data in your gateway’s Intel® IoT Gateway Developer Hub portal.
Next, add business logic to monitor temperature and humidity conditions and send email and text alerts when they are out of range. To do so, complete the following steps:
- Navigate to Analytics, and then to Rules.
- Click Add new rule.
- Set the following fields (Figure 12):
- Name – Temperature problem
- Description – Temperature is outside desired range
- Message schema – Temperature_Humidity
Figure 12. Adding rules for your sensor data.
- Click Next.
Now you see the rule editor, which is organized as a series of "If This Then That" (IFTTT) rules. If conditions use AND and OR logic to define trigger conditions. You define one or more actions in the THEN section to perform actions when the trigger conditions occur.
To monitor the storage temperature range, define an IF condition that detects temperature readings too low or too high. Complete the following steps:
- Click New condition.
- Complete the data fields as follows:
- Compare to: Select Data Point.
- Data point: Click Select data point, and then choose temperature in the d data set.
- Operator: Choose <.
- Compare with: Choose Static value.
- Value: Type 20.
- Click OK.
- Click the plus sign under OR, and then add another condition for temperature > 25:
- Compare to: Select Data Point.
- Data point: Click Select data point, and then choose temperature in the d data set.
- Operator: Choose >.
- Compare with: Choose Static value.
- Value: Type 25.
Figure 13 shows the complete dialog boxes.
Figure 13. Completed properties for your IF…THEN rules.
- Click Trigger every time conditions are met, and then set the frequency requirement to trigger if conditions are met 10 times in 15 minutes (Figure 14).
Figure 14. Set the frequency requirement for your IF…THEN condition.
- Click Save.
- In the THEN section, click New action, and then click Add action.
- You’ll create an email action that sends a notification email to the operations team.
- Fill out the fields as follows, and then click OK:
- Type: Send email
- Name: Send email to ops team
- To: <Email address to receive notifications>
- CC: <Additional email address, if desired>
- Subject: Temperature problem in sugar storage
- Select Prepend with "IoT Real-Time Insights alert"
Figure 15 shows the completed dialog box.
Figure 15. The completed Add New Action dialog box.
- Click the newly created action in the Set the action dialog box, and then click OK to add the action to the THEN section.
- In the THEN section, click the plus sign next to the email action to add a second action.
- Complete the files as follows:
- Type: Send email
- Name: Send email to ops team
- To: <Mobile phone’s email-to-text address>
- CC: <Additional email address, if desired>
- Subject: Temperature problem in sugar storage
- Select "Do not include device data in the email message"
Figure 16 shows the completed dialog box.
Figure 16. The completed Edit Action dialog box.
Your IF…THEN rule set should look like Figure 17.
Figure 17. The completed IF…THEN rule set.
- Change the Alert priority to High, and then click Save.
All the actions you define you can view and update by clicking Analytics, and then clicking the Actions tab in IoT Real-Time Insights. Actions include sending email, calling a webhook, invoking a Node-RED flow running in Bluemix, and triggering an IFTTT action.
Your new rule should show on the Analytics > Rules page and currently be in the Deactivated state (Figure 18). Click the gear icon on the Temperature rule, and choose Activate. Keep in mind that for the IoT Real-Time Insights free plan, rules can only be active for 1 hour, after which they are automatically deactivated.
Figure 18. Your new rule on the Analytics > Rules page.
Test the rule by raising the temperature of the RH-USB sensor above 25°C for at least 15 seconds. You should receive an email message and a text message from IoT Real-Time Insights similar to Figure 19.
Figure 19. Sample alert from IoT Real-Time Insights for an out-of-bounds temperature reading.
Next, add a rule to monitor the humidity range. Complete the following steps:
- Add a new rule named Humidity problem.
- Use the d.humidity data point.
- Add two condition checks using the OR operator: one for humidity < 55 and one for humidity > 60.
- Set the trigger frequency to 10 times in 15 minutes.
- Create and add two new actions named Send humidity email to ops team and Send humidity text to ops team.
- Save the rule, and then activate it.
The completed rule should look like Figure 20.
Figure 20. New rule to monitor the humidity range of your sensor.
When humidity is out of range, IoT Real-Time Insights generates an email and text alert, similar to the temperature case.
Bringing It All Together
At this point, a real-time monitoring solution is in place that will notify the operations team when storage conditions are outside the desired range. To take it further, you can use the power of the Intel® IoT Gateway Technology combined with the IBM Watson* IoT Platform and Bluemix* to implement a variety of additional functionality. Here are a few ideas.
With respect to the gateway, you could connect more temperature and humidity sensors or combine data from multiple sensors and send to the IBM Watson IoT Platform. You could drive a live temperature and humidity display and control temperature or humidity remediation devices. In addition, consider using the built-in security features to harden your gateway.
For the IBM Watson IoT Platform and other services on Bluemix, you could send temperature and humidity data to a database for long-term retention. Dashboard displays could be added to show sensor data and monitoring alerts or display sensor locations on a map. By adding more complex data analytics and machine learning, you could spot trends and detect undesirable temperature cycling patterns. You can even create and host a mobile app that lets you view storage conditions on a mobile device. The possibilities are virtually limitless.