HMS eWON

Configuring the eWON VPN Gateway to stream data to JCore Clarity

Log in to the eWON Web Console

Pull up the eWON's web interface by pointing your browser at your eWON's IP address, e.g. http://192.168.1.100

The eWON's default login is username adm, password adm.

Configure I/O Servers in the eWON

Click on I/O Servers in the sidebar, and select the communications protocol of your source device, e.g. MODBUS. The example below shows a Modbus device at 192.168.1.2.

Create eWON Tags

Click on Tags -> Values in the sidebar, and click the MODE switch to enter SETUP mode. Click the Add button to create a new tag.

Configure the tag by entering a name, selecting the source I/O server under Server Name, and entering information like the tag's source address and data type.

Create a JCore Clarity Account

If you do not already have a JCore Clarity account for yourself or your customer, create one by going to the JCore Clarity Signup Page. For additional info on the signup process, see Creating a Clarity Account.

Create a JCore Clarity Device

Click on the + button next to DEVICES in the sidebar to create a new device.

Enter a device name, login username, and login password to associate with your eWON. Keep the JSON protocol selected.

For security reasons, each device that connects to JCore Clarity must have a unique login. The device's MQTT username will always be prefixed with your organization's name.

After you create the device, you'll see a complete set of communications configuration options. Enterdata for MQTT Topic if you're using the script we provide with your eWON.

Copy BASIC script to eWON device

JCore provides a script that exports eWON data to Clarity using the eWON's BASIC programming environment.

Go to SETUP -> BASIC IDE in the eWON's sidebar. If the script is RUNNING, click on the Script Execution switch to stop it.

Paste the contents of the script below into the Init Section window, and replace myOrganization/myDeviceUsernameand myDevicePassword with the device username and password you entered in Clarity.

// Please enter the MQTT username and password you configured in the JCore Clarity
// device settings screen:
MQTTUsername$ = "myOrganization/myDeviceUsername"
MQTTPassword$ = "myDevicePassword"

MQTTEndpoint$ = "clarity.jcore.io"
MQTTPort$ = "8883"

CACRT$ = ""
CACRT$ = CACRT$ + "-----BEGIN CERTIFICATE-----" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "MIIESTCCAzGgAwIBAgITBn+UV4WH6Kx33rJTMlu8mYtWDTANBgkqhkiG9w0BAQsF" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "b24gUm9vdCBDQSAxMB4XDTE1MTAyMjAwMDAwMFoXDTI1MTAxOTAwMDAwMFowRjEL" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEVMBMGA1UECxMMU2VydmVyIENB" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "IDFCMQ8wDQYDVQQDEwZBbWF6b24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "AoIBAQDCThZn3c68asg3Wuw6MLAd5tES6BIoSMzoKcG5blPVo+sDORrMd4f2AbnZ" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "cMzPa43j4wNxhplty6aUKk4T1qe9BOwKFjwK6zmxxLVYo7bHViXsPlJ6qOMpFge5" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "blDP+18x+B26A0piiQOuPkfyDyeR4xQghfj66Yo19V+emU3nazfvpFA+ROz6WoVm" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "B5x+F2pV8xeKNR7u6azDdU5YVX1TawprmxRC1+WsAYmz6qP+z8ArDITC2FMVy2fw" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "0IjKOtEXc/VfmtTFch5+AfGYMGMqqvJ6LcXiAhqG5TI+Dr0RtM88k+8XUBCeQ8IG" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "KuANaL7TiItKZYxK1MMuTJtV9IblAgMBAAGjggE7MIIBNzASBgNVHRMBAf8ECDAG" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "AQH/AgEAMA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUWaRmBlKge5WSPKOUByeW" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "dFv5PdAwHwYDVR0jBBgwFoAUhBjMhTTsvAyUlC4IWZzHshBOCggwewYIKwYBBQUH" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "AQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8vb2NzcC5yb290Y2ExLmFtYXpvbnRy" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "dXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDovL2NydC5yb290Y2ExLmFtYXpvbnRy" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "dXN0LmNvbS9yb290Y2ExLmNlcjA/BgNVHR8EODA2MDSgMqAwhi5odHRwOi8vY3Js" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "LnJvb3RjYTEuYW1hem9udHJ1c3QuY29tL3Jvb3RjYTEuY3JsMBMGA1UdIAQMMAow" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "CAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IBAQCFkr41u3nPo4FCHOTjY3NTOVI1" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "59Gt/a6ZiqyJEi+752+a1U5y6iAwYfmXss2lJwJFqMp2PphKg5625kXg8kP2CN5t" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "6G7bMQcT8C8xDZNtYTd7WPD8UZiRKAJPBXa30/AbwuZe0GaFEQ8ugcYQgSn+IGBI" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "8/LwhBNTZTUVEWuCUUBVV18YtbAiPq3yXqMB48Oz+ctBWuZSkbvkNodPLamkB2g1" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "upRyzQ7qDn1X8nn8N8V7YJ6y68AtkHcNSRAnpTitxBKjtKPISLMVCx7i4hncxHZS" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "yLyKQXhw2W2Xs0qLeC1etA+jTGDK4UfLeC0SF7FSi8o5LL21L8IzApar2pR/" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "-----END CERTIFICATE-----" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "-----BEGIN CERTIFICATE-----" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "rqXRfboQnoZsG4q5WTP468SQvvG5" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "-----END CERTIFICATE-----" + CHR$(13) + CHR$(10)
CACRT$ = CACRT$ + "" + CHR$(13) + CHR$(10)
OPEN "file:/usr/ca-and-root.crt" FOR BINARY OUTPUT AS 1
PUT 1, CACRT$
CLOSE 1

topic$ = "data"
Changepushtime% = 10
Fullpushtime% = 600

// Read number of tags
NB%= GETSYS PRG,"NBTAGS"
DIM a(NB%)

ONTIMER 1, "GOTO MqttCONNECT"
TSET 1,10

MqttCONNECT:
MQTT "OPEN","clientId", MQTTEndpoint$
Mqtt "SETPARAM", "Port",MQTTPort$
Mqtt "SetParam", "username", MQTTUsername$
Mqtt "SetParam", "password", MQTTPassword$
MQTT "SETPARAM", "cafile","/usr/ca-and-root.crt"
MQTT "SETPARAM", "log", "1"
MQTT "SETPARAM", "keepalive", "20"

Mqtt "CONNECT"

//IF No error --> Connected --> Disable Retry timer
TSET 1,0

IsConnected:
//Record the Tag ONCHANGE events into an array.
//Allows to post only values that have changed
FOR i% = 0 TO NB%-1
 k%=i%+1
 //SETSYS Tag, "load",-i%
 a(k%) = 0
 Onchange -i%, "a("+ STR$ k%+")= 1"
NEXT i%

ONTIMER 1,"goto MqttPublishAllValue"
ONTIMER 2, "goto MqttPublishChangedValue"
// Publish all tags 1 second after connecting. Trying to publish immediately doesn't work.
TSET 1,1
TSET 2,Changepushtime%
END

//publish all tags
MqttPublishAllValue:
counter%=0
json$ =         '{'
  FOR i% = 0 TO NB% -1
      a(i% + 1) = 0
      SETSYS Tag, "load",-i%
      i$= GETSYS TAG,"Name"
      IF counter% > 0 THEN
        json$ = json$ + ','
      ENDIF
      json$ = json$ + '"' + i$+ '":'+STR$ GETIO i$
      counter% = counter% +1
  NEXT i%
  json$ = json$ +   '}'

  STATUS% = MQTT("STATUS")

 //Is Connected
 IF (STATUS% = 5) THEN
   Print "[PUBLISH ALL TAGS TIMER] " + STR$ counter% + " tags selected and published"
   MQTT "PUBLISH",topic$,json$, 0, 0
   // Go to normal interval after first successful publish
   TSET 1, Fullpushtime%
 ELSE
   Print "Not connected (" + STR$ STATUS% + ")"
   TSET 1, 1
 ENDIF
END

//Publish just the changed tags
MqttPublishChangedValue:
counter% = 0
//Compute JSON
json$ = '{'
FOR r% = 0 TO NB% - 1
  k%=r%+1
  IF a(k%) = 1 THEN
    a(k%) = 0
    SETSYS Tag, "LOAD", -r%
    name$= GETSYS Tag, "name"
    IF counter% > 0 THEN
      json$ = json$ + ','
    ENDIF
    json$ = json$ + '"' + name$+ '":'+STR$ GETIO name$
    counter% = counter% +1
  ENDIF
NEXT r%
json$ = json$ +    '}'
IF counter% > 0 THEN
 STATUS% = MQTT("STATUS")
 IF (STATUS% = 5) THEN  //Is Connected
  MQTT "PUBLISH",topic$ ,json$, 0, 0
  PRINT "[PUBLISH ONCHANGE TIMER] " + STR$ counter% + " Tags have changed detected -> Publish"
 ENDIF
ELSE
PRINT "[PUBLISH ONCHANGE TIMER] No Tag changes detected! -> Don't publish"
ENDIF
END

If you don't replace myOrganization/myDeviceUsername and myDevicePassword with the actual username and password you configured in Clarity, your device will be unable to connect!

Enable Autorun to ensure that the script runs each time your eWON boots up:

Start the script by switching Script Execution to RUNNING:

If you configured everything correctly, the device should connect to JCore Clarity, create tags, and publish data:

Troubleshooting

If your MQTT username or password do not match the values you entered in JCore Clarity, the eWON will fail to connect. The Clarity screen for the device will look like this:

And the eWON's console section will have log messages indicating the the eWON couldn't connect:

If the eWON can't connect, try re-entering the device's username and password in both Clarity and at the top of the eWON script.

If you're sure that the device username and password match and the eWON still won't connect, please verify that the eWON has a working Internet connection.

Last updated