Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Python code


Makada Nov 2, 2020 08:32 PM

Hi,

Im looking for python code to connect to cr1000.

Ive seen the pycampbellcr1000 python code but that doesnt work with latest cr1000 os.

With kind regards.


GaryTRoberts Nov 2, 2020 08:57 PM

There isn't any Python code that is "officially" supported by Campbell Scientific. There is an alternative method for interacting with the logger and can be driven by Python. Each logger, if the HTTP interface is enabled and the CR1000 has an Ethernet interface that can be reached by the PC or server running Python, has the ability to be driven by the Datalogger Web API (HTTP GET) calls.

Take a look at https://help.campbellsci.com/crbasic/cr1000x/#Info/webserverapicommands1.htm#kanchor360.

The CR1000X and CR1000 have very simular Web API command sets.


Makada Feb 20, 2023 05:27 PM

I finally have found the solution.
The error occurs because sys.stdout is not a binary stream but rather a text stream.
To fix:

Open the compact. py file located in c: \program files\python311\lib\site-packages\pycampbellcr1000.
Find the line that reads stdout = sys.stdout. buffer and replace it with stdout = getattr(sys.stdout, 'buffer', sys.stdout)
Save the file and re run the code.


Haidar Mar 8, 2023 12:18 PM
 @makada 
I'm also willing to fetch the mateorological data using raspberry pi can you provide python code for this?
I'm getting error with my code.

Haidar Mar 11, 2023 03:46 AM

How to access cr1000 datalogger through Arduino mega or any microcontroller??

And How I can give password to the datalogger so that it identify and accept it and begins communication to fetch the
mateorological data from Campbell scientific cr1000??


pokeeffe Mar 15, 2023 03:54 PM

Arduino mega and many other microcontrollers support HTTP GET. Passwords are described under Command Syntax, but you can set read-only anonymous access too. Fetching data is described under Data Query section.

https://help.campbellsci.com/crbasic/cr1000x/#Info/webserverapicommands1.htm#kanchor360

https://help.campbellsci.com/crbasic/cr1000x/Content/Info/dataqueryexamples1.htm 


Harse1971 Nov 1, 2023 09:38 AM

This post is under review.


Makada Dec 20, 2023 10:13 AM

@Haidar: can you show your current python script so I have a look. 

Log in or register to post/reply in the forum.