The RESISTANCE_TO_TEMPERATURE node converts resistance to temperature.The resistance should be a reading from a thermistor in Ohms.Params: unit : select Which unit of temperature to return.Returns: out : Scalar The resulting temperature.Python Code
from typing import Literalfrom flojoy import Scalar, flojoyfrom numpy import log@flojoydef RESISTANCE_TO_TEMPERATURE( default: Scalar, unit: Literal["K", "C", "F"] = "K", nominal_resistance: float = 1e4, nominal_temperature: float = 298.15, beta_coefficient: float = 3950,) -> Scalar: """The RESISTANCE_TO_TEMPERATURE node converts resistance to temperature. The resistance should be a reading from a thermistor in Ohms. Parameters ---------- unit: select Which unit of temperature to return. Returns ------- Scalar The resulting temperature. """ steinhart = log(default.c / nominal_resistance) # X = ln(R/Ro) steinhart /= beta_coefficient # X / B steinhart += 1.0 / (nominal_temperature) # X + (1/To) kelvin = 1.0 / steinhart # 1 / X celsius = kelvin - 273.15 fahren = celsius * 9 / 5 + 32 match unit: case "K": c = kelvin case "C": c = celsius case "F": c = fahren return Scalar(c=c)
Having problems with this example app? Join our Discord community and we will help you out!
Press enter or space to select a node.You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.
In this example, two measurements are extracted from an Arduino and plotted.
Here is a list of nodes to add:
OPEN_SERIAL
SINGLE_MEASUREMENT_SERIAL x2
VECTOR_INDEXING x4
LINE x2
RESISTANCE_TO_TEMPERATURE x2
APPEND x2
FEEDBACK x2
LOOP
Connect the nodes as seen in the example. Next set the number of loops to zero with the LOOP node parameters. Connect the 3 serial nodes to the desired serial device in the node parameters.
The SINGLE_MEASUREMENT_SERIAL should be returning two seperate measurements in the form of a Vector. Therefore, the VECTOR_INDEXING nodes should be set to 0 and 1 to extract the first and second measurements respectively (light intensity and temperature (in resistance)).
The RESISTANCE_TO_TEMPERATURE nodes convert the resistance of the thermistor to temperature.