Relay control via the Internet with Arduino

18/07/2020

The project for 2 cottages, which are controlled remotely, where each of the users (owners of each cottage) has their own site, where they manage their outputs, in the position of microcontroller was Arduino Due and Ethernet shield W5100, which has enough GPIO pins for 16 channels. relay. It was located in one cottage from which both operated. As not everyone has an Arduino Due, as it is from a different price category, the sample published Arduino codes for this are adapted for 2 Arduino Mega boards with Wiznet W5100 Ethernet shields, so that you can also try them out physically.

The web part for the project is written in PHP, it takes care of login management, changes in relay states, changes of names for relays and changes of login contacts. There are 2 user accounts, in each of which it is possible to control 8 outputs. One user cannot see the outputs of the other and cannot change them. At the same time, both users can be in the web application at the same time, and each of them can manage their outputs, they do not limit each other and they do not see their activity.

The demo I have prepared has the following login details with which it is possible to try out the web application:

1. user

    username: user1
    password: user1

2. user

    username: admin
    password: admin

The login details can be changed in the web part, each user changes them individually.

The pages consist of a login page and functional pages after login. If the user is not logged in, he will not be able to access the function pages, he will be automatically redirected to the login page.

Functional pages (behind the login) have the following tasks:

    Switching relay ON / OFF
    Change relays names
    Change of username and password for each user
    Arduino code right at the page
    Log off

Hardware characteristics:

There are 2 main types of relays used for the Arduino for this purpose. Electromagnetic relays, through which it is possible to switch a maximum of 230V 10A in the AC system, or 30V 10A in the DC system. This type of relay is also suitable for capacitive loads or for switching higher powers up to 2.3 kW with an AC system.

In the case of switching lower powers, for example lights, SSR relays are popular, which can be used to switch a maximum of 230V 2A in an AC system.

The relays have a practically unlimited service life, as they do not have a mechanical part. The only limitation with this type of relay (used in the Arduino) is only the possibility to switch alternating current, as a semiconductor triac component is used as a control element.

Web application screenshots:

The source code for Arduino is fully compatible with the website at: https://arduino.php5.sk/rele/

Source codes can be found at: https://arduino.php5.sk/ovladanie-rele.php

The program is also fully compatible with another - often used Ethernet module Wiznet W5200 or W5500 for Arduino.

In the source code, you only need to modify the library on Ethernet2.h and also connect D2 to INT.

After uploading, the program fully communicates with the web via the HTTP protocol, and  you can try status changes from the web interface. During the project, it must also be remembered that the relays are switched indefinitely, which is also a disadvantage of this project, for example when using a relay for a boiler or other risky appliance.

© 2021 Martin Chlebovec - Arduino Blog - . All rights reserved
Powered by Webnode Cookies
Create your website for free! This website was made with Webnode. Create your own for free today! Get started