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:

  • pydon.py – the python datanetwork client
  • pydonhive.py – the python MiniBee management – serial communication component
  • minibeexml.py – implementing reading and writing the minibee configurations as an XML file
  • swpydonhive.py – gluing pydon.py and pydonhive.py together to a Python “hive” client to the DataNetwork. This is the program you will use to hook up your MiniBees to the DataNetwork.
  • minihiveosc.py – 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).
  • hivelogger.py – simple example of a python program that just receives the data from the MiniBees and writes it to a tab separated file.

INSTALLATION

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 ./setup.py install

pyserial:
Follow the instructions at:
http://pyserial.sourceforge.net/pyserial.html#installation

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

USAGE

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


$ cd hive

To start the script:

$ python swpydonhive.py

this will print the help:


Usage: swpydonhive.py [options]

Create a datanetwork client to communicate with the minibee network.

Options:
-h, –help show this help message and exit
-p PORT, –port=PORT the port on which the client will listen
[default:57600]
-n NAME, –name=NAME the name of the client in the datanetwork
[default:pydonhive]
-c CONFIG, –config=CONFIG
the name of the configuration file for the minibees
[default:hiveconfig.xml]
-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
[default:127.0.0.1]
-s SERIAL, –serial=SERIAL
the serial port [default:/dev/ttyUSB0]

To start it you would do for example:


$ python swpydonhive.py -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 swpydonhive.py -c nameofconfigfile.xml -d 192.168.0.7
where 192.168.0.7 is the IP address of the computer running the DataNetwork.
You can see the actual IP address of the DataNetwork in the DataNetwork GUI.

CREATING THE CONFIG FILE:

The config file is an xml file.

The top level structure is:

<xml>
<hive name="myprojectname">

</hive>
</xml>

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" />
</minibee>

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" />
</configuration>

So top level:

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

—————
NOT YET IMPLEMENTED:
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/Questions

Comments are closed.