RTD value is not displayed well.

Moderator: RevPiModIO

Post Reply
kimgama
Posts: 2
Joined: 20 Jun 2023, 03:37

RTD value is not displayed well.

Post by kimgama »

hello.

I am using Revpi Compact.

I am trying to read RTD values with Python. It's not working..

It is read normally in Node-red and PLC Loader programs.

When I run it as python code, the values are displayed differently.

The code used is below

Upload a screen capture as well.

I look forward to your help.

thank you.
RTD_value_error.png
RTD_value_error.png (428.34 KiB) Viewed 9234 times

Code: Select all

import datetime
import time
import revpimodio2
rpi = revpimodio2.RevPiModIO( autorefresh = True )

while True:
	time_stamp = datetime.datetime.utcnow().isoformat()
	print("TIME:",time_stamp)
	ai_value   = rpi.io['RTD_Value_1'].value
	ai_value2   = rpi.io['RTD_Value_2'].value
	core_temp = rpi.io['Core_Temperature'].value
	frequency = rpi.io['Core_Frequency'].value
	
	print("PT100_1:",ai_value)	
	print("PT100_2:",ai_value2)	
	print("Frequency: ", frequency)
	print("CPU: ",core_temp)
	time.sleep(0.5)
	
User avatar
RevPiModIO
KUNBUS
Posts: 335
Joined: 20 Jan 2017, 08:44
Contact:

Re: RTD value is not displayed well.

Post by RevPiModIO »

Hi kimgama!

You are using the "Memory-Values", which just define the type of your analog inputs.

Just change your Code like this:

Code: Select all

        # Change RTD_Value_* to AIn_*
	ai_value   = rpi.io['AIn_1'].value / 10
	ai_value2   = rpi.io['AIn_2'].value / 10
Now you get the temperature with a decimal place.

Greeting
Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
kimgama
Posts: 2
Joined: 20 Jun 2023, 03:37

Re: RTD value is not displayed well.

Post by kimgama »

thank you!
It works very well.
Post Reply