Import data from HP Multimeter into Origin using pySerial

This post will show you how to read data into Origin from a serial port, using the pySerial Python module. A dialog allows user to set the time interval and number of data points to be recorded. The data is then imported into an Origin worksheet.

Hardware used in this example:

  1. HP 34401A Multimeter.
  2. RS232 cable (to connect the COM port of the computer to the multimeter).

Installation of pySerial module:

pySerial is not included in the embedded Python environment in Origin. The first step therefore is to download and install pySerail “outside” and then add the file path to Origin’s Python environment. The following instruction shows how to do it step by step, This instruction applies for either Python2.7 or Python3.3 , I am using Python 3.3 for example here:

  1. Download and install Python3.3 from the website:
  2. Download and install pySerial module from the website: .  The easiest way might be just download the .exe file (make sure it’s compatible with Python3.3) and run it.
  3. Launch Python and type “import serial”. If no error message shows up, then the installation is successful.
  4. Stay in Python console, create a system object by running “import sys”.  Run “sys.path” and  copy the obtained search path.
  5. Launch Origin and open up script window by “shift+alt+3”,  change it to Python editor by Edit:Script Execution: Python 3.3.
  6. Create a system object by running “import PyOrigin”, followed by “import sys” and assign the saved search path to the current search path by running “sys.path =  pathname”. Of course replace pathname by the string saved in step 4.  Now the embedded Python in Origin can use the pySerial module.

Read data into Origin:

  1. Download this pySerial.OPX Origin Package file (4 kB) and drag and drop the file onto Origin. Note that you may need to launch Origin not-as-administrator.
  2. A toolbar with a button will appear. Click the button to open the setup dialog.  Set the target worksheet, number of rows, and sampling interval.  Click send to start importing data.

7-20-2015 5-12-31 PM



  1.  The button created from the opx is actually running a piece of Python script. The Python code PyserialToWorksheet is attached here as well.
  2.  For RS232 connection the multimeter need to be set to remote mode to collect data. This is different from the GPIB connection.

3.  The sampling rate is not very precise, because the data collection method ( takes an extra 1 second. This doesn’t occur for GPIB connection.


Leave a Reply

Your email address will not be published. Required fields are marked *