Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Knowledge Base Home
  • Contact Us
  • Home
  • Moku:Lab
  • Software integrations
  • Python examples

Python: Data Logger (streaming)

Written by Paul Cracknell

Updated at December 22nd, 2020

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Moku:Go
    Moku:Go Arbitrary Waveform Generator Moku:Go Data Logger Moku:Go Frequency Response Analyzer Moku:Go Logic Analyzer & Pattern Generator Moku:Go Oscilloscope & Voltmeter Moku:Go PID Controller Moku:Go Spectrum Analyzer Moku:Go Waveform Generator Moku:Go Power Supplies Moku:Go Digital Filter Box Moku:Go FIR Filter Builder Moku:Go Lock-in Amplifier
  • Moku:Lab
    Windows Moku:Lab general Moku:Lab Instruments iPad app Software integrations
  • Moku:Pro
    Moku:Pro Instruments
+ More

Example Python script to implement the Data Logger (streaming)

# pymoku example: Livestream Datalogger
# 
# This example demonstrates how you can use the Datalogger to live-stream
# dual-channel voltage data over the network.
# 
# (c) 2019 Liquid Instruments Pty. Ltd.
# 

from pymoku import Moku, StreamException
from pymoku.instruments import Datalogger

# Connect to your Moku by its device name
# Alternatively, use Moku.get_by_serial('#####') or Moku('192.168.###.###')
m = Moku.get_by_name('Moku')

try:
 # Deploy the Datalogger to your Moku
 i = m.deploy_or_connect(Datalogger)

 # 10Hz sample rate
 i.set_samplerate(10)

 # Stop a previous session, if any, then start a new dual-channel data
 # stream in real time over the network.
 i.stop_stream_data()
 i.start_stream_data(duration=10, ch1=True, ch2=True)

 while True:
 # Get 10 samples off the network at a time
 samples = i.get_stream_data(n=10)

 # Break out of this loop if we received no samples
 # This denotes the end of the streaming session
 if not any(samples):
 break

 # Print out the new samples
 print("Received: Channel 1 (%d smps), Channel 2 (%d smps)"
 "" % (len(samples[0]), len(samples[1])))

 # Denote that we are done with the data streaming session so resources may
 # be cleand up
 i.stop_stream_data()

except StreamException as e:
 print("Error occured: %s" % e)
finally:
 # Close the connection to the Moku to release network resources
 m.close()
pymoku moku:lab python data logger logger datalogger streaming

Was this article helpful?

Yes
No

Related Articles

  • Moku:Lab - a capacitance meter
  • Python: Arbitrary Waveform Generator
  • Python: Data Logger (basic)
  • Python Spectrum analyzer 'Max hold' function

Sitemap

  • Moku:Lab
  • Instruments
  • Software
  • Company
  • Support
  • Store
  • Terms & Conditions
  • Privacy Policy

Offices

United States
+1 (619) 332-6230
740 Lomas Santa Fe Dr
Suite 102
Solana Beach, CA 92075

Australia
+61 2 6171 9730
243 Northbourne Avenue
Suite 2
Lyneham, ACT 2602

Follow us

Youtube LinkedIn

官方微信

Contact us
© 2021 Liquid Instruments. All rights reserved.

Definition by Author

0
0
Expand