Installation and use of the python (hive) client

Python client download

The python client is implemented as a set of python classes that deal with the connection to the DataNetwork. Additionally, there is a special client implemented to talk to the wireless network of MiniBees, consisting of another set of classes that deal with the serial communication to the MiniBees via the coordinator node, the configuration of the MiniBees and connecting all of this to the DataNetwork client.

In the download package you’ll find:

  • – the python datanetwork client
  • – the python MiniBee management – serial communication component
  • – implementing reading and writing the minibee configurations as an XML file
  • – gluing and together to a Python “hive” client to the DataNetwork. This is the program you will use to hook up your MiniBees to the DataNetwork.
  • – a simple program to communicate to the MiniBee network with a simple OSC interface (sends the data from the minibees to one IP/port via OSC; not using the DataNetwork).
  • – simple example of a python program that just receives the data from the MiniBees and writes it to a tab separated file.


Dependencies are:

On some operating systems python will already be installed, before you go on, check whether you have the right version:

check which version you have:
$ python --version
If it is lower than 2.6 you will need to get a version higher than 2.6.

Install the dependencies:

pyOSC :

$ cd pyosc
$ sudo ./ install

Follow the instructions at:

Pydon itself does not have an installation script yet, so for now just run the python scripts from with the directory of the package.


To use the Python hive client, you go to the directory “hive” within the package:

$ cd hive

To start the script:

$ python

this will print the help:

Usage: [options]

Create a datanetwork client to communicate with the minibee network.

-h, –help show this help message and exit
-p PORT, –port=PORT the port on which the client will listen
-n NAME, –name=NAME the name of the client in the datanetwork
-c CONFIG, –config=CONFIG
the name of the configuration file for the minibees
-m MINIBEES, –nr_of_minibees=MINIBEES
the number of minibees in the network [default:10]
-d HOST, –host_ip=HOST
the ip address of the datanetwork host
-s SERIAL, –serial=SERIAL
the serial port [default:/dev/ttyUSB0]

To start it you would do for example:

$ python -c example_hiveconfig.xml -s /dev/ttyUSB0

/dev/ttyUSB0 is the address of your serial port, it will be different on a mac (something like: /dev/tty-ASSFADF0002332).

If the DataNetwork host is running on another machine:
$ python -c nameofconfigfile.xml -d
where is the IP address of the computer running the DataNetwork.
You can see the actual IP address of the DataNetwork in the DataNetwork GUI.


The config file is an xml file.

The top level structure is:

<hive name="myprojectname">


Then there are elements for each MiniBee you have:

<minibee id="1" revision="B" serial="13A200403BF27B" libversion="3" caps="7">
<config id="1" name="accelero" />

So the ID, the revision of the board, the serial number of its XBee (see back side of XBee, a serial number listed there as: “0013A200406A697E”, should read “13A200406A697E” in the configuration file, so dropping the leading zeros), the library version and the capabilities are defined. The elements you want to change are the id, and the serial number.

Then you define the config that is used by this minibee by a number, which refers to a configuration element.
Several MiniBees can be defined that have the same configuration, e.g. minibees 1, 2 and 3 have configuration no. 1, minibees 4 and 5 have configuration no. 2.

An example of a configuration element:

<configuration id="2" name="accelero" message_interval="50" samples_per_message="1">
<pin config="AnalogIn" id="A0" />
<pin config="TWIData" id="A4" />
<pin config="TWIClock" id="A5" />
<twi id="1" device="ADXL345" />
<twi id="2" device="TMP102" />
<twi id="3" device="BMP085" />

So top level:

ID and label
Message interval in milliseconds
Samples per message (should be 1 for now)

If this is higher than 1, the MiniBee will make measurements as often as you set the number to,
and then send a package with all the data once every each message interval has passed. The time in between is divided up.
(NOTE: I haven’t built in the timed playback of these messages yet, in the python version).

Then for each pin:
id and configuration. Pins that are not mentioned are not configured.

Possible pin configurations (use these exact names):

DigitalIn — digital input (any pin but A4, A5)
DigitalOut — digital output on/off (any pin but A4, A5)
AnalogIn — analog input (for pin A0, A1, A2, A3, A6, A7)
AnalogIn10bit — analog input with 10bit result (for pin A0, A1, A2, A3, A6, A7)
AnalogOut — PWM or analog out (pins D3, D5, D6, D9, D10, D11)
Ping — Ultrasonic sensor (any pin but A4, A5)
SHTClock — Clock signal for SHT15 sensor (temperature/humidity) (any pin but A4, A5)
SHTData — Data signal for SHT15 sensor (temperature/humidity) (any pin but A4, A5)
TWIClock — Use a TWI/I2C sensor, clock signal (pin A5)
TWIData — Use a TWI/I2C sensor, data signal (pin A4)

And if TWI is used:
the devices which are used.

Currently supported are ADXL345, LIS302DL, TMP102, and BMP085.

Example configurations are given in the xml files you find in the hive folder of the package.

Further documentation is found in the HOWTO, README and GETTING_STARTED files in the package.


Comments are closed.