Home Automation using NodeMCU ESP8266 and PHP Website. Control Relays using NodeMCU ESP8266

Home Automation over Online Server using NodeMCU is an IoT project to control our home appliances like light, fan, cooler, etc. from a website. In this project, we use NodeMCU and Relay Module.

We also develop a PHP website to command the NodeMCU for controlling our home appliances. We use a hosting server to online our website for controlling our home appliances from everywhere.

Must Read:

Components Needed

How it works

home automation online server

Setup the Website

First, we have to make a website and host it from an online server. We have developed a basic PHP website with an MYSQL database.

You have to perform following steps:

  1. Download the following PHP codes files which is in zip format.
  1. Now go to your PHPMyAdmin in your CPanel and create a database. Here we named our database as “autodb“.
  1. Now upload the PHP Scripting file to public_html in your CPanel’s File Manager.
  1. Extract the zip file and edit the connection.php file.
  1. Now change the “DB USERNAME“, “DB USERPASS”, and “DATABASE NAME” in the connection.php file.
  1. Now download the below SQL database file. Extract the Zip File.
  1. Import the SQL file to the “autodb” database in your PHPMyAdmin.
  1. Now browse the desired file location on the website in the web browser. For example – www.domain.com/automation. Here automation is the folder where we have saved our PHP files.
  1. The login credentials are Email: admin@auto.com and Password: 12345.

Circuit Diagram of NodeMCU with Relay Module

Circuit Diagram of NodeMCU with Relay Module home automation

Code For NodeMCU

Now open the Arduino IDE and change the Board from tools.

Must See: How to program NodeMCU with Arduino IDE.

Now copy the below code and paste it in Arduino IDE. Change the WiFi SSID, Password, and Domain Name from “www.domain.com” in the below code.

Some More Articles For You:

Our Youtube Channel

Scroll to Top