• 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 Esp32 подключение реле

This Article Has Been Shared 364 Times!

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)

  • CircuitPython vs C/C++ vs Lua for the Microcontrollers

    Which Programming Language Better for the Microcontrollers to Invest Time? Here is CircuitPython vs C/C++ vs Lua Comparison for the Microcontrollers.

  • 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.

  • Samsung Smartwatch as Proximity Switch : Part I

    We Can Use BLE of Samsung Smartwatch to Work as Proximity Switch Created With ESP32 Arduino for Automation of Lights in a Room.

  • Pulse Oximeter with ESP32 and MAX30102

    The MAX30100 IC is an integrated pulse oximetry module two LEDs, a photodetector, optimized optics, and low-noise analogue signal processing designed for the wearable devices and medical devices. The MAX30102 IC is an upgrade to The MAX30100 and The MAX30101 IC. Here is the datasheet of MAX30102 (website of MAXIM). The PDF will give you […]

  • ESP32 Arduino WS2811 Pixel/NeoPixel Programming

    The WS2811, WS2812, WS2812B, WS2813, and SK6812x are known as NeoPixel or Pixel. They are RGB LEDs with a controller. Particularly WS2811 RGB LED strings are commonly sold in India during Diwali and in North America during Halloween, Christmas etc. Bhoot Chaturdashi in India and Halloween in North America are equivalent. Indian wedding typically involves […]

Additionally, 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

  • What is Voice User Interface (VUI) January 31, 2023
  • Proxy Server: Design Pattern in Programming January 30, 2023
  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023

About This Article

Cite this article as: Abhishek Ghosh, "ESP32 Arduino IoT Relay Control (PHP MySQL Based Self Hosted)," in The Customize Windows, December 5, 2022, February 2, 2023, https://thecustomizewindows.com/2022/12/esp32-arduino-iot-relay-control-php-mysql-based-self-hosted/.

Source:The Customize Windows, JiMA.in

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT