Most systems have two different parts: the user interface and the 'engine'.

The user interface:

The user interface is - as the name indicates - the part of the system where the user interacts with the system. This involves giving the system commands to do whatever you want it to do, at get the result in a way that can be seen by the user.

We often want the user interface to be smart and good looking. Graphic presentation is often preferred over stupid figures. A web application is a good way to accomplished this, and at the same time makes the interface available on several different platforms.

The 'engine':

The engine is the interface to the electronic world.  It could be logic to read temperatures, control relays, manage time, access data and so on.

The engine must be able to handle hardware and data of any kind in an efficient way.

The combination:

The user interface and the engine must have a way to communicate with each other. As the communication between the user interface and the engine is limited by the user’s ability to interact with the user interface, this communication does not have to be very fast, but preferable standardized in order to have flexibility to access the system from several platforms.

I all my systems, the standard modules consist of the following:

  1. The engine is based on Node.js, because there are so many modules available to interface with all types of hardware and data. The JavaScript-like programming is well known and far more productive than C or C++.
  2. The transport mechanism to the user interface is a web-server, which is part of the Node.js engine. I take very few lines of code to establish the web server in Node.js.
  3. The user interface is designed as web-pages. In the past, any action on a web-page would result in sending a new web-page to the browser.  This resulted in flickering screens and much data to be send back and forth. Therefore my user interfaces usually consist of only one web-page. This one web-page handles all changing of pages internally. Only changed data are transmitted to the web interface or send to the server. To improve the visible part and ease the programming of the user interface, I use jQuery, JavaScript and html.
  4. To handle the transmission of these data I use Socket.io. An interface available for both Node.js and html pages (java script);

That is all. To get access to an application, I open a browser window and write the URL of the application like http://my_rasberry_pi:86 where 86 is the port assigned to the applications web-server.

Updating the port forwarding in the router makes the application available from the outside world. Useful if you want the use a home automation application.

So - what do you need to do?

  1. Install Node.js
    1. install node.js
    2. install forever
    3. install socket.io
    4. Install web server for node.
  2. write your node app
  3. write your web-page
  4. you are done!

You can download a scelleton template of an application here (including web-page)

If you want to start the system when the Pi is started, you need to do a few more thing.

What is next?

Go ahead. Find your project and start coding.

Some of my projects are: