Cubietruck Cubieboard3 as domotica controller webserver

Forum about Questions, discussions and announcements regarding the Bwired website owned by Pieter Knuvers
Post Reply
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Cubietruck Cubieboard3 as domotica controller webserver

Post by Bwired »

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 18148 times
cubie2.jpg
cubie2.jpg (86.1 KiB) Viewed 18148 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 18148 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
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Cubietruck Cubieboard3 as domotica controller webserver

Post by Digit »

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...
vanisher

Re: Cubietruck Cubieboard3 as domotica controller webserver

Post by vanisher »

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?
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Re: Cubietruck Cubieboard3 as domotica controller webserver

Post by Bwired »

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
sneevlietcj
Starting Member
Starting Member
Posts: 1
Joined: Fri Mar 07, 2014 3:20 pm

Re: Cubietruck Cubieboard3 as domotica controller webserver

Post by sneevlietcj »

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.
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Re: Cubietruck Cubieboard3 as domotica controller webserver

Post by Bwired »

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
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Cubietruck Cubieboard3 as domotica controller webserver

Post by Digit »

When installed check the version, I believe it was rather old.
So I compiled it from source.
Post Reply

Return to “Bwired Forum”