If you have machines at two remote sites, you might want to monitor their status from one central location. By using the Ewon Flexy at each site, you can securely send data over the internet without setting up a complicated network. This makes it easier to keep an eye on your operations, catch issues early, and keep everything running smoothly.
APPLICABLE PRODUCTS
Ewon Flexy
PRE-REQUISITES
- You must have a Talk2M Developer ID
- Your devices must be registered and online in a Talk2M account.
- You must be using an Ewon Flexy on a firmware revision 11 or higher
IN THIS ARTICLE
M2Web API & RequestHTTPX
With the addition of the RequestHTTPX BASIC command in firmware revision 11, we may now use the M2Web API as a way to exchange tag values between two devices. This option is especially flexible as it does not require a public IP or really any IP addressing and uses the already established Talk2M connections. This method is useful for creating a more versatile application. RequestHTTPX supports GET and POST methods, we used POST for this example due to better security.
For example, we have a Flexy 202 (Device A) that is reading the status and the temperature from an ABLOGIX IO server. The Flexy 202 will be sending this data to a remote site with an Flexy 205 (Device B) using the M2Web API. We will export the data on a 5 second interval so as not to execute too many requests. The Flexy 205 will need tags created to store the data to. The below screenshots show the basic setup.
Device A:
Device B:
Device A's BASIC IDE:
This script is set on the device that has the original tag values. The full script is below for easy use. Make sure you change the parameters to fit your use case, this is a template and will not work as is.
TSET 1, 5
ONTIMER 1, "GOTO UpdateRemote"
UpdateRemote:
//Account info - Change these parameters as fit
account$ = "accountName"
username$ = "username"
password$ = "password"
developerid$ = "developerID"
//Remote flexy specific info - Change these parameters as fit
devicename$ = "flexyName"
deviceusername$ = "adm"
devicepassword$ = "adm"
//remote flexy tag name - Change these parameters as fit
tagName1$ = "SiteA_Status"
tagname2$ = "SiteA_Temperature"
// local tag values - Change these parameters as fit
tagValue1$ = STR$ Status@
tagvalue2$ = STR$ Temperature@
method$ = "POST"
url$ = "https://m2web.talk2m.com/t2mapi/get/"+devicename$+"/rcgi.bin/UpdateTagForm"
postData$ = "TagName1="+tagName1$+"&TagValue1="+tagValue1$+"&TagName2="+tagName2$+"&TagValue2="+tagValue2$+"&t2maccount="+account$+"&t2musername="+username$+"&t2mpassword="+password$
postData$ = postData$ + "&t2mdeveloperid="+developerid$+"&t2mdeviceusername="+deviceusername$+"&t2mdevicepassword="+devicepassword$
REQUESTHTTPX url$, method$, "", postData$
END