Connect-150 Webhook POST

From I-CubeX Wiki
Revision as of 03:51, 13 January 2018 by Admin (talk | contribs)
Jump to: navigation, search

Connect can output sensor data to the web, for use in IoT (Internet of Things) applications. This enables use of I-CubeX devices to trigger an event on the web using an IoT platform such as IFTTT and Zapier. The Web field in the digitizer view window requires a Webhook URL address that may be provided by the IoT platform.


Connect-150 digitizer view umd web.png


Connect will send the sensor data using a POST message with a JSON attachment, with one of the following formats:

Analog sensors

{\"value1\":\"<sensor_input_number>\", \"value2\":\"<sensor_parameter_number>\", \"value3\":\"<sensor_parameter_value>\"}

where <sensor_input_number> is any number between 0 and 7 representing the sensor inputs 1 .. 8, and <sensor_parameter> is always 0 since analog sensors only output one parameter, ie. the sensor output voltage.

Digital (I2C) sensors, standalone mode

{\"value1\":\"<sensor_input_number>\", \"value2\":\"<sensor_parameter_number>\", \"value3\":\"<sensor_parameter_value>\"}

where <sensor_input_number> is any number between 0 and 7 representing the sensor inputs 1 .. 8, and <sensor_parameter> is any number between 0 and 15 depending on the method selected for the digital sensor. The method determines how many parameter values the sensor outputs.

Digital (I2C) sensors, host mode

{\"value1\":\"<sensor_input_number>\", \"value2\":\"<sensor_parameter_number>\", \"value3\":\"<sensor_parameter_value>\", \"value<2 + 2 * sensor_parameter_number>\":\"<sensor_parameter_number>\", \"value<3 + 2 * sensor_parameter_number>\":<sensor_value>\"<sensor_parameter_value>\"}.

where <sensor_input_number> is any number between 0 and 7 representing the sensor inputs 1 .. 8, and <sensor_parameter> is any number between 0 and 15 depending on the method selected for the digital sensor. The method determines how many parameter values the sensor outputs.

To test this feature use the digitizer in standalone mode. Configure the digitizer with EditorX to use eg. the Threshold or Peak signal processing methods to output a sensor value incidentally as a way to trigger an event. Sending messages to the web continuously at a high rate, eg. at 100 ms interval or less could have unexpected or even undesirable results.

To use this feature with IFTTT.com do the following (assuming you have already created an account) at IFTTT.com):

  • Create a new applet, eg. by selecting "New Applet" from the user menu in the top right.
  • Click on the blue "This" word in the "If This Then That" phrase.
  • Enter Webhooks in the search field for "Select a service".
  • Click the "Receive a web request" button.
  • Enter a name for the event, eg. "I-CubeX_Sensor_Triggered".
  • Click on the blue "That" word in the "If This Then That" phrase.
  • Select an action service, eg. Email
  • Click the "Send me an email" button
  • Click "Create action". The applet is now created.
  • Click on your username, then services.
  • Choose Maker, and click on the settings on the top right.
  • Copy the URL on this page to the Web field in Connect.
  • Replace the word "use" with "trigger/<name_of_event>/with/key", where "<name_of_event>" is the name given to the event, eg. "I-CubeX_Sensor_Triggered".

Now, if the Web every time a sensor outputs a value an email will be sent to the email address specified in the applet.