Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPCUA and GasDetection #2

Open
Shining9311 opened this issue Jul 24, 2021 · 0 comments
Open

OPCUA and GasDetection #2

Shining9311 opened this issue Jul 24, 2021 · 0 comments

Comments

@Shining9311
Copy link

Hello!
I want to use this package for OPCUA Client and Server and I don't know how to use this module for getting value from sensor and publish this in the cloud platform.
could you please help me?
this is my server python code. "X" is the part for MQ2 module and I have to complete this.

from opcua import Server
import time
from gas_detection import GasDetection

X = MQ2

server = Server()
url = "opc.tcp://xxx.xxx.x.xxx:4840"
server.set_endpoint(url)

name = "OPCUA server"
addSpace = server.register_namespace(name)

node = server.get_objects_node()
param = node.add_object(addSpace, "Parameters")

var = param.add_variable(addSpace, "Variable", X)
var.set_writable()

server.start()

try:
while True:

    v = var.get_value()

    print("Variable =" .format(v))

    time.sleep(0.25)

except KeyboardInterrupt:
print('\nAborted by user!')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant