Cubietruck Cubieboard3 as domotica controller webserver

Forum about Questions, discussions and announcements regarding the Bwired website owned by Pieter Knuvers

Cubietruck Cubieboard3 as domotica controller webserver

Postby Bwired » Tue Dec 10, 2013 10:59 pm

After experimenting with the Raspberry PI and all the possibilities it was about about time to start converting my existing Home automation software from Windows (VB) to Linux.
I'm a Windows guy for many many years so adjusting to Linux took me some time :) With the help of guys like Digit and Rene, who were trying to convince me for along time, i got the hang of it.
The Rasp was not sufficient for me, so we found a better solution to handle our stuff.
We decided to go for the CubieTruck Cubieboard3 http://cubieboard.org/tag/cubietruck/ which for now is only supplied by http://embeddedcomputer.nl/cubietruck-cubieboard3.html in the Netherlands (btw: http://embeddedcomputer.nl have a lot of other nice boards)
The big advantage of the Cubie against the Rasp is that its much faster and the SATA connector, this options makes it an independent Domotica controller / webserver.

I installed Ubuntu server and move it from the Nand memory to the sata drive (boot)

Here you can see a youtube how this works


I installed the very powerfull Node-js, socket IO and mqtt, so the software is running under node-js which is easy to write as its javascript!

cubie1.jpg
cubie1.jpg (85.56 KiB) Viewed 12678 times

cubie2.jpg
cubie2.jpg (86.1 KiB) Viewed 12678 times


Example: Getting the status of my Roomba via RooWifi was easy to do, see below the json status coming in.
with the help of node mysql https://github.com/felixge/node-mysql its easy to log everything in a MySql Database which is also running smooth and fast on the Cubie

roombjs.jpg
roombjs.jpg (180.6 KiB) Viewed 12678 times

Im now planning to shift all my device interfaces, controlling software and dbase logging to Linux:
Xanura A10
Nemef Radaris RFID doorcontrollers
Smartmeter
RFXcom
Roomba
ETH484
Mobotix Camera's
Poseidon Controllers
MAX
Visonic
LED contollers
Plugwise
Davis Vantage PRO2
AXIS 241Q
Opentherm Gateway
Solar cells Solar-log
GSM Modem
fritzbox for call indentifcation
Philips Hue
No break controllers
Btraced Track & Trace server (http://www.btraced.com)
Electric curtains


my next board will probably be this one, more faster and a better casing which is needed for this important job :)
http://utilite-computer.com/web/home
User avatar
Bwired
Administrator
Administrator
 
Posts: 5308
Joined: March 2006
Location: Netherlands

Re: Cubietruck Cubieboard3 as domotica controller webserver

Postby Digit » Wed Dec 11, 2013 1:54 am

Welcome to the club, a lot of work to do for you this winter Pieter! :)
OTOH... it may look like a lot of work, but I started in June this year and right now ~90% of the work has been done, so don't worry about it :wink:
If all goes well I can shut down my 'old' system around March 2014...
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Re: Cubietruck Cubieboard3 as domotica controller webserver

Postby vanisher » Wed Dec 11, 2013 8:29 am

Nice project.. I'm curious how to start such a project. About one century ago i did some programming in Delphi , Pascal en C++.

How do you create a GUI , webbased? compatible with tablet and or smartphone?
-------------------------------------------------------------------
A Domotica starter, currently running: Plugwise, Z-Wave, Jeenods, Homeseer / DomotiGa
vanisher
Member
Member
 
Posts: 293
Joined: June 2011

Re: Cubietruck Cubieboard3 as domotica controller webserver

Postby Bwired » Wed Dec 11, 2013 1:27 pm

Well believe me if you did this kind of programming you can handle this
Javascript is very easy to learn and understand, but also very powerfull
And all controlling can be done web based with websockets which mean that now refreshing of the screen is needed and very fast refreshing (this not Ajax!)
Using web to controle your domotica is the only way to go forward I think, you can also use any device for it.
Lots of node-js examples can be found on the internet.

See below an example script which receives a Json string from the Roomba and stores it immediately in a Mysql database which is also running on the Cubietruck.
This is the only script needed for this! you can run it automatic when the Cubie is rebooted and even monitor it with Monit service manager.
With Node-Inspector you can debug everything via standard Google Chrome F12 function.

Code: Select all
// Load the TCP Library
net = require('net');

// Keep track of the clients
var clients = [];

// Start a TCP Server
net.createServer(function (socket) {

  // Identify this client
  socket.name = socket.remoteAddress + ":" + socket.remotePort

  // Put this new client in the list
  clients.push(socket);

  // Send a nice welcome message and announce
   
  broadcast(socket.name + " joined the server\n", socket);

  // Handle incoming messages from clients.
  socket.on('data', function (data) {
    broadcast(socket.name + "> " + data, socket);
   var objRoomba = JSON.parse(data);
   Mysqllog(objRoomba)
});

  // Remove the client from the list when it leaves
  socket.on('end', function () {
    clients.splice(clients.indexOf(socket), 1);
    broadcast("\n" + socket.name + " left the server.\n");
  });
 
  // Send a message to all clients
  function broadcast(message, sender) {
    process.stdout.write(message)
  }

//  MySql logging
function Mysqllog(p){

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'xxxx',
  password : 'xxxx',
  database : 'domobase'
});

connection.connect();
  var myDate = new Date();
  connection.query('INSERT INTO roomba SET ?', {datum : myDate, status: p.ROOMBA.status, cleaning: p.ROOMBA.cleaning, battery: p.ROOMBA.battery, temp: p.ROOMBA.temp, roomba_error: p.ROOMBA.error, button: p.ROOMBA.button}, function(err, result) {
 
if (err) throw err;
  console.log(result.insertId);
});
connection.end();
}

}).listen(8001);

// Put a friendly message on the terminal of the server.
console.log("Tcp Listener server running at port 8001\n");
http://www.bwired.nl Online Home, Domotica, Home Automation. Weblog. http://blog.bwired.nl
User avatar
Bwired
Administrator
Administrator
 
Posts: 5308
Joined: March 2006
Location: Netherlands

Re: Cubietruck Cubieboard3 as domotica controller webserver

Postby sneevlietcj » Fri Mar 07, 2014 2:28 pm

I have also been using Raspberry PI's as MQTT brooker, now have decided to upgrade to a Cubietruck.
Done the lubuntu server install same way as in the youtube video, but now having a hard time geting the MQTT to install.
Tried the steps Bwired described but having an issue with the apt-add-reposititory, is there anything that I have been missing?

Running Linaro 13.08 on the cubietruck.
sneevlietcj
Starting Member
Starting Member
 
Posts: 1
Joined: March 2014

Re: Cubietruck Cubieboard3 as domotica controller webserver

Postby Bwired » Fri Mar 07, 2014 4:13 pm

did you check this http://mosquitto.org/download/

Ubuntu

As of version 11.10 Oneiric Ocelot, mosquitto will be in the Ubuntu repositories so you can install as with any other package. If you are on an earlier version of Ubuntu or want a more recent version of mosquitto, add the mosquitto-dev PPA to your repositories list – see the link for details. mosquitto can then be installed from your package manager.

sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
If the command “apt-add-repository” is not recognised, it can be installed with:

sudo apt-get install python-software-properties
User avatar
Bwired
Administrator
Administrator
 
Posts: 5308
Joined: March 2006
Location: Netherlands

Re: Cubietruck Cubieboard3 as domotica controller webserver

Postby Digit » Fri Mar 07, 2014 6:48 pm

When installed check the version, I believe it was rather old.
So I compiled it from source.
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands


Return to Bwired Forum

Who is online

Users browsing this forum: No registered users and 1 guest