Skip to content

READ_A0_PINS

Download Flojoy Studio to try this app
Read voltages from a sensor connected to a LABJACK U3 device. The SENSOR node can be used to convert voltage into temperature measurements. Params: default : OrderedPair number : int Defines the number of temperature sensors connected to the LabJack U3 device. Returns: out : OrderedPair The output of the node is a list of voltages measured from the sensors.
Python Code
from typing import Optional

import u3  # Import the library from LabJackPython in order to use our U3-LV device
from flojoy import NodeInitContainer, OrderedPair, flojoy, node_initialization


@flojoy(deps={"labjackpython": "2.1.0"})
def READ_A0_PINS(
    init_container: NodeInitContainer,
    default: Optional[OrderedPair] = None,
    sensor_number: int = 1,
) -> OrderedPair:
    """Read voltages from a sensor connected to a LABJACK U3 device.

    The SENSOR node can be used to convert voltage into temperature measurements.

    Parameters
    ----------
    default : OrderedPair, optional

    number : int
        Defines the number of temperature sensors connected to the LabJack U3 device.

    Returns
    -------
    OrderedPair
        The output of the node is a list of voltages measured from the sensors.
    """

    voltages: list[float] = []

    sensor_num: list[int] = []

    d = init_container.get()
    if d is None:
        raise ValueError("LabJack U3 device not initialized")

    for i in range(0, sensor_number):
        sensor_num.append(i + 1)
        # Loop on the LabJack pins
        voltage: float = d.getAIN(i)
        voltages.append(voltage)

    return OrderedPair(x=sensor_num, y=voltages)


@node_initialization(for_node=READ_A0_PINS)
def init():
    d = u3.U3()
    d.configIO(FIOAnalog=255, EIOAnalog=0)

    return d

Find this Flojoy Block on GitHub

Videos

Temperature measurements with LabJack & Flojoy

Example App

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

In this example, we show how to record and display temperature measurements with a LABJACK U3 device and update them in a Loop. The appendix contains all information about hardware requirements and sensor connections (Images). You’ll also need to install the Labjack exodriver to communicate with the U3 device through USB: https://labjack.com/pages/support?doc=/software-driver/installer-downloads/exodriver/.

When the sensors are connected to the LABJACK U3 device and placed to record temperature, you can prepare your Flojoy app:

The LABJACKU3 node communicates with the LABJACK U3 device to extract temperature measurements from the sensors. This node has only one parameter to fix: the number of sensors (6 in this example).

The BAR node displays all temperature measurements on the same figure.

To update the results with the latest measurements, we use the LOOP node to create a loop around our LABJACKU3 and BAR nodes. (Refer to the LOOP node documentation for more information).