Remote serial communication with VirtualHub for Web

Remote serial communication with VirtualHub for Web

Most of our examples with Yoctopuce communication modules use their integrated job system, which enables autonomous interrogation of an external sensor and assignment of the values read to the 10 genericSensors available on the module. This makes it particularly easy to upload measurements to a VirtualHub for Web server. Today, we're going to show you how to proceed in a more complex case where it's not possible to use genericSensors, for example because there are more than 10 measures to capture, or because the data is not numerical.

A typical scenario for this configuration might be the remote monitoring of a MODBUS PLC, where you wish to periodically check the value of numerous registers. If direct network access were available, we would simply connect a Yocto-RS485-V2 to a YoctoHub-Ethernet and use the MODBUS interrogation functions of the Yoctopuce library:

MODBUS query via direct network access
MODBUS query via direct network access


But if the network on which the MODBUS system is located can't be reached from the outside, you'd have to define a stand-alone query job on the Yocto-RS485-V2 and use VirtualHub for Web to upload data to an externally accessible server:

Autonomous MODBUS query, and remote access
Autonomous MODBUS query, and remote access


This week's news is that it is now possible to use this technique not only to obtain the values assigned to the virtual sensors genericSensor1...10, with the get_currentValue() method, but also to access the entire serial communication buffer (16 KB), for example with the readArray(), readLine(), or even registerSnoopingCallback() methods. To test this feature, make sure you've updated your VirtualHub for Web to version 58549 or higher.

As this feature may involve the transmission of a significant amount of data for each HTTP callback, which could lead to additional costs on cellular transmission, it must be explicitly enabled in the module's Web interface, through VirtualHub for Web:

Enabling serial data upload
Enabling serial data upload


After enabling this function, you can close the module window, wait for the two HTTP callbacks to occur, and open the window again. The first immediate benefit is that you can visually check that communication is running smoothly:

Communication buffer on VirtualHub for Web
Communication buffer on VirtualHub for Web


From here, you can create a program to monitor serial communication remotely, by connecting to VirtualHub for Web. Of course, the data won't arrive instantly, but every time the YoctoHub makes an HTTP callback. On the other hand, as the message timestamp is stored in the communication buffer, you'll even be able to access it if you use the snoopMessages() method.

As an example, here's what the output of our ModbusTool will look like if you run it from the command line, specify the URL of a VirtualHub for Web server as the interface to monitor, and activate the Snooping tab:

Using ModbusTool remotely
Using ModbusTool remotely



You can use the same principle with a Yocto-I2C module to retrieve data from multiple I2C sensors, or with a Yocto-RS232 to retrieve NMEA data from navigation equipment, for example, or even from the serial console of a remote network device.

Add a comment No comment yet Back to blog












Yoctopuce, get your stuff connected.