Jump to content
  • 0

WebDAQ 904: 1) temperature from ntc thermistor 2) reading latest sample via REST API and Python


Question

Posted

Dear Ladies and Gentlemen,

we newly bought the WebDAQ 904 for our R&D Team and right now I have some questions regarding the functionality of the device.

My Questions:
1) Get temperature values from a thermistor

We thought it should be possible to connect a thermistor (e.g. ntc) to one of the channels of the device and retrieve the temperature data from that kind of sensor.
Thus, where are looking for a “Job Editor” functionality where we can enter the specifications of our thermistor to retrieve the correctly calculated temperature values. In such a provided job configuration mask we would enter the thermistor variables “beta”, e.g. 3988, “design resistance”, e. g. 10 kOhm and the “design temperature”, e. g. 25°C.

Question 1:
Is it possible to directly retrieve temperature data from a ntc thermistor, as described above?


2) Getting latest recorded logging sample via REST API

I’ve partly studied your sample programs “read_data_wait_for_start.py” and “read_data.py” (both written for python, found here: https://files.digilent.com/#downloads/WebDAQ/REST-API/).
Pulling the data samples via REST API in this code is done by sending e. g. the command GET /mywebdaq.local/api/v1.0/schedule/jobs/job1/samples/123/1000/bin ;
where 123 is standing for the logged sample, with the index 123,  that way I‘m fetching sample 123;
1000 is standing for the amount of samples which shall be fetched at a time.

Question 2:
Is it possible to pull only the latest sample by sending a corresponding URI via REST API?
This URI  could be:
GET /mywebdaq.local/api/v1.0/schedule/jobs/job1/samples/latest_sample/bin
The idea is to write a loop in python that only fetches the latest single sample within one loop iteration, and it should not fetch an accumulated data block.


Thank You for Your effort,
JoTop

2 answers to this question

Recommended Posts

  • 0
Posted

The WebDAQ 904 does not support thermistors. If possible, consider switching to using a thermocouple. 

To get the most current value using the REST API, query the job status. You should get a samplesAcquired value as part of the response. Then, you can query the latest samples by doing (samplesAcquired - 1) as the sample index and sample count of 1.

  • 0
Posted

Dear DAQman,
thank You for answering my question.
Meanwhile a found a solution for my pyhton script. It uses the "samplesAcquired" of the job status json / dictionary.
My problem was, that a received lot's of empty strings with no data inside.
As soon as I send multiple succesive requests to the webdaq within short time I will finally get a string with the wanted data.

I do it that way in Python (simplified):
import requests
import codecs
import time as tm

# [...]


def get_index_via_job_status_json(base_url=BASE_URL, job_name=JOB_NAME):
    job_status_response = requests.get(base_url + '/schedule/jobs/' \
                                       + job_name + '/status')
    job_status_response.raise_for_status()  # raise http error if available
    job_status_json = job_status_response.json()
    current_index = job_status_json['samplesAcquired']
    # print(current_index)
    return current_index
    
      
def acquire():
    read_index = get_index_via_job_status_json()
    content = None
    while 1:
        # print('Looping')
        current_address = BASE_URL + '/schedule/jobs/' + \
        JOB_NAME + '/samples/' + str(int(read_index)) + \
            '/' + str(MAX_READ_SAMPLE_COUNT) + '/csv'
        # print(current_address)
        data = requests.get(current_address)
        data.raise_for_status()
        data_content = data.content
        # print('data_content bytewise:', data_content)
        data_content = codecs.decode(data_content, 'utf-8')
        # print('data_content:', data_content)
        content = data_content
        if content != '':
            # print(content)
            # print('We got something!')
            break
        tm.sleep(0.01)
    return content

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...