Record Wi-Fi Signal in a Tag on Flexy

09 Feb 2023

When troubleshooting Wi-Fi issues, it may be helpful to see a Flexy's Wi-Fi signal numerically, rather than just as a symbol on the summary page. This number can be loaded into a tag, which can then be shown as a KPI or recorded to a historical log.

The Wi-Fi signal number ranges from 0, for disconnected, to 7, for a very strong connection.

 

APPLICABLE PRODUCTS

  • Ewon Flexy equipped with Wi-Fi extension card

 

PRE-REQUISITES

  • Ability to edit tags
  • Access to the BASIC IDE

 

IN THIS ARTICLE

 

Creating the Wi-Fi Signal Tag

  1. Navigate to Tags → Values, then set mode to Setup at top left
  2. Add a new tag and give it the name WiFiSignal
  3. Leave the server name as MEM, which is used for memory tags controlled by user input or a script
  4. If interested in logging, check "Historical Logging Enabled" and set the Logging Interval to the desired frequency.

mceclip3.png

WiFiSignal tag configured to log its value every 60 seconds

 

Adding the BASIC Script

  1. Navigate to Setup → BASIC IDE
  2. In the Init Section, paste the code below
    • This code first sets a timer that runs the function get_wifi_signal() every ten seconds
    • get_wifi_signal() sets the tag WiFiSignal to the value of "WIFISSIDLevel" from system info
    • Because the value from system info is a string, the function to_int%() converts this to an integer that can be loaded into the WiFiSignal tag
  3. Up top, click Run then check Autorun to ensure the script runs automatically after the Ewon reboots
  4. Finally, at the top right change the "Script execution" toggle to Running to run the script
TSET 1, 10
ONTIMER 1, "@get_wifi_signal"

REM Set tag WiFiSignal to signal from system info
FUNCTION get_wifi_signal():
SETSYS INF, "LOAD"
WiFiSignal@ = @to_int%(GETSYS INF, "WIFISSIDLevel")
ENDFN

REM Convert string to integer
FUNCTION to_int%($param1$):
$to_int% = FCNV $param1$, 30, 0, "%d"
ENDFN

 

ADDITIONAL INFO

RG-0006-01-EN - Programming Reference Guide