Skip to main content

Communication tools for Campbell CR1000-type Dataloggers

Project description

PyCampbellCR1000 is a python project which aims to allow the communication with Campbell CR1000 Type Datalogger

The main features include automatic collecting of data and settings (read only) as a list of dictionnaries.

The tool can be used in your python scripts for data post-processing, or in command line mode to collect data as CSV.

We don’t update anything from PyCampbellCR1000 besides time, because we are assuming that the dataloggers are already configured.

Note: PyCampbellCR1000 uses the PyLink lib, offers a universal communication interface with File-Like API.

Examples

We init communication by giving the datalogger URL.

>>> from pycampbellcr1000 import CR1000
>>> device = CR1000.from_url('tcp:host-ip:port')
>>> # or with Serial connection
>>> device = CR1000.from_url('serial:/dev/ttyUSB0:38400')

To get time, use:

>>> device.gettime()
datetime.datetime(2012, 7, 16, 12, 27, 55)

To get data, you have to enter the table name where it is stored. If you don’t know the table name, you cannot collect the list of available tables in the datalogger.

>>> device.list_tables()
['Status', 'Table1', 'Public']

Choose the time period to get your data from start date to stop date.

>>> import datetime
>>> start = datetime.datetime(2012, 7, 16, 11, 0, 0)
>>> stop = datetime.datetime(2012, 7, 16, 12, 0, 0)
>>> data = device.get_data('Table1', start, stop)
>>> data[0]["Datetime"]
datetime.datetime(2012, 7, 16, 11, 0)
>>> data[0]["CurSensor1_mVolt_Avg"]
2508.0
>>> print(data.filter(('Datetime', 'CurSensor3_mAmp_Avg')).to_csv())
Datetime,CurSensor3_mAmp_Avg
2012-07-16 11:00:00,18.7
2012-07-16 11:01:00,18.48
...
2012-07-16 11:59:00,17.25

Features

  • Collecting data as a list of dictionaries

  • Collecting data in a CSV file

  • Reading and adjusting the data logger’s internal clock

  • Retrieving table definitions

  • Listing table names

  • Reading settings

  • Collect file list and download file content

  • Tested with CR1000 and CR800 dataloggers (should work with CR3000 datalogger)

  • Various types of connections are supported (TCP, UDP, Serial, GSM)

  • Comes with a command-line script

  • Compatible with Python 2.6+ and 3.x

Installation

You can install, upgrade, uninstall PyCampbellCR1000 with these commands

$ pip install pycampbellcr1000
$ pip install --upgrade pycampbellcr1000
$ pip uninstall pycampbellcr1000

Or if you don’t have pip

$ easy_install pycampbellcr1000

Or you can get the source code from github.

$ git clone https://github.com/SalemHarrache/PyCampbellCR1000.git
$ cd PyCampbellCR1000
$ python setup.py install

Documentation

See documentation here: http://pycampbellcr1000.readthedocs.org

Changelog

Version 0.3

Released on 2014-03-26.

  • Bug correction about communication with NL115, NL120 and NL200 modules using “CSI/O” serial port.

  • Support python 3.3 and 3.4

Version 0.2

Released on 2012-07-26.

  • Fixed a bug related to update command (on Windows)

  • Used UTC datetime

  • Decoded pakbus packet properly

  • Other minor bugs fixed

Version 0.1

Released on 2012-07-18.

First properly tagged release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyCampbellCR1000-0.3.tar.gz (50.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page