Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modbus TCP communication from HTML/Javascript Webpage

I have a device that uses Modbus TCP. I want to read data from it and display it on a webpage (Without an in between server).

I have found a project that does almost this exact same thing as a Chrome extension:

https://github.com/Cloud-Automation/chrome-modbus

It uses this in the javascript code: chrome.sockets.tcp

I was hoping that I could do the same thing on my webpage using WebSockets.

It seems that websockets would work on my webpage (acting as the client), sending and receiving information from the device (acting as the server). It doesn't seem that websockets is affected by cors.

Does anybody have pointers on where I could start on this? (Or a javascript library would be great)

Is this possible?

like image 601
dgProgrammer Avatar asked Oct 18 '22 22:10

dgProgrammer


2 Answers

Without an in between server will not be possible, unless your plc supports other protocol different than modbus (e.g. post/get).

If your plc is "completely closed" and you only have this port/protocol open, then you need an in between server that makes the conversion of modbus tcp to html. Using node-red as well as the dashboard and modbus flows, you can achieve it.

If you solved it other way, I would like to know how you did it.

like image 95
Ñhosko Avatar answered Oct 27 '22 20:10

Ñhosko


I did get this solved without a server in between. I did it using Chrome Sockets link I also made it work using a cordova app for smart phones. Firefox has a sockets api as well, but did not attempt to figure it out for that browser.

like image 34
dgProgrammer Avatar answered Oct 27 '22 18:10

dgProgrammer