Difference between revisions of "ECE497 Project: Node.js Weather Station"

From eLinux.org
Jump to: navigation, search
(Work Breakdown)
Line 78: Line 78:
 
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this...  
 
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this...  
  
* At last we successfully excuate the ./myi2c file inside our javascript using the following code:
+
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:
  
 
<pre>
 
<pre>
Line 125: Line 125:
  
 
4. The next thing we will do is to refresh the website every other time...
 
4. The next thing we will do is to refresh the website every other time...
 +
 +
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts.
 +
 +
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes.
  
 
== Conclusions ==
 
== Conclusions ==
  
 
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.
 
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.

Revision as of 22:00, 17 February 2012


Team members: Yuming Cao, Ziyi Zhang

Executive Summary

Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard.

Give two sentences telling what works.

Give two sentences telling what isn't working.

End with a two sentence conclusion.

The sentence count is approximate and only to give an idea of the expected length.

Installation Instructions

1. Here's our github path that includes everything useful to our project: https://github.com/caoy1/Project.

2. Additional packages installed via opkg:

  • install nodejs
opkg update
opkg install nodejs
opkg install nodejs-dev
  • install node package manager
curl http://npmjs.org/install.sh | sh
  • install socket.io module
npm install socket.io
  • install binary module
npm install binary
  • Include kernel mods.
  • If there is extra hardware needed, include links to where it can be obtained.
  • Here's the guideline to install Cloud9 easily: [1]

User Instructions

Once everything is installed, how do you use the program? Give details here, so if you have a long user manual, link to it here.

Highlights

Here is where you brag about what your project can do.

Consider including a YouTube demo.

Theory of Operation

Give a high level overview of the structure of your software. Are you using GStreamer? Show a diagram of the pipeline. Are you running multiple tasks? Show what they do and how they interact.

Work Breakdown

1. We've already successfully using JavaScript read and write data to the linux gpio file.

fs.writeFileSync("/sys/class/leds/beagleboard::usr0/trigger", "heartbeat");
fs.writeFileSync("/sys/class/gpio/export", ""+5);

2. Even though we can access to the gpio in the above way, we still need to find someway to access to the I2C information. In the I2C exercises, in the C code provided in exercise 5, we still need to find some way in our javaScript instead of using i2c_smbus_write_byte() and i2c_smbus_read_byte(). Now there are two options for us:

a) To translate tons of the C codes into JavaScript...

b) Try to run the ./myi2c excutable file inside script...

  • It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this...
  • At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:
var exec  = require('child_process').exec,
    child;
child = exec('./myi2c',
  function (error, stdout, stderr) {
    console.log('stdout:', stdout);
    console.log('stderr:', stderr);
    if (error !== null) {
      console.log('exec error:', error);
    }
});

And the terminal will show the temperature.

3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!

  • I've successfully done it!!! The pics are already uploaded to the github. Check the following code:
var fs = require("fs");
var http = require("http");

try {
	http.createServer(function(request, response) {

		response.writeHead(200, {"Content-Type": "text/plain"});
		var exec = require('child_process').exec, child;
		child = exec('./myi2c',
	    		function (error, stdout, stderr) {
				response.write(stdout);
				console.log('stdout:', stdout);
				console.log('stderr:', stderr);
				response.end();
				if(error != null) {
					console.log('exec error:', error);
				}
			}
		);
	}).listen(8888);
} catch(ex3) {
	console.log("sb");
}

4. The next thing we will do is to refresh the website every other time...

  • We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts.
  • Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes.

Conclusions

Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.