Skip to main content

Python library for interfacing low level hardware sensors and actuators with MQTT bindings.

Project description

Documentation Status Join Chat on Gitter.im

Design and implementation of Python library for interfacing low level hardware sensors and actuators with MQTT and TSDB bindings. The system architecture is designed to be so simple at hardware level to support sigle-board microcontrollers like ESP2866, ESP32 modules as well as sigle-board computers based on ARM or x86 architectures. The communication among devices is handled by the standard MQTT message bus.

Installation

Virtualenv

Install required dependencies

apt-get install python-dev libyaml-dev git python-virtualenv

Prepare clean virtualenv

virtualenv /opt/robophery

Clone this repository

git clone https://github.com/cznewt/robophery.git

Install dependencies and robophery

source /opt/robophery/bin/activate
pip install -r requirements.txt
python setup.py install

Service

If you are running systemd-enabled distribution, setup systemd unit file to start robophery automatically:

cat << EOF >>/etc/systemd/system/robophery.service
[Unit]
Description=robophery manager
Wants=mosquitto.service
After=network.target mosquitto.service

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/robophery
Environment=ROBOPHERY_CONF=/etc/robophery
ExecStart=/opt/robophery/bin/rp_manager
RestartSec=5
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

Create /opt/robophery directory and config file /opt/robophery/robophery_conf.py and start the service.

systemctl daemon-reload
systemctl start robophery
systemctl enable robophery

To check status of a service, use systemctl status -l robophery. To see logs, you can use systemd journal (eg. journalctl -u robophery -f)

Configuration

You can use salt-formula-robophery to automate both installation and configuration or you can provide config file in any other way.

Example

Following example configuration will setup robophery running on Raspberry Pi and will collect data from DHT22 sensor attached to GPIO pin 3 and publish it to MQTT every 60 seconds.

CONF = {
  'name': 'mylittleraspberry',
  'log_level': 'debug',
  'log_handlers': ['console', 'syslog'],
  'read_interval': 10000,
  'publish_interval': 60000,
  'platform': 'raspberrypi',
  'config': {
    'comm': {
      'default_mqtt': {
        'host': 'mymqttserver',
        'port': 1883,
        'class': 'robophery.comm.linux.mqtt.PahoMqttComm'
      },
    },
    'interface': {
      'local_gpio': {
        'engine': 'gpio',
        'class': 'robophery.platform.rpi.gpio.RaspberryPiGpioInterface'
      }
    },
    'module': {
      'dht22': {
        'data': {
          'pin': 3,
        },
        'class': 'robophery.module.gpio.dht22.Dht22Module'
      }
    }
  }
}

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robophery-0.2.tar.gz (71.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page