Section 7. Communication with the MQTT protocol
Streaming data into the Terminal Program
These are basic steps you'll follow to see data streamed into a terminal program on
macOS or the command prompt on Windows. Before attempting to connect with
the instrument, power it on and let it warm up. Connect the network cable between
the instrument and your computer or your local network.
1
Create the python script to read data.
Copy the following into a text file and save it to your computer's desktop (or
another directory) with a
.py
extension, like
read-data.py
.
import
paho.mqtt.client
as
paho
def
on_subscribe
(client, userdata, mid, granted_qos):
(
"Subscribed: "
+
str
(mid)+
" "
+
str
(granted_qos))
def
on_message
(client, userdata, msg):
msg =
str
(msg.payload)
(msg)
client = paho.
Client
()
client.on_subscribe = on_subscribe
client.on_message = on_message
client.
connect
(
"172.24.82.41"
,
1883
)
client.
subscribe
(
"licor/niobrara/output/concentration"
, qos=
1
)
client.
loop_forever
()
2
Change the IP Address next to
client.connect
to match that of your instrument. The default
port is 1883, so leave that as it is. Save the updated file.
3
Run the Python script.
In the terminal program, change to the directory that has the
.py
file saved earlier.
Type
cd desktop
on Mac or type
cd C:\Users\User.Name\Desktop
if you saved
them to your desktop (
User.Name
is a placeholder, used as an example). Then type
python read-data.py
to launch the script created in step 1. Data will stream into
the terminal program.
4
Type
Ctrl + C
to stop the script.
7-8
LI-7815 CO₂/H₂O Gas Analyzer
Содержание LI-7815
Страница 1: ...LI 7815 CO2 H2O Trace Gas Analyzer Instruction Manual...
Страница 2: ......
Страница 10: ...viii...
Страница 30: ...Section 2 Getting started 2 14 LI 7815 CO H O Gas Analyzer...
Страница 38: ...Section 3 Applications of the LI 7815 3 8 LI 7815 CO H O Gas Analyzer...
Страница 42: ...Section 4 Software overview 4 4 LI 7815 CO H O Gas Analyzer...
Страница 54: ...Section 4 Software overview 4 16 LI 7815 CO H O Gas Analyzer...
Страница 62: ...Section 5 Troubleshooting 5 8 LI 7815 CO H O Gas Analyzer...
Страница 70: ...Section 6 Maintenance 6 8 LI 7815 CO H O Gas Analyzer...
Страница 88: ...Appendix B Additional safety information B 6 LI 7815 CO H O Gas Analyzer...
Страница 92: ...Appendix C Specifications C 4 LI 7815 CO H O Gas Analyzer...
Страница 97: ......