RE: Um...My Temp in F Degrees is the Same as the C Degrees/Dang!

var b = require(‘bonescript’);

function readTemp() {
b.analogRead(‘P9_39’, displayTemp);
}

function displayTemp(reading) {
var millivolts = reading.value * 1800;
var tempC = (millivolts - 500) / 10;
var tempF = (tempC * 9/5) + 32
console.log("TempC = " + tempC + "\t Temp F = " + tempF);
}

setInterval(readTemp, 100000);

Okay…

This is my software from “Programming the BeagleBone Black” in the “hardware interfacing” section. I am messing with a TMP36 sensor for analog temp. reads.

The issue is this:

I keep getting a similar read for my C and F reads. I should be able to get the F read but unfortunately, I get the same as the C read.

Seth

P.S. Try your TMP36 sensor and this software and get back to me. I would love to know about the value(s) I am creating and why they are returning the listed read(s). Oh and here is a photo. See!

You must live near the equator... :wink:

-40F == -40C

This is something norther folk in America & Canada run into every once in
awhile in January...

Regards,

Hello Rob,

Seth here. I am located in the states. There is a big fault and I am not clued in, obviously. How is F == C? I figured that there would be a part to the software, the section that displays the difference, that tells me/you the C and F reads.

Seth

P.S. I am in about an 80 degree temp. right now. So, do I need to replace “reading.value” with an actual numerical value? I will keep trying.

Hello Rob,

Seth here. I am located in the states. There is a big fault and I am not
clued in, obviously. How is F == C?

Your values are correct:

-39.58241C = -39.2483F

-40C = -40F
0C = 32F
100C = 212F

I figured that there would be a part to the software, the section that
displays the difference, that tells me/you the C and F reads.

Seth

P.S. I am in about an 80 degree temp. right now. So, do I need to replace
"reading.value" with an actual numerical value? I will keep trying.

var millivolts = reading.value * 1800;

That's not right..

var millivolts = (reading.value / 4096.0) * 1800;

i think...

Regards,

BoneScripts’s analogRead tries to normalize the value from 0 to 1 (full scale, i.e. 1.8V). I don’t rule out a bug as drivers have changed in reporting millivolts or raw values.

Hello Rob,

Seth here. I am located in the states. There is a big fault and I am not clued in, obviously. How is F == C? I figured that there would be a part to the software, the section that displays the difference, that tells me/you the C and F reads.

Seth

P.S. I am in about an 80 degree temp. right now. So, do I need to replace “reading.value” with an actual numerical value? I will keep trying.

Try printing the reading.value. I expect you have a wiring issue. Double check it is connected to P9.39.

Hello,

How can I print out the reading.value?

Seth

Hello,

I used cosole.log to print out the name and value of reading.value.

Seth

Oh and my print out was 0.057xxxx.

Seth

Here are some print outs from a recent run from my software on the BBGW.

Seth

P.S. Here is the picture:

On Thu, 29 Jun 2017 17:46:14 -0700 (PDT), Mala Dies
<functt@gmail.com> declaimed the following:

   var b = require('bonescript');

   function readTemp() {
       b.analogRead('P9_39', displayTemp);
   }

   function displayTemp(reading) {
       var millivolts = reading.value * 1800;
       var tempC = (millivolts - 500) / 10;
       var tempF = (tempC * 9/5) + 32
       console.log("TempC = " + tempC + "\t Temp F = " + tempF);
   }

  Is that a cut&paste, or did you type it in by hand?

  I ask as I note that there is no semicolon ending the line declaring
tempF

  Someone else will have to comment on whether that language does
automatic promotion to float on division, otherwise they could be a loss of
significance ( 2/3 => 0 vs 2.0/3.0 => 0.66667)

  Someone else will have to comment on whether that language does
automatic promotion to float on division, otherwise they could be a loss of
significance ( 2/3 => 0 vs 2.0/3.0 => 0.66667)

just use commandline javascript interpreter:
$ js

9/5

1.8

Hello,

I got the software from a book, “Programming the BeagleBone Black.”

Seth

Hello,

Okay…I will try it.

Seth

Mr. Rob,

Why would I use the value 4096.0?

Seth

P.S. I have tried to suit the software to suit my needs and I keep coming up empty. I will try this value and I will get back to you.

Do you know anything about the hardware you're trying to use ? the onboard
ADC's report a value of 0-4095(4096 total ) depending on how much voltage
they're seeing at the pins. 1.8 would be fore the absolute maximum value in
voltage the ADC can read before failure. The reason why 4096.0 was probably
mentioned is that would indicate a float value, which strickly speaking is
not really necessary in Javascript. But in C, sometimes, it's necessary.

Hello,

Thank you.

Seth

Hello Rob,

Seth here, again. I tried out the (reading.value / 4096.0) * 1800; in the software. It tells me that I have a temperature of -49.99 degrees in Celsius. I am trying to make believe my calculations from the software are correct with the inside/climate controlled temp. in this house.

49 degrees in Celsius is 120.xx in Fahrenheit. This seems extreme. It is extreme. I have my temp on 80 degrees in Fahrenheit. I was expecting a degree in Celsius of 26 or 27 from my reads. If you have any ideas, please let me know. I am pretty sure you are very busy and do not have complete time to dedicate to me. I understand completely.

Seth

P.S. Oh and I cut out the temp. transfer from Celsius to Fahrenheit in the software. This is how the 49.xx came to be. I tried more than one TMP36 sensor. I will keep trying for this project I plan on keeping in time. Oh…is there a type of ADC we are using that can be researched? Can I find this ADC name and brand in the SRM?

Oh SNAP,

I think I may be on the wrong board. I just realized I have been using the BBGW instead of the Rev. C or BBBW. Crud. I will keep trying.

Seth

P.S. I will get back to everyone soon. Sorry for this issue.

On Fri, 7 Jul 2017 17:52:25 -0700 (PDT), Mala Dies
<functt@gmail.com> declaimed the following:

Hello Rob,

Seth here, again. I tried out the *(reading.value / 4096.0) * 1800;* in the
software. It tells me that I have a temperature of -49.99 degrees in
Celsius. I am trying to make believe my calculations from the software are
correct with the inside/climate controlled temp. in this house.

  So, what value are you getting for "reading.value" and does it make
sense?

  Working backwards (with the above correction)

  function displayTemp(reading)
  {
    var millivolts = reading.value * 1800;
    var tempC = (millivolts - 500) / 10;

for a temperature of -49.99

-49.99 = (mv - 500) / 10
-499.9 = (mv - 500)
0.1 = mv

0.1 = (rv / 4096) * 1800
5.555E-5 = rv / 4096
0.227 = rv

  For all practical purposes, your -49.99 is what would be expected if
you were reading ground (actual ground would result in -50degC).

  Comparing the same circuit and (similar) code between (Monk)
Programming the Beaglebone Black and (Chavan) Programming the BeagleBone...

Neither use the 4096 divisor; apparently bonescript is supposed to already
scale the ADC value to 0.0-1.0; the 4096 would be needed if you were
getting the actual ADC counter (12-bit). They differ on the temperature
equation (beyond the difference between mV and V)

  v = rv * 1.8
vs
  mv = rv * 1800

  degC = (100 * v) - 50
vs
  degC = (mv - 500) / 10

  If "rv" were 0.5, then

v = 0.9 mv = 900
degC = 40.0 degC = 40.0

... so the two formulation will display the same value. Now, if rv were 0.0
it gives

v = 0.0 mv = 0
degC = -50 degC = -50

  Note that the sensor is rated for a minimum of -40degC, so there must
be some residual voltage on the ADC at all times -- equivalent to 0.1v (or
0.055 from the ADC)

  According to the spec sheet, the TMP36 has an offset of 0.5v, and
produces 0.75v at 25degC.

  degC = (v - 0.5) * 100

is the direct translation, and again, an ADC value of 0.0 gives a -50degC.