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'
      }
    }
  }
}

More Information

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 details)

Uploaded Source

File details

Details for the file robophery-0.2.tar.gz.

File metadata

  • Download URL: robophery-0.2.tar.gz
  • Upload date:
  • Size: 71.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for robophery-0.2.tar.gz
Algorithm Hash digest
SHA256 8c1a83468ce4b974c9cefa3332453ca6a63af8be031b6f7b650fc3175a1ad0da
MD5 a361038ed4e4aad51979016bbcf405b6
BLAKE2b-256 97b057f9f33849462bbe89251cda2b4093ab6b9eac1f8bc5f04b9be595188141

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page