RE: TMP36 and BoneScript on BBB/Hello

72 views
Skip to first unread message

Mala Dies

unread,
Apr 14, 2017, 11:16:23 PM4/14/17
to BeagleBoard
Hello,

I am on P9_40 with my TMP36 temperature sensor. I used the book, "30 BeagleBone Black Projects." It is lesson number 11. It has some BoneScript lessons but I think the book is outdated. Does anyone know of the updates and how it pertains to temperature sensors?

Seth

P.S. Here is the software I cannot get to read. I am going to try and set it up in Cloud9 instead of on PuTTY and see what happens.

var b = require('bonescript');

var inputPin = "P9_40";

getBeagleTemp();

function getBeagleTemp();
    var value = b.analogRead(inputPin);

    var millivolts = value * 1800;
    var temp_c = ( millivolts - 500)/10;

    setTimeout(getBeagleTemp, 1000);

    console.log(temp_c);
}

Mala Dies

unread,
Apr 14, 2017, 11:45:26 PM4/14/17
to BeagleBoard
Hello Again,

I am not sure if people get kicks off of figuring out every tiny detail but here goes it!

4:4:41-ti-r82
fs.js:549
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/sys/bus/iio/devices/iio:device0/in_voltage1_raw'
  at Error (native)
  at Object.fs.openSync (fs.js:549:18)
  at Object.fs.readFileSync (fs.js:397:15)
  at Object.exports.readAIN (/usr/local/lib/node_modules/bonescript/src/hw_mainline.js:221:30)
  at Object.f.analogRead (/usr/local/lib/node_modules/bonescript/src/index.js:277:19)
  at getBeagleTemp (/var/lib/cloud9/temp11.js:8:19)
  at Object.<anonymous> (/var/lib/cloud9/temp11.js:5:1)
  at Module._compile (module.js:409:26)
  at Object.Module._extensions..js (module.js:416:10)
  at Module.load (module.js:343:32)
  at Function.Module._load (module.js:300:12)
  at Function.Module.runMain (module.js:441:10)
  at startup (node.js:140:18)
  at node.js:1043:3

These are the error codes for the older software listed above. If anyone knows where to direct me, I am sure I can start an elongate journey into reading. Shoot!

Seth

P.S. I have tried in PuTTY and on Chrome on the Cloud9 IDE. 

Mala Dies

unread,
Apr 15, 2017, 5:02:54 PM4/15/17
to BeagleBoard
Hello,

I finally got some read-outs but I had to change the software many times.

Seth

P.S. I will post the software soon.

On Friday, April 14, 2017 at 10:16:23 PM UTC-5, Mala Dies wrote:

Mala Dies

unread,
Apr 15, 2017, 5:17:37 PM4/15/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("Temp C=" + tempC + "   Temp F=" + tempF);
}

setInterval(readTemp, 10000);

I found this software and changed it a bit. I use P9_39 or P9_40, i.e. whichever. I get a read out but it is not what I thought it would be for tempF.

Seth

P.S. I got this software from a book, I think. It is either from, "Programming the BeagleBone Black," or the software on the updated images, e.g. analog2.js. I will research it again.  



On Friday, April 14, 2017 at 10:16:23 PM UTC-5, Mala Dies wrote:

Mala Dies

unread,
Apr 15, 2017, 5:21:18 PM4/15/17
to BeagleBoard
I keep getting 49.xxxxxxx and 57.xxxxxxx as the temperatures but I know it is incorrect. Any suggestions?

Seth

Mala Dies

unread,
Apr 17, 2017, 8:53:42 PM4/17/17
to BeagleBoard
var b = require('bonescript');
var x = celsius;
var z = farenheit;
var inputPin = "P9_39";

getBeagleTemp();

function getBeagleTemp() {
    var value = b.analogRead(inputPin, x, z);
    
    var millivolts = value * 1800;
    var x = (millivolts - 500)/10;
    var z = z (9/5 * x) - 32;
    setTimeout(getBeagleTemp, 10000);
    
    console.log(z);
}

Hello...

I tried this software outside of the Cloud9 IDE. I ran into an error. It says that it could not find the module bonescript. Directly afterwards, I tried to download, via npm, bonescript to see if there were any updates. I received a bunch of error codes. I guess I am just going to try the Cloud9 IDE for now.

Um, if anyone needs to see the bonescript download error codes, let me know. Oh and the first error while downloading bonescript was a node issue. Bonescript must use an update version of node while what I need is an outdated version of node.

Seth

P.S. If anyone can make that software work, let me know. Oh and BBB!

William Hermans

unread,
Apr 17, 2017, 9:01:18 PM4/17/17
to beagl...@googlegroups.com
Why don't you just learn how to use the ADC module from userspace LInux, then setup the ADC yourself, and read from the file in oneshot mode every cycle ? It's not that difficult . . .

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/e1dac766-ff75-4dec-af98-0e9c6db1407e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mala Dies

unread,
Apr 17, 2017, 9:21:32 PM4/17/17
to BeagleBoard
Okay...I can check on that too. I just thought using the bonescript software and the BBB would be fun. 

Seth

P.S. I have been using the analog pin P9_39 and/or P9_40. Thank you.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

William Hermans

unread,
Apr 17, 2017, 9:45:23 PM4/17/17
to beagl...@googlegroups.com
The point is this:

a) Setting up the hardware is as simple as loading a device tree overlay that has already been written for, and is included with all modern beaglebone Debian images.
b) Once you learn which file to read from, and how to use Nodejs to read from a file. You'll never run into these problems again.

My own Implementation from github: https://github.com/wphermans/Bonejs/blob/master/adc.js

Yes, only 15 lines of code, it is that easy. But of course, you're going to have to add a few lines of code for program flow, and logic, etc.

Anyway, maybe in the future you do want to use Jason's bonescript, that's fine. I'm not trying to dissuade you from using bonescript. It has a lot of features I did not add into my own code. But if you just need something simple to just read from a couple channels ADC . . . you do not need all that fluff.

To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/6386259a-2fcd-4c61-9da9-4251b7a0c4c7%40googlegroups.com.

Mala Dies

unread,
Apr 17, 2017, 9:53:28 PM4/17/17
to BeagleBoard
Hello Again,

Thank you. I will look into it. I know very little about node.js. I have been following some books on the BBB. I just know how to run .js files with node. That is about it for now.

Seth

P.S. I have used the ADC from the Adafruit_BBIO a long time ago but I stopped once things got odd. I was having trouble calling ADC with success. Anyway, thank you and I will check it out. 
Reply all
Reply to author
Forward
0 new messages