Connecting sensor to Rev pi

Show the world your Revolution Pi project!
Post Reply
Ajinkya09
Posts: 13
Joined: 11 Jan 2024, 06:27

Connecting sensor to Rev pi

Post by Ajinkya09 »

I am a new user exploring Rev Pi for the first time. Just for tiral seek guidance on connecting a P type thermocouple temperature sensor to my Rev Pi, while also developing a Node-RED dashboard. Specifically, I would like to know whether direct Python coding suffices for this task or if CODESYS is necessary. Additionally, I am interested in recommended steps and considerations for integrating the sensor data into the Node-RED dashboard.
User avatar
stefanh
KUNBUS
Posts: 33
Joined: 05 Apr 2023, 10:53

Re: Connecting sensor to Rev pi

Post by stefanh »

Hi Ajinkya09,

here are some tips and instructions for getting started with your RevPi and a temperature sensor
Requirements: in addition to the RevPi, you need a RevPi AIO expansion module to work with a temperature sensor (RTD, Pt100/Pt1000).

The link to our documentation will help you to connect the temperature sensor (RTD, Pt100/Pt1000):
https://revolutionpi.com/tutorials/uebe ... -messung-2

The link to our documentation will help you to configure the temperature sensor (RTD, Pt100/Pt1000) input:
https://revolutionpi.com/tutorials/uebe ... gurieren-2

Once you have successfully connected your temperature sensor (RTD, Pt100/Pt1000) to the RevPI AIO expansion module, you can start programming.

Testing AIO with piTest

1. Connect via SSH to your RevPi
  • Type the following command into your terminal tool on your computer: bash:~ pi@”PISERIALNUMBER”.local
    password: ON YOUR REVPI
2. show all devices
  • bash:~ piTest -d > Found 3 devices: […]
3. Testing the RTD „Resistance Temperature Detector“ on the AIO
  • bash:~ piTest -r RTDValue_1 > 2 Byte-Value of RTDValue_1: 290 dez (=0122 hex) 

Temperature sensor (RTD, Pt100/Pt1000) and AIO with Node-RED

1. Open a browser on your computer and connect to your RevPi via IP or ”PISERIALNUMBER”.local
  • login with user: “admin” password: ON YOUR REVPI
    webstatus website opens up
    click on the services tab to enable Node-RED
    select Enable/Disable Node-RED “Enabled” and click SAVE ALL
2. Click on the APPS tab and start Node-RED by clicking on start button
> Node-RED website opens up
3. Install the graphical user interface
  • Click on the burger menu
    Click on “Manage palette”
    Click on the “Install” tab.
    Search for the entry “node-red-dashboard”
    Click on “Install”
4. Create a first flow
  • Drag a Revolution Pi - “revpi – single – input” node into the flow
    Double-Click on “revpi – single – input” node and select Input Pin: “ PIN: RTDValue_1”
    search in filter nodes “debug” and add a “debug” node
    Connect the two nodes
    Double-Click on revpi node and click the pen symbol at the Server
    Config a Server, user: “pi” password: ON YOUR REVPI and click Add or Update
5. Create a dashboard
  • goto the dashboard menu (right)
    add a Tab and a Group
    add a node named “gauge”
    Connect the “gauge” node to the “revpi – single – input” node (parallel to the “debug” node)
    Click the deploy and the than the link symbol top right at the dashboard menu
    > dashboard displays the temperature

Temperature sensor (RTD, Pt100/Pt1000) and AIO with Python

1. Connect via SSH to your RevPi
  • Type the following command into your terminal tool on your computer: bash:~ pi@”PISERIALNUMBER”.local
    password: ON YOUR REVPI
2. create a Python script
  • bash:~ nano tmp_sensor.py
    copy the following code into nano

Code: Select all

import revpimodio2, time
for count in range(6):
    rpi = revpimodio2.RevPiModIO(autorefresh=True)
    tmp_sensor_1 = rpi.io.RTDValue_1.value
    print("Temperature: " + str(tmp_sensor_1))
    time.sleep(5)
  • strg+o to save the file and strg+x to close the editor
3. run the Python script
  • bash:~ python3 tmp_sensor.py

Temperature sensor (RTD, Pt100/Pt1000) and AIO with Codesys

1. Install CODESYS Development System V3 Install CODESYS Development System V3
2. Install CODESYS Control for Raspberry Pi 3. Install Revolution Pi Library for CODESYS Explanation Application Based Licenses | CODESYS Store International 4. Preparing your CODESYS Development System
  • Start CODESYS V3.5 SP19 Patch 2
    Unzip CODESYS-Control-RaspberryPi-4800.zip
    Go to Tools  CODESYS Installer
    Click: “Install File”
    Select CODESYS Control for Raspberry PI 4.8.0.0.package
    Select CODESYS Control for Raspberry PI 4.8.0.0 in the menu
    Accept the License Agreement and continue
    Follow the instructions  The add-ons were successfully installed.
    Unzip revolutionpibridge-V1.4.0.0.zip
    Go to Tools  CODESYS Installer
    Click: “Install File”
    Select RevolutionPiBridgeV1.4.0.0.package in the menu
    Accept the License Agreement and continue
    Follow the instructions  The add-ons were successfully installed.
5. Preparing your RevPi
  • Start CODESYS V3.5 SP19 Patch 2
    Go to Tools  Update Raspberry Pi
    Raspberry Pi menu: enter the password from your RevPi
    Raspberry Pi menu: enter IP Adress from your RevPi
    Raspberry Pi menu: select CODESYS Runtime Package: 4.8.0.0 (raspberry, armhf)
    Raspberry Pi menu: click “install”
    Follow the instructions  The runtime were successfully installed.
  • If you install the codesys version 3.15.19 or higher, you have to do the following things.
    connect to your RevPi via SSH
    edit the Codesys Config
    bash: ~ nano /etc/CODESYSControl_User.cfg
    add “PlaceholderFilePath.1=/etc/revpi, $configrsc$” under “[SysFile]”
    save with Ctrl + O, close nano with Ctrl + X
    restart the Codesys Service
    bash: ~ sudo service codesyscontrol restart
6. Creating a CODESYS Project
  • Start CODESYS V3.5 SP19 Patch 2
    File New Project: Create a new standard project
    Select Device: “CODESYS Control for Raspberry Pi MC SL (CODESYS GmbH)”
    Select PLC_PRG in: “Structured Text”  Click “OK”
7. Add your RevPi & IO modules in the CODESYS Project
  • Right-click on "Device (CODESYS Control for Raspberry Pi MC SL)" in the Devices tab.
    Click on "Add Device…".
    Click on the + Miscellaneous to expand
    Select your RevPi  Click “Add Device”
    Right-click on your added RevPi  Click “Add Device”
    Select piBridgeLeft  Click “Add Device”
    Right-click on piBridgeLeft  Click “Add Device"
    Select RevPi_AIO  Click “Insert Device”
    Select RevPi_DIO  Click “Insert Device”
    Important: a Device named PiBridgeEnd will be automatically generated, over this device you can add some Gateway via click “Plug Device…”
8. Config your IO modules on your RevPi
  • Double-click on “RevPi_AIO (RevPi_AIO)” in Devices/PROJECTNAME/Device (CODESYS Control fpr Raspberry Pi MC SL)/RevPi_Connect (RevPi Connect)/piBridgeLeft(piBridgeLeft)
    Check and change the settings
    Go to tab “Revolution Pi AIO Module I/O Mapping”
    Give the channels you want to use a variable name – “tmp_sensor_1”
9. Run a CODESYS application on your RevPi
  • Double-click on PLC_PRG (PRG) in Application
    add a variable named “iSensorTmp”
PROGRAM PLC_PRG

Code: Select all

VAR
iSensorTmp: INT;
END_VAR
  • add a line code zu read the value

Code: Select all

iSensorTmp:= Temp_sensor_1; // Read RTD Channel 1
  • Click on menu Online Login
    Follow the instructions and click on Debug Start or F5 key
    displays the temperature in the debug view
I hope this little guide helps you and you have fun programming our devices.

Regards

Stefan
Support | KUNBUS
Ajinkya09
Posts: 13
Joined: 11 Jan 2024, 06:27

Re: Connecting sensor to Rev pi

Post by Ajinkya09 »

Thank you, Stefan,
for providing detailed instructions on connecting a sensor to Revolution Pi. Your guide is comprehensive and will be valuable for me and also many users.

In my case now for this project, I'm using a K-type thermocouple sensor with a MAX6675 converter when working with Raspberry Pi. Could you please advise on how this work with RevPi

1) How to connect a K-type thermocouple sensor to Revolution Pi?
2) Is it possible to directly program in Python for reading K-type thermocouple data without using Codesys?
3) Do I need to use Codesys, or are there alternative methods for programming the Revolution Pi with a K-type thermocouple?
4) How can I set up a Node for data visualization in Node-RED when using a K-type thermocouple sensor?

Your guidance is appreciated.

Best regards,
Ajinkya09
Ajinkya09
Posts: 13
Joined: 11 Jan 2024, 06:27

Re: Connecting sensor to Rev pi

Post by Ajinkya09 »

if possible, Pease give answer to above question as soon as possible I am slightly confused as to where I went wrong or whether it is even wrong in the first place. Hope to get a reply on this soon!
Post Reply