Use Python and a USB DAQ to Read Analog Voltages and Save Them to a CSV File

MagicDAQ
2 min readJun 25, 2021

Log analog voltages to a CSV file using Python and the MagicDAQ USB DAQ

Image Attribution

Disclosure

We designed MagicDAQ — the following code uses our own API and USB DAQ hardware.

Purpose

Some times you just want a simple way to measure some voltage and log it to a CSV file. What better way than with Python and a USB DAQ?

The below code demonstrates two separate ways to approach the problem:

  • The first approach is the simplest possible implementation, suitable for measurement frequencies a few Hz and slower.
  • The second approach is slightly more complex — it relies on streaming voltage inputs. This approach is suitable for much faster data acquisition — up to 31kHzs in fact.

Sample Code

File can be found on Github here.

This code example was taken from the MagicDAQ Python API

Head over to the API to see code examples for every MagicDAQ function.

MagicDAQ Feature Highlights

In case you were wondering what else the MagicDAQ can do, here is a list of the key features:

  • 8 Analog inputs, 14 bit resolution, 48 KS/s maximum measurement frequency, -/+ 10V input voltage range
  • 8 Digital inputs / outputs, 0 to 5V range
  • 2 Analog outputs / PWM outputs / sine wave outputs, 0 to 5V range
  • 1 Pulse counter / PWM output, 0 to 3.3V range

Need Some Help?

We’re always happy to share our knowledge — feel free to email us at:

  • support@magicdaq.com

--

--