Controlling RS485 relays from a web browser

Control RS485 Relays from a web browser

This project pulls together a number of different projects on this site to enable control of relays from a web browser via a raspberry pi and RS485 network.

For this project you will need the following

1. A Raspberry pi with Raspbian installed

2. An Isolated RS485/422 adapter

3. A number of RS485 relay boards in this project I use 2

The Hardware

Connect the Isolated RS485 adapter up to the raspberry pi and follow the instructions on that page to enable the onboard uart now connect the RS485 slaves to the isolated RS485 board via two wires and terminate the network at the furthest node.

The Software

Next we need to download and install Webiopi instructions can be found here

As the first step we need to change is the config file located at /etc/webiopi/config

sudo nano /etc/webiopi/config

Firstly we need to configure the serial port to 19.2 KBaud by changing it to this line


serial0 = Serial device:ttyAMA0 baudrate:19200

Copy and paste the file below into an editor and save it as Index.html and put this at the root location for webiopi. Or configure the line in the config file to point to the location.

Now reboot your raspberry pi for the changes to take effect and start webiopi by the command:

$ sudo /etc/init.d/webiopi start

Now open a browser and go to http://localhost:8000/ on the raspberry pi you should be asked for a username and password these are

username: webiopi

password: raspberry

You should see a web page like thisScreen%20Shot%202013-08-12%20at%2018_45_37

that enables you to control the relays.

To log in on another browser on your

network at http://raspberrypi:8000/

Replace raspberrypi with your IP address