Table of Contents

RaspberryPi

System setup

Official web site of the RaspberryPi project http://www.raspberrypi.org/

Download Raspian image and write it to SD card according to instructions. Minimum SD card size is 2 GB, but the bigger the better. At first boot lets you configure the system and expand the file system to accommodate the whole disk.

At command prompt, one can start the configurator by:

sudo raspi-config

These instructions are created according to raspbian-wheezy-2013-07-26.

HA Software

Node.js

Installation instructions: http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/. Notice, the instruction is referring to version 0.10.2. Check for the latest one. I did installed 0.10.22.

Notice also this: When you want to use ‘npm’ or ‘node’ as root with sudo you have to add the ‘-i’ option, so that the root user’s environment is acquired. For example when you want to install the package ‘forever’ globally with ‘npm’.

sudo -i npm install forever -g

Modbus

Dependencies

sudo apt-get install build-essential autoreconf

Node.js module

npm install modbus

Database

MongoDB

At the moment, MongoDB is not available as an rpm package for Raspbian. Here are instructions how to build it locally. In my system, the build process took more than 12 hours altogether. It may be convenient to run the shell in screen. Notice that 8GB or bigger memory card is needed.

sudo apt-get install git-core build-essential scons libpcre++-dev xulrunner-dev libboost-dev libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev
git clone git://github.com/RickP/mongopi.git
cd mongopi
scons --release
sudo scons install
sudo scons -c

The last command is the clean up build and free some 0,5 GB of flash disk. Then create data directory /data/db and start mongo:

mongod

Cube

Cube is a Node.JS program. In Debian, Node.JS binary is named as nodejs, whereas many scripts expect node. A symbolic solves this problem.

sudo apt-get install nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node

Instructions

git clone https://github.com/square/cube.git
cd cube
sudo apt-get install npm
npm install

1-wire support

Install following packages: owfs owhttpd owserver

sudo apt-get install owfs owfs-fuse owhttpd owserver

Edit /etc/owfs.conf

! server: server = localhost:4304
server: usb = all
mountpoint = /mnt/1wire
allow_other
http: port = 2121
ftp: port = 2120

In order to have 1-wire sensors available in file system, create mount point directory /mnt/1wire and add following row at the end of d_start section in /etc/init.d/owserver to have the file system mounted at boot.

/usr/bin/owfs -C -uall -m /mnt/1wire --allow_other

Install package: rrdtool. A simple command line script example owread.sh how to read 1-wire readings to RRD database #!/bin/bash # # Store 1-wire temperature sensor readings into RRD database. # This script is expected to be executed by crond once a minute. # # Jaakko Ala-Paavola # 2013-01-13 SENSOR[0]=10.351B2A020800 SENSOR[1]=10.84082A020800 OWPATH=/mnt/1wire RRD=temperature.rrd TMP=/run BACKUP=/opt/HA # If volatile RRD Database does not exists, then use backup copy # If backup copy does not exists, then create a new database if [ ! -f $TMP/$RRD ] then if [ -f $BACKUP/$RRD ] then cp $BACKUP/$RRD $TMP/$RRD else /usr/bin/rrdtool create $TMP/$RRD –step 60 \ DS:temp1:GAUGE:300:-50:120 \ DS:temp2:GAUGE:300:-50:120 \ RRA:AVERAGE:0.5:1:1440 \ RRA:AVERAGE:0.5:10:1008 \ RRA:AVERAGE:0.5:60:720 \ RRA:MIN:0.5:1440:365 \ RRA:MAX:0.5:1440:365 \ RRA:AVERAGE:0.5:1440:365 fi /bin/chmod a+rw $TMP/$RRD fi # Collect 1wire data and update RRD database # If sensor does not exists, replace the value with U as Unknown. for sensor in ${SENSOR[@]}; do DATA+=“:” if [ -f $OWPATH/$sensor/temperature ] then DATA+=`cat $OWPATH/$sensor/temperature | sed -e 's/^[ \t]*'` else DATA+=“U” fi done /usr/bin/rrdtool update $TMP/$RRD N$DATA exit 0 Make the crond to run the above script owread.sh once a minute and make backup copy of the database once an hour. Edit crond configuration with command sudo crontab -e 0 * * * * cp /run/temperature.rrd /opt/HA/temperature.rrd * * * * * /opt/HA/owread.sh</del>

raspberrypi.txt · Last modified: 2014/01/12 22:39 by jap
Recent changes RSS feed CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki