PyCampbellCR1000
raw JSON → 0.4 verified Fri May 01 auth: no python
A Python library for communicating with Campbell Scientific CR1000 and similar dataloggers via TCP/IP or RS-232. Current version is 0.4. Development appears to be sporadic; no recent releases or updates.
pip install pycampbellcr1000 Common errors
error ModuleNotFoundError: No module named 'pycampbellcr1000' ↓
cause Library not installed or installed into a different Python environment.
fix
Run 'pip install pycampbellcr1000' in the correct environment.
error AttributeError: 'CR1000' object has no attribute 'get_table_names' ↓
cause Using an older version of the library (pre-0.4) where method names differed.
fix
Upgrade to latest: 'pip install --upgrade pycampbellcr1000'
error ConnectionRefusedError: [Errno 111] Connection refused ↓
cause Datalogger is not reachable at the specified IP/port or the server is not running.
fix
Verify datalogger IP and port (default 6789 for TCP). Ensure the datalogger is connected and network accessible.
Warnings
breaking As of v0.4, from_url() method used for connections; older examples may use CR1000(host, port) directly which may not work. ↓
fix Use CR1000.from_url('tcp:host:port') instead of CR1000(host, port).
gotcha The library uses Python's built-in logging; enable debug logging to see communication details. ↓
fix import logging; logging.basicConfig(level=logging.DEBUG)
gotcha Data retrieval methods may block indefinitely if the datalogger is unreachable; set a timeout via the underlying socket timeout. ↓
fix Use CR1000.from_url('tcp:host:port', timeout=10) to set a timeout.
Imports
- CR1000
from pycampbellcr1000 import CR1000
Quickstart
from pycampbellcr1000 import CR1000
# Connect to datalogger via IP or serial
logger = CR1000.from_url('tcp:192.168.1.100:6789')
# or serial: logger = CR1000.from_url('serial:/dev/ttyUSB0:115200')
# Get table names
tables = logger.get_table_names()
print('Tables:', tables)
# Read data from a table (returns list of dicts)
data = logger.get_data('Table1', count=5)
for row in data:
print(row)
# Close connection
logger.close()