How-To Guides
Flows Guides

Create Audio Notifications for Sensor Readings

1min

You can use Flows to create dashboards to notify you when sensor anomalies occur.

User Scenario

Imagine a situation in an automobile assembly plant temperature sensors detect readings that are beyond the normal range. In such a scenario, the system can immediately trigger an audio alert, which can help to quickly address potential issues.

To create a flow that notifies you of temperature reading alerts:

  1. In Manufacturing connect Edge, navigate to the Flows Manager and create a new flow. See Create a Flow to learn more.
  2. Drag an Inject node, Function node, and Serial out node onto the canvas and connect them.
  3. Create a new connection by adding Serial in, Function, and Audio out nodes to the canvas and connecting them together. The two connections should be connected as shown below.

    Flows canvas
    Flows canvas
    
  4. Double-click either the Serial in or Serial out node. The Edit serial node dialog box appears.
    • Serial Port: Click the Edit icon. The Edit serial-port node page opens.
      • Create a configuration for the connected device. Make sure that the Serial Port and Baud rate match the device information.
      • Click Update.
    • Click Done.
  5. Repeat step 4 to configure each serial node in the flow.
  6. Double-click the Inject node. The Edit inject node dialog box appears.
    • msg.payload: Select string from the drop-down option and enter a string message that requests the desired data from it. In this use case, F is used to request temperature data in Fahrenheit from the sensor.
    • Repeat: Set an interval to have the node automatically request data after every one second.
    • Click Done.

      Edit inject node dialog box
      Edit inject node dialog box
      
  7. Double-click the Audio out node. The Edit audio out node dialog box appears.
    • TTS Voice: Select a voice to use.
    • Play audio when window not in focus: Select the check box to hear the alert when the flow is minimized.
    • Group: If needed, click the Edit icon to create a dashboard.
    • Name: Enter a user-defined name.
    • Click Done.

      Edit audio out node dialog box
      Edit audio out node dialog box
      
  8. Double-click the Function node connected to the Inject node and Serial out node. The Edit function node dialog box appears.
    • On Message: Enter code that adds a carriage return to the message to ensure that the device reads it properly. msg.payload = msg.payload + "\r"; // Add a carriage return to the output. return msg;
  9. Double-click the Function node connected to the Serial in node and Audio out node. The Edit function node dialog box appears.
    • On Message: Enter code that checks for the sensor reading and outputs a message when it is above or below a certain threshold. var val = parseFloat(msg.payload); // Gets the temperature in degrees Fahrenheit from the string sent by the device. if (val > 70.0) { // Checks for if the temperature is higher than 70 deg F msg.payload = "high"; // Sets the notification message to say "high" when the temperature is high. } else { msg.payload = "low"; // Sets the notification message to say "low" when the temperature is lower than 70 deg F. } return msg;
  10. Click Deploy and expand the message window beneath the flow.
  11. Click the Dashboard icon. Then, click the Expand icon to open the dashboard to begin hearing the audio notifications.

    The expanded dashboard icon
    The expanded dashboard icon