Using KST for graphing

KST is a useful desktop program available on Linux and Windows for graphing and data analysis of CSV data. It can be used to graph the output of OpenEnergyMonitor hardware connected directly via serial, the following guide details how to set this up with an emontx running standard firmware.

"Kst is the fastest real-time large-dataset viewing and plotting tool available and has basic data analysis functionality. Kst contains many powerful built-in features and is expandable with plugins and extensions. Extensive help is available, both from within kst and on the web. Kst is a KDE application and is freely available for anyone to download and use." - KST Website

1. KST Installation

In a terminal window type: sudo apt-get install kst

If you're a windows user, KST can be downloaded here

2. Python serial reader to CSV file

Save the following program to a file, lets call it:


import serial, sys, string
ser = serial.Serial('/dev/ttyUSB0', 9600)

while 1:

  # Read in line of readings from emontx serial
  linestr = ser.readline()

  # Remove the new line at the end
  # linestr = linestr.rstrip()
  # Replace space with comma for CSV
  linestr.replace(" ",",")
  # Append line to file
  with open("mydata.csv", "a") as myfile:

  # Output line to terminal window
  print linestr


  1. With a OpenEnergyMonitor node connected via USB to serial cable.
    Run with: python
  2. Open KST, either by clicking on a launcher or typing KST in terminal.
  3. Once open click on the data wizard icon. Select the mydata.csv
  4. Move all available data fields to the selected data field box by clicking the right arrow.
  5. Click on the Next button, and again, then click Finish
  6. You should see several graphs as in the picture above and they should be updating in real time.
  7. To get KST to calculate and display useful stats like Standard Deviation, Mean, etc:
    Click on the text label then select from the insert scalar in label drop down box.

In this Chapter:

Copied to Clipboard