ORCAIn essence, this Technical Note (TN) is very similar to [[MISC-TN-024: Automated test equipment (ATE) monitoring with SBCSPG gateway and ThingsBoard IoT platform|''MISC-TN-001_—_Running_Armbian_Bullseye_024: Automated test equipment (Debian_11ATE)monitoring with SBCSPG gateway and ThingsBoard IoT platform'']]. There is a noticeable difference, however, as a different software stack was used on the edge device. In this case, [https://www.lfedge.org/projects/fledge/ Fledge] was utilized.
==Testbed==The edge device is the [[MISC-TN-004:_Running_Debian_(armbian)_on_SBCSPG#The_hardware_platform|SBCSPG gateway]] running Debian Bullseye. To deploy this distribution onto the target, the same approach described [[ORCA-TN-001_—_Running_Armbian_Bullseye_(Debian_11)|here]] was used. Unlike Orca SBC, SBCSPG is based on a 32-bit ARM Cortex-A7 processor, though. As such, a [https://wwwmirrors.lfedgedotsrc.org/projectsarmbian-dl/fledgetritium-h3/archive/Armbian_22.11.1_Tritium-h3_bullseye_current_5.15.80_minimal.img.xz different image] was used.
To install Fledge, the <code>apt</code>-based approach described [https://mirrorsfledge-iot.dotsrcreadthedocs.orgio/armbian-dlen/tritium-h3latest/archivequick_start/Armbian_22installing.11html here] was followed.1_Tritium-h3_bullseye_current_5It is worth to remember that some dependencies were handled manually.15.80_minimal.imgFor instance, <code>autoconf</code> and <code>libtool</code> packages were installed manually.xz
LAN ===Enabling the connection to the PLC===As described in [[MISC-TN-024: Automated test equipment (ATE) monitoring with SBCSPG gateway and ThingsBoard IoT platform|''MISC-TN-024'']], the PLC we want to talk to is connected to a different subnet, namely 192.168.30.0/24. For testing the connection to the PLC, after adding the required subnet configuration, the <code>modbus</code> command line tool was used, which is provided by the <code>modbus_cli</code> package. In the following example, the register mapped ad the address 300 is read.
armbian<pre class="board-terminal">root@sbcspg:~$ pip install modbus_cli/usr/local/fledge/python/fledge/plugins/north# ip addr add 192.168.30.253/24 dev eth0 label eth0:1
300: 33 0x2132 0x20</pre> We then configured Fledge in order to read periodically a couple of PLC's registers. Please note that this is a no-code operation as it is carried out with the help of the native web-based Fledge UI. To access PLC exposed data, the Fledge's <code>modbustcp</code> South plugin was used. Please note that also we had to patch it manually to solve a bug that prevented it from working properly. The patch is detailed [https://github.com/fledge-iot/fledge-south-modbustcp/pull/26/files here]. To make the change effective, we disabled and re-enabled the plugin via the web interface. [[File:SBCSPG-Fledge-2.png|center|thumb|600x600px|Installing the <code>modbustcp</code> South plugin.]][[File:SBCSPG-Fledge-3.png|center|thumb|600x600px|Configuring the plugin]][[File:SBCSPG-Fledge-4.png|center|thumb|600x600px|Configuring the plugin.]][[File:SBCSPG-Fledge-5.png|center|thumb|600x600px|The plugin is enabled.]][[File:SBCSPG-Fledge-6.png|center|thumb|600x600px|Fledge provides a native web interface to visualize collected data. ]]
Riavviare south === Enabling the connection to ThingsBoard IoT platform ===In order to upload collected data to ThingsBoard platform, a simple North plugin disablewas developed. To this end, the Microsoft Azure plugin was used as reference. The ThingsBoard North plugin is minimalist and '''unfit for a real-world production environment'''. Nevertheless, it was enough to perform the basic tests described in this document. Before testing this new plugin, the <code>mosquitto-clients</code> package was installed as the plugin invokes the <code>mosquitto_pub</enable per via graficacode> command line tool.
Preparing to unpack .../6-mosquitto-clients_2.0.11-1_armhf.deb ...
Unpacking mosquitto-clients (2.0.11-1) ...
Setting up libmosquitto1:armhf (2.0.11-1) ...
Setting up libev4:armhf (1:4.33-1) ...
Setting up libcjson1:armhf (1.7.14-1) ...
Setting up mosquitto-clients (2.0.11-1) ...
Setting up libdlt2:armhf (2.18.6-1+deb11u1) ...
Setting up libwebsockets16:armhf (4.0.20-2) ...
Setting up mosquitto (2.0.11-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/mosquitto.service → /lib/systemd/system/mosquitto.service.
Processing triggers for libc-bin (2.31-13+deb11u5) ...
</pre>
You can think about this This Technical Note (TN) as an evolution The following box shows the code of the article "[[MISC-TN-021: SBCSPG and ThingsBoard IoT]]". The use case described here is a real-world application based on the same elements: * [[MISC-TN-004: Running Debian (armbian) on SBCSPG#The hardware platform|The ''SBCSPG'' industrial gateway]] * [https://thingsboard.io/docs/ ''ThingsBoard IoT platform''] * [https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/ ''ThingsBoard IoT gateway'']. The application is to monitor robotized DAVE Embedded Systems' ATEs like the one shown [https://youtu.be/OoNiKgJXq00?t=409 here]plugin.
<syntaxhighlight lang="python" class"mw-collapsible= Implementation ="" mw-collapsed"="">The implementation is suitable for a production environment. Unlike what we did for [[MISC# -TN*-021coding: SBCSPG and ThingsBoard IoT|this TN]], in this case the ThingsBoard IoT platform was installed on the cloud, specifically on an AWS EC2 instance running Ubuntu Linux. The following diagram shows the complete solution.utf-8 -*-
Technically, the gateway can communicate with the ATE using different physical links and protocols. In the example under discussion, the physical link is Ethernet and the protocol is Modbus/TCP. The gateway retrieves periodically some data regarding the robotic arm used to move the device under test (DUT). These data are [https://www.universal-robots.com/articles/ur/interface-communication/modbus-server/ exposed by the PLC governing the arm] and are documented in detail [https://s3-eu-west-1.amazonaws.com/ur-support-site/16377/ModBus%20server%20data.pdf here].
=== ThingsBoard IoT configuration ===
To install ThingsBoard IoT platform on an EC2 instance, [https://thingsboard.io/docs/user-guide/install/cluster/aws-self-hosted-setup/ these instructions] were followed.
=== ThingsBoard IoT gateway configuration ===from fledge.common import loggerTo run this esample, the most important module to configure was the [https://thingsboardfrom fledge.io/docs/iot-gateway/config/modbus/ Modbus connector]plugins. The following box shows the resulting configuration file needed to poll some variables of the arm's joints (namely temperatures and currents)north.<syntaxhighlight lang="json">armbian@sbcspg:~$ cat /etc/thingsboard-gateway/config/modbuscommon.jsoncommon import *{__author__ = "masterAndrea Marson": {__copyright__ = "slavesCopyright (c) 2023 DAVE Srl": [ { "host": __license__ = "192Apache 2.168.30.420",__version__ = "port${VERSION}": 502, "type": "tcp", "method": "socket",_LOGGER = logger.setup(__name__) _CONFIG_CATEGORY_NAME = "timeoutTHINGSBOARD": 35,_CONFIG_CATEGORY_DESCRIPTION = "byteOrderThingsBoard Python North Plugin": "BIG", "retries": true, "retryOnEmpty": true,_DEFAULT_CONFIG = { "retryOnInvalid" 'plugin': true,{ "pollPeriod" 'description': 5000'ThingsBoard North Plugin', "unitId" 'type': 1'string', "deviceName" 'default': "UR5"'thingsboard', "sendDataOnlyOnChange" 'readonly': 'true,' "connectAttemptTimeMs": 5000 }, "connectAttemptCounttb_iot_platform_host": 5, "waitAfterFailedAttemptsMs": 300000, "timeseries": [{ {"tagdescription": "base_joint_temperature_deg_CThingsBoard IoT platform host.", "type": "16intstring", "functionCode": 3, "objectsCountdefault": 1,"addressput the public name of your host here": 300 }, {"tagorder": "shoulder_joint_temperature_deg_C2", "typedisplayName": "16intThingsBoard IoT platform host", "functionCode": 3 }, "objectsCounttb_mqtt_topic": 1, "address": 301 },{ {"tagdescription": "base_joint_current_mAMQTT topic", "type": "16intstring", "functionCode": 3, "objectsCountdefault": 1,"addressv1/devices/me/telemetry": 290 }, {"tagorder": "shoulder_joint_current_mA3", "typedisplayName": "16intMQTT topic", "functionCode" 'readonly': 3,'true' "objectsCount": 1 }, "addresstb_device_access_token": 291 },{ {"tagdescription": "elbow_joint_current_mADevice's access token.", "type": "16intstring", "functionCodedefault": 3,"objectsCount": 1, "addressput your device's token here": 292 }, {"tagorder": "wrist1_joint_current_mA4", "typedisplayName": "16int", "functionCodeDevice's access token": 3, "objectsCount": 1 }, "addresssource": 293 },{ {"tagdescription": "wrist2_joint_current_mASource of data to be sent on the stream.", "type": "16intenumeration", "functionCodedefault": 3, "objectsCount": 1,"addressreadings": 294 }, {"tagoptions": ["wrist3_joint_current_mAreadings"], "typeorder": "16int5", "functionCodedisplayName": 3,"objectsCountSource": 1, "address" 'readonly': 295 } ] } ]'true'
== Dashboards Visualization of uploaded data ==ThingsBoard IoT allows Similarly to create easily custom dashboards to visualize data. At what we did in [[http://ec2-15-160-47-190.euMISC-southTN-1.compute.amazonaws.com024:8080/dashboard/1178fb20Automated test equipment (ATE) monitoring with SBCSPG gateway and ThingsBoard IoT platform|''MISC-e56dTN-11ec-8592-e3cb29424137?publicId=28967df0-e56d-11ec-8592-e3cb29424137 this link024'']] such , we created a simple dashboard is available showing some temperatures and currents of to visualize in real-time on cloud side collected data as shown in the arm's jointsfollowing example.[[File:ATE monitoring SBCSPG ThingsBoard dashboard1-Fledge-8.png|center|thumb|600x600px|Visualization of uploaded data.]]