# LMT87 Temp sensor

**URL:** <https://forum.xod.io/t/lmt87-temp-sensor/5579>\
**Category:** Uncategorized\
**Created:** [November 20, 2021, 6:45pm UTC](https://forum.xod.io/t/lmt87-temp-sensor/5579 "2021-11-20T18:45:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![stedenis](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@stedenis](https://forum.xod.io/u/stedenis)\
**Post date:** [November 20, 2021, 6:45pm UTC](https://forum.xod.io/t/lmt87-temp-sensor/5579/1 "2021-11-20T18:45:14Z")

</div>

The LMT87 Temp sensor is a 3 pin device that I suspect might be represented by the analog-sensor. There is a rather complicated mapping (for tight tolerances) and a rough formula (for low tolerance) to interpret the output to an understood value. If I am to use the analog-sensor, how am I to enter the mapping or the formula? If not, can this node be created?

I can also imagine that an LMT87 node can be created from the analog-sensor. Is this the path that is usually followed?

---

<div class="post-metadata">

**Author:** ![wayland](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/wayland/32/1590_2.png) [@wayland](https://forum.xod.io/u/wayland)\
**Post date:** [November 20, 2021, 9:47pm UTC](https://forum.xod.io/t/lmt87-temp-sensor/5579/2 "2021-11-20T21:47:52Z")

</div>

Hi @stedenis,

A good starting point is the official guide to creating nodes for analog sensors:  
[https://xod.io/docs/guide/analog-sensor-node/](https://xod.io/docs/guide/analog-sensor-node/)

You can use the XOD math nodes to implement your mapping/formula.

If you get stuck, post your XOD patch here and I’m sure someone will point you in the right direction.

---

<div class="post-metadata">

**Author:** ![xodballxod](https://avatars.discourse-cdn.com/v4/letter/x/f475e1/32.png) [@xodballxod](https://forum.xod.io/u/xodballxod)\
**Post date:** [December 15, 2021, 4:27pm UTC](https://forum.xod.io/t/lmt87-temp-sensor/5579/3 "2021-12-15T16:27:47Z")

</div>

> [@stedenis](#):
>
> LMT87 node can be created from the analog-sensor

1. Arduino Analog Read node reads in fraction of the bit precision (10-bits = 1023 for Arduino) of the voltage range (5V for Arduino Uno). So you have to first divide to value by the bits (1023), then multiply by the 5V. They do like that to allow flexibility in the physical system, like using a different range of voltage. As Wayland says, below, the XOD node reports the fraction of 5V.  
[https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogReadSerial](https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogReadSerial)
2. If the equation map is complicated (like it’s non-linear over a big range), then you can chop out the part that you’re interested in and fit it, in Excel for example, to a linear or quadratic curve over the region of interest, and just use basic math nodes to program that in XOD. If it’s linear, then the MAP node will work, easily.

---

<div class="post-metadata">

**Author:** ![wayland](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/wayland/32/1590_2.png) [@wayland](https://forum.xod.io/u/wayland)\
**Post date:** [December 15, 2021, 6:16pm UTC](https://forum.xod.io/t/lmt87-temp-sensor/5579/4 "2021-12-15T18:16:01Z")

</div>

While the [analogRead](https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/) function in the Arduino IDE returns a value in the range 0 to 1023, XOD’s [analog-read](https://xod.io/libs/xod/gpio/analog-read/) node outputs a value in the range 0.0 to 1.0. This means that if you’re using an Arduino Uno, you simply need to multiply the output from the analog-read node by five to get the voltage.

---

<div class="post-metadata">

**Author:** ![stedenis](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@stedenis](https://forum.xod.io/u/stedenis)\
**Post date:** [December 19, 2021, 9:56pm UTC](https://forum.xod.io/t/lmt87-temp-sensor/5579/5 "2021-12-19T21:56:29Z")

</div>

Wayland, I understand. This is not foreign to me.

---

<div class="post-metadata">

**Author:** ![stedenis](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@stedenis](https://forum.xod.io/u/stedenis)\
**Post date:** [December 19, 2021, 10:05pm UTC](https://forum.xod.io/t/lmt87-temp-sensor/5579/6 "2021-12-19T22:05:34Z")

</div>

Per the LMT87 datasheet, “Although the LMT87 is very linear, the response does have a slight umbrella parabolic shape.” My needs require the ability across most of the full range. While there is a mapping (they call it a transfer table), I need the granularity between lookup elements. That means a formula is needed.

I have the formula. Now, I need to make it work. If I get this to work as a standard Arduino library, how well do libraries translate in XOD?

---

<div class="post-metadata">

**Author:** ![wayland](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/wayland/32/1590_2.png) [@wayland](https://forum.xod.io/u/wayland)\
**Post date:** [December 19, 2021, 11:14pm UTC](https://forum.xod.io/t/lmt87-temp-sensor/5579/7 "2021-12-19T23:14:38Z")

</div>

The developers have made it easy to wrap class-based Arduino libraries, see:  
[https://xod.io/docs/guide/wrapping-arduino-libraries/](https://xod.io/docs/guide/wrapping-arduino-libraries/)

However, for your project it may be simpler to place all of the code for your formula inside a not-implemented-in-xod node, see:  
[https://xod.io/docs/guide/nodes-for-xod-in-cpp/](https://xod.io/docs/guide/nodes-for-xod-in-cpp/)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [January 24, 2022, 11:32pm UTC](https://forum.xod.io/t/lmt87-temp-sensor/5579/10 "2022-01-24T23:32:44Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
