• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » ESP32 Arduino IoT Relay Control (PHP MySQL Based Self Hosted)

By Abhishek Ghosh December 5, 2022 8:41 am Updated on December 5, 2022

ESP32 Arduino IoT Relay Control (PHP MySQL Based Self Hosted)

Advertisement

This is the first guide for the series of guides to replace the setup for IBM Watson IoT based projects. If you look at our old articles and GitHub repository, you will realize that we were publishing IBM Watson IoT-centric sketches for the past 4 years. A significant time and effort were spent and our innocent readers were using them. Suddenly they came to know that IBM Watson IoT platform will get closed.

That event forced us to start searching for a modern alternative to quickly get started. In the earlier article on this topic, we have pointed towards some of the ways which our users can select themselves.

 

How We Have Started ESP32 Arduino IoT Relay Control Project

 

Codes and snippets of this article are fully based on electronoobs.com’s NOOBIX project. We have forked their present version on our GitHub repository without modifying any file. If you download the version 1.0.0 from our GitHub repo, you’ll get the same files they have distributed. The future versions of the project will gradually change and will not be compatible with NOOBIX project. We will also be happy if you want to follow the guides of electronoobs.com instead of ours. They have invested their time to create some DIY projects with the hope that some of the readers will use their affiliate links and they will get some money. If this v1.0.0 comes to your work then kindly consider donating them. The reason I have chosen their files as a base is that they are time-tested by many users and they are basic and fat-free. It is difficult to start a complex project.

Advertisement

---

ESP32 Arduino IoT Relay Control

The diagram is indicative only.

 

How to Get Started With This Project

 

This project can control one Relay and have one LED indicator. There is no encryption and you can not use it in the final project because of a lack of security. This is good to get started and follow our next guides for further development.

You need a few things for this project. First is an ESP32 dev board which is configured to use Arduino IDE. Second, you will need a solid-state relay connected with Pin 12.

On the server part, you will need a LAMP server. Your existing server running WordPress should work fine or you can use some cheap or free host and install a LAMP server on it. We have guides to install Apache2, Percona MySQL and PHP on any VPS. You can use any shared server like that from BlueHost or GoDaddy or HostGator.

Create a MySQL database and create a Table with the name LED_status with number of columns 2. Name the first column as id and second column as status. Type of both will be INT. Length/Values will be 11 for both. id column will be incremental and primary. The value of id will be 1 and status (rows) will be 0. You can run these two SQL queries to create it:

Vim
1
2
3
CREATE TABLE `esp32`.`LED_status` ( `id` INT(11) NOT NULL AUTO_INCREMENT , `status` INT(11) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;
 
INSERT INTO `LED_status` (`id`, `status`) VALUES ('1', '0')

I am describing the project originally had. I will supply the required SQL from next versions, so you need not to fight with it if you do not know what I am talking about.

Now, go to our GitHub project. Open the ESP32 sketch.ino file and edit these below lines:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
...
//Add WIFI data
const char* ssid = "ElectroNoobs-Taller";     //Add your WIFI network name
const char* password =  "12345678";           //Add WIFI password
...
...
      /*Begin a new connection to the website. Make sure you change "https://electronoobs.com/" to
       *the name of your website. So the next line should be:
       *http.begin("https://yourwebsite.com/NOOBIX_V2/esp32_update.php");*/          
      http.begin("https://electronoobs.com/NOOBIX_V2/esp32_update.php");          //Indicate the destination webpage
 
...

The WIFI network name and WIFI password will be of your router or mobile hotspot.
yourwebsite.com/NOOBIX_V2/esp32_update.php must match the public URL of your file.

You can upload the files to your ESP32 via Arduino IDE. Now go to /server_files/ directory of the GitHub project. Open the connection.php file. I will sanitize this file in future, for now, create a MySQL database and fill up the basic details. Upload these files on the public root of your web server (and delete the index.html file):

– connection.php
– esp32_update.php
– index.php
– led_off.png
– led_on.png
– main.css

If you open index.php on the browser, you will be able to control the relay.

 

What is Next?

 

In near future, we will remove the LED control via the index.php file. You will be able to control the relay via HTTP POST request via cURL command with bash scripts and developer mobile app. We will add a push button control with debounce-on code. This was the setup we started working with IBM Watson IoT. We have to secure the server so that without an access key, unknown people can not send an HTTP POST request to control our relay.

Tagged With esphome управление реле , Esp32 подключение реле , https://thecustomizewindows com/2022/12/esp32-arduino-iot-relay-control-php-mysql-based-self-hosted/
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to ESP32 Arduino IoT Relay Control (PHP MySQL Based Self Hosted)

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • IoT Based Pulse Oximeter With ESP32, MAX30102 and IBM Watson IoT

    Pulse oximeters are in use since long during an operation, in intensive care, in the emergency room and other places such as in unpressurized aircraft. The COVID-19 pandemic made pulse oximetry technology for the consumers. Most of the finger pulse oximeters in the market lack BLE and Wi-Fi. There are only a few finger pulse […]

  • Control Multiple AC Appliances With One ESP32 Arduino

    Here is how to use ESP32 and IBM Watson IoT to control multiple relays (i.e. multiple AC appliances) by pushbutton and over the internet.

  • How to Control Multiple Relays With Single Arduino ESP32?

    Before How to Control Multiple Relays With Single Arduino ESP32 Testing, You Need to Learn How to Create Multiple MQTT Channels & Fetch Data.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy