This package provides additional suite of python based rpi abstraction for handling rpi hardware and data control. The package currently includes an abstraction layer and API engine for the RPi.GPIO package for python, which allows for multi-process and non-blocking control of GPIO pins. The package also includes a module for handling usb mass storage device mounting, data dumping, and unmounting,and other data handling. Finally the Package also includes a module for common sensors.
This package provides an abstraction layer and API engine for the [RPi.GPIO](https://pypi.org/project/RPi.GPIO/) package for python, which allows for multi-process and **non-blocking** control of GPIO pins.
With this package you can start the GPIO Engine, and control the output pins for relay control/ actuation using a json configuration files, while your code performs other
operations. This allows for relative __real time control<sup>*</sup>__ of the GPIO pins(~<1s scale). This package also provides real-time api of the status for external logging or
communication.Using the JSON protocol for the api we can allow for user control and information logging. For now this package only handles GPIO output but will feature
input control in the near future.
___*Note:___ While this package provides multi-process control of the GPIO pins for near real-time control, jitter can vary considerably due to the nature of Linux OS and
python's garbage collection. For now refresh rate is by default set to 1 second to mitigate issue of jitter to a known scale, but we cannot guarantee performance if refresh rate is set to 0.
- Documentation: *Coming soon*
- [Github](https://github.com/moha7108/RPi_control_center)
## Installation
- pip
```shell
pip install RPI-control-center
```
- source
```shell
git clone https://gitlab.com/moha7108/rpi-control-center.git
cd rpi-control-center
pip install -r requirements.txt
```
## Example Usage
### Control Scripts
#### Controlling relays
```python
import time
from rpi_control_center import controls
relay_config = {
"relay1":{'pin':26, 'state':False, 'config':'no'},
"relay2":{'pin':20, 'state':False, 'config':'no'},
"relay3":{'pin':21, 'state':False, 'config':'no'},
}
relay_group1 = controls.relay_engine( relay_config=relay_config,
label='test_relays',
api_dir='./api/',
log_dir='./log/',
refresh_rate=1)
relay_group1.start()
######### You can put any code because this function is non-blocking
try:
while True:
time.sleep(5)
relay_group1.set_relay_state('relay1',True)
time.sleep(5)
relay_group1.set_relay_state('relay2',True)
time.sleep(5)
relay_group1.set_relay_state('relay3',True)
time.sleep(5)
relay_group1.set_relay_state('relay1',False)
time.sleep(5)
relay_group1.set_relay_state('relay2',False)
time.sleep(5)
relay_group1.set_relay_state('relay3',False)
except:
relay_group1.stop()
```
#### USB Mass Storage Script
```python
import time, os
from rpi_control_center import rpi_usb
storage_devices = rpi_usb.get_devices(True)
print(storage_devices)
for dev in storage_devices:
dev('test.txt')
time.sleep(5)
os.system(f'sudo ls {dev.mnt}')
dev.umnt_usb()
os.system(f'sudo ls /mnt')
```
#### CSV Handling Script
```python
from rpi_control_center.data import csv_handler
test_data = {'hello': 13, 'poop':'34013'}
test_csv = csv_handler(filename='test_data')
test_csv(test_data)
print(test_csv.data_files)
print(test_csv.writing_to)
print(test_csv.total_size)
```
### Sensor Monitoring scripts
#### K30 CO2 Sensor (Serial)
```python
from rpi_sensor_monitors import monitors
co2_sensor = monitors.K30_CO2(serial_device = "/dev/ttyS0", baudrate=9600, label='k30_CO2', api_dir='./api/', log_dir='./log/', refresh_rate=1)
co2_sensor.start()
try:
while True:
time.sleep(5)
except:
co2_sensor.stop()
```
#### BME680 Sensor
```python
from rpi_sensor_monitors import monitors
env_sensor = monitors.BME680()
env_sensor.start()
time.sleep(60)
env_sensor.stop()
```
## Hardware and drivers
### List of Compatible Raspberry Pi boards
- [Raspberrypi 3B+](https://www.raspberrypi.org/products/raspberry-pi-3-model-b/)
- [Raspberrypi Zero 2W](https://www.raspberrypi.com/products/raspberry-pi-zero-2-w/)
### List of Compatible Sensors
- BM680 (DFRobot flavor)
- any Ultrasonic sensor
- K30 CO2 Sensor
## Feedback
All kinds of feedback and contributions are welcome.
- [Create an issue](https://github.com/moha7108/RPi_control_center/issues)
- Create a pull request
- Reach out to @moha7108
## Contributors
- Mohamed Debbagh
- [GitLab](https://gitlab.com/moha7108/), [Github](https://github.com/moha7108/), [Twitter](https://twitter.com/moha7108)
## Change Log
### 0.2.3
- Move relay controlling to controls module and simplify code
- K30 CO2 Sensor compatability
- add status indicators to api files
### 0.2.2
- add ultrasonic sensor monitor
- get sensor reading from object directly
- add am2420 sensor class
- add dual camera (VERY SPECIFIC USECASE)
- change package architecture to include control module
- add pwm to control module
### 0.2.1
- add data module with csv handler class to the rpi_control_center package
-
### 0.2.0
- addition of rpi_monitors module for sensor interfacing (currently only DFRobot_BME680)
- add dependancies (smbus, spidev)
### 0.1.3
- add rpi_usb module for usb mass storage handling
### 0.1.2
- fix minor error in test and example code
### 0.1.1
- Change host to github for better community issue tracking and documentation, functionally the same as previous version
- gitlab will be used as a mirror
### 0.1.0
- Logging via logzero, ability to suppress debug level logs when debug_mode is off
- create log and api folders when they do not exist
- all previous versions are pre release, this is the first working release
### Packaging Notes
- source venv/bin/activate
- python setup.py sdist bdist_wheel
- twine upload dist/* or twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Raw data
{
"_id": null,
"home_page": "https://github.com/moha7108/RPi_control_center",
"name": "RPI-control-center",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "Raspberry Pi,Raspi,Python,GPIO,USB,Mass storage,API,non-blocking",
"author": "Mohamed Debbagh",
"author_email": "moha7108@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/32/23/510401144578ac77388abe495d80b2235b30f4fe23d1d5112f1b49de1aab/RPI-control-center-0.2.3.2.tar.gz",
"platform": null,
"description": "This package provides additional suite of python based rpi abstraction for handling rpi hardware and data control. The package currently includes an abstraction layer and API engine for the RPi.GPIO package for python, which allows for multi-process and non-blocking control of GPIO pins. The package also includes a module for handling usb mass storage device mounting, data dumping, and unmounting,and other data handling. Finally the Package also includes a module for common sensors.\n\nThis package provides an abstraction layer and API engine for the [RPi.GPIO](https://pypi.org/project/RPi.GPIO/) package for python, which allows for multi-process and **non-blocking** control of GPIO pins.\nWith this package you can start the GPIO Engine, and control the output pins for relay control/ actuation using a json configuration files, while your code performs other\noperations. This allows for relative __real time control<sup>*</sup>__ of the GPIO pins(~<1s scale). This package also provides real-time api of the status for external logging or\ncommunication.Using the JSON protocol for the api we can allow for user control and information logging. For now this package only handles GPIO output but will feature\ninput control in the near future.\n\n\n\n___*Note:___ While this package provides multi-process control of the GPIO pins for near real-time control, jitter can vary considerably due to the nature of Linux OS and\npython's garbage collection. For now refresh rate is by default set to 1 second to mitigate issue of jitter to a known scale, but we cannot guarantee performance if refresh rate is set to 0.\n\n- Documentation: *Coming soon*\n- [Github](https://github.com/moha7108/RPi_control_center)\n\n## Installation\n\n- pip\n```shell\npip install RPI-control-center\n```\n- source\n```shell\ngit clone https://gitlab.com/moha7108/rpi-control-center.git\ncd rpi-control-center\npip install -r requirements.txt\n```\n\n## Example Usage\n### Control Scripts\n#### Controlling relays\n```python\nimport time\nfrom rpi_control_center import controls\n\nrelay_config = {\n \"relay1\":{'pin':26, 'state':False, 'config':'no'},\n \"relay2\":{'pin':20, 'state':False, 'config':'no'},\n \"relay3\":{'pin':21, 'state':False, 'config':'no'},\n}\n\nrelay_group1 = controls.relay_engine( relay_config=relay_config,\n label='test_relays', \n api_dir='./api/', \n log_dir='./log/',\n refresh_rate=1)\n\nrelay_group1.start()\n\n\n######### You can put any code because this function is non-blocking\ntry:\n while True:\n time.sleep(5)\n relay_group1.set_relay_state('relay1',True)\n time.sleep(5)\n relay_group1.set_relay_state('relay2',True)\n time.sleep(5)\n relay_group1.set_relay_state('relay3',True)\n time.sleep(5)\n relay_group1.set_relay_state('relay1',False)\n time.sleep(5)\n relay_group1.set_relay_state('relay2',False)\n time.sleep(5)\n relay_group1.set_relay_state('relay3',False)\nexcept:\n relay_group1.stop()\n```\n\n#### USB Mass Storage Script\n```python\nimport time, os\nfrom rpi_control_center import rpi_usb\n\nstorage_devices = rpi_usb.get_devices(True)\nprint(storage_devices)\n\nfor dev in storage_devices:\n dev('test.txt')\n time.sleep(5)\n os.system(f'sudo ls {dev.mnt}')\n dev.umnt_usb()\n os.system(f'sudo ls /mnt')\n```\n\n#### CSV Handling Script\n```python\nfrom rpi_control_center.data import csv_handler\n\ntest_data = {'hello': 13, 'poop':'34013'}\n\ntest_csv = csv_handler(filename='test_data')\ntest_csv(test_data)\n\nprint(test_csv.data_files)\nprint(test_csv.writing_to)\nprint(test_csv.total_size)\n```\n\n### Sensor Monitoring scripts\n\n#### K30 CO2 Sensor (Serial)\n```python\nfrom rpi_sensor_monitors import monitors\n\nco2_sensor = monitors.K30_CO2(serial_device = \"/dev/ttyS0\", baudrate=9600, label='k30_CO2', api_dir='./api/', log_dir='./log/', refresh_rate=1)\nco2_sensor.start()\n\ntry:\n while True:\n time.sleep(5)\nexcept:\n co2_sensor.stop()\n```\n#### BME680 Sensor\n```python\nfrom rpi_sensor_monitors import monitors\n\n\nenv_sensor = monitors.BME680()\nenv_sensor.start()\ntime.sleep(60)\nenv_sensor.stop()\n```\n\n## Hardware and drivers\n\n### List of Compatible Raspberry Pi boards\n- [Raspberrypi 3B+](https://www.raspberrypi.org/products/raspberry-pi-3-model-b/)\n- [Raspberrypi Zero 2W](https://www.raspberrypi.com/products/raspberry-pi-zero-2-w/)\n\n### List of Compatible Sensors\n\n- BM680 (DFRobot flavor)\n- any Ultrasonic sensor\n- K30 CO2 Sensor\n\n\n## Feedback\n\nAll kinds of feedback and contributions are welcome.\n\n- [Create an issue](https://github.com/moha7108/RPi_control_center/issues)\n- Create a pull request\n- Reach out to @moha7108\n\n## Contributors\n\n- Mohamed Debbagh\n - [GitLab](https://gitlab.com/moha7108/), [Github](https://github.com/moha7108/), [Twitter](https://twitter.com/moha7108)\n\n## Change Log\n### 0.2.3\n- Move relay controlling to controls module and simplify code\n- K30 CO2 Sensor compatability\n- add status indicators to api files\n\n### 0.2.2 \n- add ultrasonic sensor monitor\n - get sensor reading from object directly\n- add am2420 sensor class\n- add dual camera (VERY SPECIFIC USECASE)\n- change package architecture to include control module\n- add pwm to control module\n### 0.2.1\n- add data module with csv handler class to the rpi_control_center package\n-\n### 0.2.0\n- addition of rpi_monitors module for sensor interfacing (currently only DFRobot_BME680)\n- add dependancies (smbus, spidev)\n### 0.1.3\n- add rpi_usb module for usb mass storage handling\n### 0.1.2\n- fix minor error in test and example code\n### 0.1.1\n- Change host to github for better community issue tracking and documentation, functionally the same as previous version\n- gitlab will be used as a mirror\n### 0.1.0\n- Logging via logzero, ability to suppress debug level logs when debug_mode is off\n- create log and api folders when they do not exist\n- all previous versions are pre release, this is the first working release\n\n### Packaging Notes\n- source venv/bin/activate\n- python setup.py sdist bdist_wheel\n- twine upload dist/* or twine upload --repository-url https://test.pypi.org/legacy/ dist/*\n",
"bugtrack_url": null,
"license": "GNU GPLv3",
"summary": "This package provides additional suite of python based rpi abstraction for handling rpi hardware control.",
"version": "0.2.3.2",
"project_urls": {
"Bug Tracker": "https://github.com/moha7108/RPi_control_center/issues",
"Github": "https://github.com/moha7108/RPi_control_center",
"Homepage": "https://github.com/moha7108/RPi_control_center"
},
"split_keywords": [
"raspberry pi",
"raspi",
"python",
"gpio",
"usb",
"mass storage",
"api",
"non-blocking"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0ffdef114b6535b73166db94be32fda7a02e6ffb0490f9bed23969fe4029401c",
"md5": "5e0bdf1e908eb329846518488077b66d",
"sha256": "0e5e5de6f7279e1226f55aedc8649131c9993ecd9392561a73f5d76c72cc98ac"
},
"downloads": -1,
"filename": "RPI_control_center-0.2.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5e0bdf1e908eb329846518488077b66d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 44332,
"upload_time": "2024-03-14T23:07:29",
"upload_time_iso_8601": "2024-03-14T23:07:29.095462Z",
"url": "https://files.pythonhosted.org/packages/0f/fd/ef114b6535b73166db94be32fda7a02e6ffb0490f9bed23969fe4029401c/RPI_control_center-0.2.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3223510401144578ac77388abe495d80b2235b30f4fe23d1d5112f1b49de1aab",
"md5": "dfa905522507e539231c174f2dd6dda4",
"sha256": "c852e4ecff57d560882955df9a75815b7c476e87a47812535525f01b80c62e39"
},
"downloads": -1,
"filename": "RPI-control-center-0.2.3.2.tar.gz",
"has_sig": false,
"md5_digest": "dfa905522507e539231c174f2dd6dda4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 41579,
"upload_time": "2024-03-14T23:07:31",
"upload_time_iso_8601": "2024-03-14T23:07:31.597738Z",
"url": "https://files.pythonhosted.org/packages/32/23/510401144578ac77388abe495d80b2235b30f4fe23d1d5112f1b49de1aab/RPI-control-center-0.2.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-14 23:07:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "moha7108",
"github_project": "RPi_control_center",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "rpi-control-center"
}