robogaia.com
  • Products
    • 3 Axis Encoder Conter Arduino Shield
    • 6 Channel Encoder Counter Arduino Shield
    • 8 Channel Encoder Counter Arduino Shield
    • Raspberry Pi 6 Channel Encoder Hat
    • Raspberry Temperature Controller Plate
    • 4 Relays Raspberry Pi Plate/Shield
    • C2N-UNI8IO To Terminal Block Board
    • Arduino Solid State Relay
    • Encoder Shield Connector
    • Mechanical Encoder Board with Connector
    • Raspberry Pi Dual Thermocouple Plate
    • Raspberry Pi 3 Channel Encoder Hat
    • HC-SR04 Ultrasonic Distance Sensor
  • Blog
  • Contact
  • Tutorials
    • How to Add a Web Interface to the Raspberry Pi 4 Relay Board
    • How to add a simple web server on Raspberry Pi with Flask Framework
    • How To Calculate Resistor Wattage
    • How To Start With Robotics
    • How To Start With Artificial Intelligence
    • How to start with CNC 6040 machine
    • How to calibrate Robogaia accelerometer/gyro shield
    • How to build Balancino (the balancing robot)
  • Distributors
  • Services
  • About

How to Add a Web Interface to the Raspberry Pi 4 Relay Board

Picture
    Sometimes is very handy to control your project from a browser
from a different location.

This little app is wtitten in Python language and it uses the Flask framework to get access to relays from the web page.




The actual board and the relay scripts are here.
Before you start follow the tutorial for installing the Flask framework here.





Usage

Download the robogaia_4_relays_web_interface.tar.gz file on the Raspberry Pi board. The file is on the bottom of the page.


From terminal type



wget http://www.weebly.com/uploads/6/8/0/9/6809982/robogaia_4_relays_web_interface.tar.gz
tar -xzvf  robogaia_4_relays_web_interface.tar.gz
cd robogaia_4_relays_web_interface

Make sure the relays are initialized:
sudo relays_init

The last command will start the web server and the web page is available .

python relay_web_interface.py

From the browser (Firefox,Chrome, Internet  Explorer) type the Raspberry Pi  IP address and the port number  (the Flask will start by default at port 5000)

The IP address should look something like :
http://192.168.0.14:5000

Here is how the web page looks like . Every relay has 2 buttons ( ON and OFF) .
By pressing one of them the relay will close or open.


Picture
robogaia_4_relays_web_interface.tar.gz
File Size: 1 kb
File Type: gz
Download File

@Robogaia 2021