Research

Boattr – what is it?

A hardware/software research project into the management of off-grid, autonomous sites. It collects and processes data from enviromental sensors and provides remote monitoring, control and automation.

Optionally it can also provide a host of other peripheral services that can run on the small embedded computer (wireless AP, internet connectivity, vpn remote access, tor gateway, file storage etc)

why was it made?

Since living off-grid Anton realised that he was lacking good information about the energy consumption and production, battery health and the various other subsystems of the boat.

One part of the project is about being able to better understand how those systems work by collecting, analysing and visualising their data.

The other interesting aspect is using realtime information from the sensors as well as historical data to make clever decisions and respond to external changes.

It seems that there was no free software based solution to fit my needs so Anton decided to Do It.

collecting data

At this point boattr has current, voltage, temperature and water pressure sensors. Data is collected from the sensors and stored in a db every minute. We can create real time graphs as well as mine the database for other historical data.

The heart of the system is a beaglebone black ARM embedded computer running Debian. Most of the sensors are analog and connected via a 10 channel ADC => I2c IC.

The temperature sensors are using the 1wire interface and one can read more details about the 1wire setup

Current sensing using the bidarectional allegro acs714 hall effect sensors using the breakout board from pololu

Voltage using a simple voltage divider

the software

The software part of boattr is made of a ruby module with two classes, Sensors and Data and the puppet provisioning code. The Sensors class contains all the functionality to obtain the results from the the various different sensors connected to the system.Data is responsible for processing resulting data, saving and sending to other places.

Here is an example of a box called ‘brain01’ on the boat retrieving data from the sensors, sending them to the database and real time graphs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#/root/boattr/boat.rb
require '/root/boattr/sensors.rb'
hostname = Socket.gethostname
p hostname

brain01 = {
  'description' => 'analog/i2c from brain01',
  'basename'    => 'boat',
  'i2cAddress'  => 0x28,
  'i2cBus'      => '/dev/i2c-1',
  'couchdb'     => 'localhost',
  'dashboard'   => 'localhost',
  'graphite'   => '10.70.60.1',
}

sensors=Boattr::Sensors.new(brain01)

brain01_sensors =
  [ sensors.current('solar',0),
    sensors.current('generator',1),
    sensors.current('lights',2),
    sensors.current('pumps',3),
    sensors.current('ring',4),
    sensors.current('fridge',5),
    sensors.voltage('batteries',6),
    sensors.waterlevel('tank',7),
    sensors.temperature('out','10-000802964c0d'),
    sensors.temperature('in','10-0008029674ee'),
    sensors.temperature('cylinder','10-000802961f0d'),
    sensors.temperature('stove','10-00080296978d'),
    sensors.temperature('canal','28-000004ee99a8'),
]


Boattr::Data.new(brain01).to_db(brain01_sensors)
Boattr::Data.new(brain01).to_graphite(brain01_sensors)

A cron job will run the above code every minute saving json formatted documents on an instance of couchdb as well as real time graphs using graphite.

Puppet is used to configure the system, install packages, configuration files and cronjobs:

node definition for a box called brain02 linenos:false
1
2
3
4
5
6
7
8
9
10
11
12
13
node brain02  {
  $subnet     = '192.168.8'
  $domain     = 'camp'
  $ip         = "${subnet}.99"
  $br_iface   = 'br0'
  $wifi_iface = 'wlan0'
  $ssid      = $::hostname

  class { 'dnsmasq':  subnet => $subnet, interface => $interface }
  class { 'network::ap' :  ssid => $ssid, wifi_iface => $wifi_iface }
  class { 'network::interfaces' :  }
  class { 'couchdb': }
}

The graphs look like this:

dashing is in the works.

The code is available on github

#boattr Some sort of project to manage off-grid systems

#provisioning

At the moment we need a BeagleBone Black (BBB) with debian. Recent revisions (the ones with 4GB eMMC ) come with debian as default. If you have an older one you will have to install it yourself.

Connect to the BBB with ssh. We assume You have debian wheezy already installed. For the following steps you have to be root. Make sure there is internet connectivity as well.

##change the hostname replace name in /etc/hostname and /etc/hosts. A restart is required after this step or before running puppet below.

##Install puppet git and librarian

apt-get update
apt-get install puppet git librarian-puppet

##clone the repo

cd /root/
git clone git://github.com/galp/boattr.git
cd boattr

##Install the required puppet modules with librarian

librarian-puppet install

##customise puppet

Have a look in provision/default.pp. You can either modify the ‘default’ node definition in this file or copy one of the blocks that looks more suitable to a different file called $HOSTNAME.pp in the same directory. Change the node name in the file along with anything else required. Make sure the fully quilified dns names much.

##run puppet to provision all the components

Run puppet like below pointing to the right file.

puppet apply --modulepath="/root/boattr/provision/modules/:/etc/puppet/modules/"  --hiera_config="/root/boattr/hiera/hiera.yaml" --verbose  provision/default.pp

It might take a few runs until all dependencies are resolved and you should have all the components installed.

boattr setup

config file

Boattr in this context is the ruby program that runs every minute collecting data from sensors, analyzing and sending to db and dashboard among other things.

There is a configuration file that we need to edit. This file is located at /root/boattr/config.yml. By default it does not exists so we can use the config_sample.yml as a starting point.

cp /root/boattr/config_sample.yml /root/boattr/config.yml

Standard