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

63 views
Skip to first unread message

Mala Dies

unread,
Jun 29, 2017, 8:46:14 PM6/29/17
to BeagleBoard
    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!

Robert Nelson

unread,
Jun 29, 2017, 9:06:01 PM6/29/17
to Beagle Board, Mala Dies
You must live near the equator... ;)

-40F == -40C

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

Regards,

--
Robert Nelson
https://rcn-ee.com/

Mala Dies

unread,
Jun 29, 2017, 9:21:27 PM6/29/17
to BeagleBoard, fun...@gmail.com
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.

Robert Nelson

unread,
Jun 29, 2017, 9:29:36 PM6/29/17
to Beagle Board, Mala Dies
On Thu, Jun 29, 2017 at 8:21 PM, Mala Dies <fun...@gmail.com> wrote:
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,

Jason Kridner

unread,
Jun 29, 2017, 9:48:02 PM6/29/17
to beagl...@googlegroups.com, Mala Dies
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. 


Regards,

--
Robert Nelson
https://rcn-ee.com/

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAOCHtYhArOtm66Zf2vkCsSfjKzpqz7B9u6iGDYwhe4NUCx%3D17A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Jason Kridner

unread,
Jun 29, 2017, 9:50:44 PM6/29/17
to beagl...@googlegroups.com, fun...@gmail.com


On Jun 29, 2017, at 9:21 PM, Mala Dies <fun...@gmail.com> wrote:

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. 

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Mala Dies

unread,
Jun 29, 2017, 10:59:43 PM6/29/17
to BeagleBoard, fun...@gmail.com
Hello,

How can I print out the reading.value?

Seth

Mala Dies

unread,
Jun 29, 2017, 11:04:01 PM6/29/17
to BeagleBoard, fun...@gmail.com
Hello,

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

Seth

On Thursday, June 29, 2017 at 8:50:44 PM UTC-5, Jason Kridner wrote:

Mala Dies

unread,
Jun 29, 2017, 11:05:07 PM6/29/17
to BeagleBoard, fun...@gmail.com
Oh and my print out was 0.057xxxx.

Seth

Mala Dies

unread,
Jun 29, 2017, 11:27:00 PM6/29/17
to BeagleBoard, fun...@gmail.com
Here are some print outs from a recent run from my software on the BBGW.

Seth

P.S. Here is the picture: 

Dennis Lee Bieber

unread,
Jun 30, 2017, 10:54:56 AM6/30/17
to beagl...@googlegroups.com
On Thu, 29 Jun 2017 17:46:14 -0700 (PDT), Mala Dies
<fun...@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)

--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/

Przemek Klosowski

unread,
Jun 30, 2017, 5:14:06 PM6/30/17
to beagl...@googlegroups.com

On Fri, Jun 30, 2017 at 10:54 AM, Dennis Lee Bieber <wlf...@ix.netcom.com> wrote:
  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
js> 9/5
1.8

Mala Dies

unread,
Jun 30, 2017, 7:04:23 PM6/30/17
to BeagleBoard
Hello,

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

Seth

Mala Dies

unread,
Jun 30, 2017, 7:05:00 PM6/30/17
to BeagleBoard
Hello,

Okay...I will try it.

Seth

Mala Dies

unread,
Jun 30, 2017, 11:33:45 PM6/30/17
to BeagleBoard, fun...@gmail.com
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.

William Hermans

unread,
Jun 30, 2017, 11:52:05 PM6/30/17
to beagl...@googlegroups.com

On Fri, Jun 30, 2017 at 8:33 PM, Mala Dies <fun...@gmail.com> wrote:
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.

Mala Dies

unread,
Jul 1, 2017, 12:09:41 AM7/1/17
to BeagleBoard
Hello,

Thank you.

Seth

Mala Dies

unread,
Jul 7, 2017, 8:52:26 PM7/7/17
to BeagleBoard, fun...@gmail.com
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?

On Thursday, June 29, 2017 at 8:29:36 PM UTC-5, RobertCNelson wrote:

Mala Dies

unread,
Jul 7, 2017, 8:56:25 PM7/7/17
to BeagleBoard, fun...@gmail.com
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. 

Dennis Lee Bieber

unread,
Jul 7, 2017, 11:04:37 PM7/7/17
to beagl...@googlegroups.com
On Fri, 7 Jul 2017 17:52:25 -0700 (PDT), Mala Dies
<fun...@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.

Mala Dies

unread,
Jul 8, 2017, 9:22:41 PM7/8/17
to BeagleBoard
Hello Dennis,

Seth here. Thank you for all that info. I will look further into the specification sheet on this particular product. Now, I know this is not your issue but here goes...

I try to finish each book I get, i.e. no matter the changes in the kernel, image, and/or software I use. It is just a hobby for me as of now. I get the V and mV difference. I get basic math but I was unaware of the offset. The book, Programming the BeagleBone Black (Monk), stated something different. I was not expecting to see my readings as similar values. I understand a little more now.

The book had the readings at various temperatures, e.g. Fahrenheit was a completely different value compared to Celsius. This is the only reason I am in awe. I thought it was as easy as software, hardware, book, and understandings. I know now that I will need to delve deeper into learning before asking anything.

Seth

P.S. Sometimes I take time out to try out new books and software on the BBB and the other variations of that specific board. I am far from a "real McCoy" programmer that knows everything. I really do appreciate you helping me to better understand. 

Dennis Lee Bieber

unread,
Jul 9, 2017, 11:21:36 AM7/9/17
to beagl...@googlegroups.com
On Sat, 8 Jul 2017 18:22:41 -0700 (PDT), Mala Dies
<fun...@gmail.com> declaimed the following:

>Hello Dennis,
>
>Seth here. Thank you for all that info. I will look further into the
>specification sheet on this particular product. Now, I know this is not
>your issue but here goes...
>

Mostly I ran through all those equations to confirm what might be
happening; I'm not certain I even own a TMP36 in the back corner (my
apartment is a mess and I have to dig just to get to the
BBB/RPi/Arduino/TIVA/etc. stuff).

There was also that matter where someone recommended that factor of
4096 was needed -- but I have trouble believing two books, both using the
same sensor and bonescript, could overlook such a factor.

Compounding that, is an old report
https://github.com/jadonk/bonescript/issues/39 that says the version of
bonescript on the old Angstrom OS already scaled the analog reading into
the 1.8V (well, 1800mV) range -- so the multiplication by 1.8 (or 1800)
wouldn't be needed for them. Yet the documentation at
http://beagleboard.org/Support/BoneScript/analogRead/ (which of about the
same time frame as the other report) states it returns a float between 0
and 1, where 1 => 1.8V, hence the scaling factor IS needed here.

I'm tempted to ask you to try
http://www.toptechboy.com/tutorial/beaglebone-black-lesson-9-reading-analog-inputs-from-python/
(which is using a simple potentiometer to set values, and does not use
node.js weird [to me] "everything is an asynchronous callback"). I believe
recent builds of the Debian OS already include Adafruit_BBIO, but if not it
isn't difficult to fetch.

Maybe also try using a different Analog input pin. The advantage to
trying with the potentiometer is that you can easily sweep through the
entire range from 0.0 to 1.8V. If you still keep getting 0.0, then either
you are wired to the wrong pins, the pins are configured for digital (GPIO
0/1), or you have a faulty ADC [burned out from overload with >1.8V at some
time -- but without killing the rest of the BBB].

Note that the Python version of the TMP36 exercise is on page 102 of
[Chavan]; [Monk} is only bonescript, so no help

>I try to finish each book I get, i.e. no matter the changes in the kernel,
>image, and/or software I use. It is just a hobby for me as of now. I get
>the V and mV difference. I get basic math but I was unaware of the offset.
>The book, Programming the BeagleBone Black (Monk), stated something
>different. I was not expecting to see my readings as similar values. I
>understand a little more now.
>

The main problem is that you aren't getting /valid/ readings; and the
invalid readings are noise close to the point where Celsius and Fahrenheit
scales manage to cross over (-40 is the same temperature in both, but +40
is a cold day in Fahrenheit, and a deadly heat wave in Celsius).

Try with a potentiometer (you could even use the same program, just
pretend the setting is a temperature)... [Use a fixed pitch font to view
diagram]


1.8V ---+
|
$--- ADC
|
GND ---+

(where $ is the potentiometer). With the pot all the way down you should
get "temps" of -50degC, and turned all the way up should get 130degC,
half-way should give 40degC.

Mala Dies

unread,
Jul 9, 2017, 9:50:59 PM7/9/17
to BeagleBoard
Hello Dennis,

Seth here, again. Thank you again for all this info. I will look into it. It may take me a while to reply next time. I need to order some POTs and try the task at hand. 

Seth

P.S. I could have burnt it out a while back on the TMP36. I will try a different pin too. I should be able to get back to you on the different pin soon. 
Reply all
Reply to author
Forward
0 new messages