I just wanted to share my simple RS485 controller. This repo contains the following parts:
Folder | Description |
---|---|
BoardCommunication | A python script the creates a simple REST-based interface with json responses |
RaspiGPIO | A python script that integrates commands via GPIO-Pins (relays on BoardCommunication script) |
Webfrontend | A very simple webfrontend (relays on BoardCommunication script) |
Prerequisite: Python3.x installed
# create virtual env
python3 -m venv venv
# activate
source venv/bin/activate
# run server
cd BoardCommunication
python restApi.py
Server listens now on
0.0.0.0:8080
Prerequisite: Python3.x installed
On systems with systemd installed the instal.sh
script can be used to install the communication server as a service.
chmod +x install.sh
./install.sh
# start on boot
sudo systemctl enable rs485
# control
service rs485 start|stop|status
Example request to switch on channel 2
127.0.0.1:8080/on/2/{password}
Returns:
{'channel':2, 'result':'ok','msg':1} #success
{'channel':2, 'result':'fail','msg':'error_message'} #failure
For specific the configurations please refer the comments in the scripts
- 8CH 12V Modbus RTU RS485 Relay (ebay-Link)
- RaspberryPI Model 3 with debian
- USB - RS485 Konverter (ebay-Link)
These scripts are not secure! I highly recommend to use them only controlled environments. This is especially true for the web-interface.
MIT