Reading an Analog input from a web page ?

Hello group;

I am wondering if is possible to read an analog input on the BBB at the press of a button on a web page.

I already have code that uses node.js and socket.io to turn on an LED in response to a button push.

But I want to Read an input and display the result.

Does anyone know how to do this ??

Thanks J

http://www.packtpub.com/building-a-home-security-system-with-beaglebone/book

William:
I have an example[1] that not only reads analog in, but it also plots it on a web page.

–Mark

[1] BeagleBoard-exercises/realtime at master · MarkAYoder/BeagleBoard-exercises · GitHub

p.s. I also have a homework[1] assignment that gives an overview of it.

–Mark

[1] https://drive.google.com/#folders/0B5UNMAgIJB74cUhIRlRwcXdQaTQ

Awesome Mark !

Thanks J

http://www.packtpub.com/building-a-home-security-system-with-beaglebone/book

Hi Mark;

Thanks for the response. I looked at the links, and I think it would be easier if provided more detail.

What I am trying to do is a lot less complex (I think) than your examples.

As part of my latest book for Packt Publishing, I have an RF Power Meter design.

Basically you read an analog voltage which is proportional to the RF power being measured.

(It could just as easily be temperature) multiply by a correction factor to convert millivolts to dBm and then

print out the result.

I already have test software that does this to the console, but I want to now output it to a web page.

The web page already controls a programmable attenuator, using socket.io and toggling IO bits.

I don’t need to graph anything; just print a number on the web page that corresponds to the RF power.

I found a couple of files in your git tree called “ioPlot.html” and “ioPlot.js”

but I am not sure how to simplify them for my application.

Thanks;

Bill

http://www.packtpub.com/building-a-home-security-system-with-beaglebone/book

Hi Mark;

Thanks for the response. I looked at the links, and I think it would be easier if provided more detail.

What I am trying to do is a lot less complex (I think) than your examples.

As part of my latest book for Packt Publishing, I have an RF Power Meter design.

Basically you read an analog voltage which is proportional to the RF power being measured.

(It could just as easily be temperature) multiply by a correction factor to convert millivolts to dBm and then

print out the result.

I already have test software that does this to the console, but I want to now output it to a web page.

The web page already controls a programmable attenuator, using socket.io and toggling IO bits.

I don’t need to graph anything; just print a number on the web page that corresponds to the RF power.

I found a couple of files in your git tree called “ioPlot.html” and “ioPlot.js”

but I am not sure how to simplify them for my application.

Thanks for the reply John

I found a really good tutorial on the web that uses socket.io to display a clock on a web page.

So modifying the code for my purposes was a snap J

I’ll look into DoJoToolkit anyway.

Bill

http://www.packtpub.com/building-a-home-security-system-with-beaglebone/book

HI William,

There are a few different methods you can use to accomplish this. Just keep in mind that I have been doing a lot of reading lately on Node.js( the last year or so ), but I am no expert.

First if the input you’re reading is accessible via sysfs, you can use process.exec( I think it is ) to read the value into a javascript variable to display on the webpage.

Secondly, I believe you could write an app that reads the value( perhaps using mmap ), and puts it into a “file” in memory, then use process.exec( again ) to cat the value into a javascript variable much like the above approach.

Anyway, there are surely other options and the two I mentioned above may / may not be the best approach. This is just something that I’ve been researching myself for the last year or so in my spare time “wondering” How I personally could achieve a similar goal.

http://stackoverflow.com/questions/12941083/get-the-output-of-a-shell-command-in-node-js

The above is one such link I believe that I came across at one point I though seemed useful.

BTW, you probably ran into the same alarm clock “app” I ran into recently that I thought was kind of cool :slight_smile:

Thanks J

Yeah, I think we both found the same tutorial. Anyhow the code seems to work.

Just have to test it with the hardware tomorrow.

It’s just cosmetic, but I’m trying to write the information to a text box or something now.

The main thing is it works !

The book should be out in a couple of months.

Later;

Bill

http://www.packtpub.com/building-a-home-security-system-with-beaglebone/book

There are security issues to contend with as well. The second option above may be the best I mentioned as the app could be made to run under root privileges, while the Node.js app could be given read privileges to this so called file in memory( while running as a regular user ). This native app could then be made to fire off at a certain interval, while the Node.js app could be made to read the values out at a multiple of the time interval. OR, Node.js has a FileWatcher Class method that fires off when a file changes. . .

Anyway, this is why I personally like Node.js so much as it is object oriented / event driven, with a lot of meat to it. It is also non blocking, and very fast. Lots to like . . . Good luck.