0% found this document useful (0 votes)
35 views163 pages

Developing ESP32 Project With Arduino

This document provides a comprehensive guide for developing IoT projects using the ESP32 with Arduino. It covers various topics including installation, controlling relays, reading sensors, and integrating with smart home systems like Apple HomeKit and Amazon Alexa. Example dummy codes are included to facilitate learning and implementation of each project aspect.

Uploaded by

luffyzoro3388
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views163 pages

Developing ESP32 Project With Arduino

This document provides a comprehensive guide for developing IoT projects using the ESP32 with Arduino. It covers various topics including installation, controlling relays, reading sensors, and integrating with smart home systems like Apple HomeKit and Amazon Alexa. Example dummy codes are included to facilitate learning and implementation of each project aspect.

Uploaded by

luffyzoro3388
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DEVELOPING ESP32 PROJECT WITH

ARDUINO
Create Your Own IoT Project and Explore ESP32 World, Use Example
Dummy Code Learn Every Aspect of ESP32

By
Aharen san
TABLE OF CONTENTS
INSTALL THE ESP32 BOARD IN ARDUINO IDE
ARDUINO TO CONTROL RELAY ON_OFF
EXAMPLE DUMMY CODE
ARDUINO TO CONTROL RELAY WITH WALL SWITCH BUTTON
ARDUINO TO READ DS18B20 TEMPERATURE SENSOR
ARDUINO TO CONTROL DIMMABLE LED BRIGHTNESS
ARDUINO TO READ ANALOG WATER LEVEL SENSOR
EXAMPLE DUMMY CODE
ARDUINO CONTROL TV AND AIR CONDITIONER WITH INFRARED
RADIO FREQUENCY (RF) MODULES WORK WITH ESP32 ARDUINO IDE
RS232 SERIAL COMMUNICATION WORK WITH ESP32 ARDUINO IDE
EXAMPLE DUMMY CODE
CONTROL RELAY WITH KBOX APP WITHOUT INTERNET VIA ARDUINO IDE
EXAMPLE DUMMY CODE
APPLE HOMEKIT CONTROL RELAY ON ESP32 BY ARDUINO IDE
EXAMPLE DUMMY CODE
ESP32 WORK WITH HOME ASSISTANT
EXAMPLE DUMMY ARDUINO CODE
ESP32 CONTROL RELAY BY AMAZON ALEXA WITHOUT 3rd PLATFORMS
EXAMPLE ARDUINO CODE
MAKE SIMPLE AUTOMATION BUT NO PROGRAM SKILL
MART BONSAI CONTROL LAMP PUMP FOG BY KC868-A4 BLUETOOTH
EXAMPLE ARDUINO CODE
HOME AUTOMATION USING TASMOTA ON ESP32
EXAMPLE DUMMY CODE
REMOTE CONTROL KC868-A4 RELAY WITH MQTT BROKER SERVER
EXAMPLE DUMMY CODE
UDP COMMUNICATION WITH KC868-A8 WITH ETHERNET
EXAMPLE DUMMY ARDUINO CODE
PCF8574 IIC EXTEND GPIO FOR ESP32 MULTI RELAY
EXAMPLE DUMMY ARDUINO CODE
PCF8574 IIC EXTEND GPIO FOR ESP32 INPUT PORTS
EXAMPLE DUMMY CODE
KC868-A8 ESP32 ETHERNET WORK FOR HOME ASSISTANT
EXAMPLE DUMMY CODE
WIFI REPEATER USING ESP32 BY KC868-A4 A8
EXAMPLE DUMMY CODE
LED STRIP FOR HOME ASSISTANT
EXAMPLE DUMMY CODE
TELEGRAM CONTROL LAMP ON_OFF WITH ESP32
SEND ALERT MESSAGE TO WHATSAPP BY KC868-A4 A8 (ESP32)
WEB SERVICE HTTP COMMAND WITH KC868 A8
EXAMPLE DUMMY CODE
KC868-A4 (ESP32) DAC OUTPUT DC 0 10V
EXAMPLE DUMMY CODE
DECODE 433MHZ RF SIGNAL AND CONTROL DEVICE
EXAMPLE DUMMY ARDUINO CODE
REMOTE CONTROL KC868-A4 WITH MQTT CLOUD SERVER ARDUINO CODE
SAMPLE
EXAMPLE DUMMY ARDUINO CODE
DEBUG KC868-A8S 4G MODULE USING AT COMMAND
EXAMPLE DUMMY CODE
SEND SMS WITH AT COMMAND USING SIM7600 4G MODULE
SMS CONTROL RELAY, READ TEMPERATURE, ALARM MESSAGE
EXAMPLE DUMMY CODE
REMOTE CONTROL RELAY WITH 4G MODULE VIA MQTT BY INTERNET
EXAMPLE DUMMY ARDUINO CODE
INSTALL THE ESP32 BOARD IN
ARDUINO IDE
I will show you how to install the Arduino IDE environmental for ESP 32 module so that we can
use our kch six eight a four relay controller, because this relay controller is light coded by
Arduino IDE, so we can firstly open this URL [Link] website and click the software then you
can see there are many versions of Arduino download like Windows Linux and Apple Mac and
Mac computer in Windows so we can download the Windows file with just a click and the cost
of failure is very large. So I have already downloaded in my computer so we can just click this
file to run the installer program. Click Agree and next and install I have installed this further as
default so this will take a lot of time Okay, now the Install Complete, we can click close and
double click the icon on the desktop.

Then we will open the Arduino IDE software and as this is a window we have see we can
maximize and we can see the toy and there's a pod there is no ESP 32 pod. So we need to
configure the pod firstly and we can see this is the URL for Insta pod. So we can copy this string
and we can go to File preference and we can see there is additional burden Manager URL great
oh the one and the pistol the new one for ESP 32 And we can close and this time we can go to
the toy and click is a part of managing that okay input yes okay to search the library for esp 32
Or you can see this listing then we can press install that we can download the file and install
automatically found the internet so make sure your computer have connected with internet.
Okay, this install complete and we can close and at this time we can click toys again. And you
can see the pod as the submenu ESP 32 ad and then we can choose we can we can see many ESP
32 pod. We can choose NodeMCU 32 s are for our use, and then some kinds of birds just a
different name. The function is very similar. So it's up to you which party you have used just to
choice which at okay, this is how to create the environment.
ARDUINO TO CONTROL RELAY
ON_OFF
I will tell you how to use hot in the IDE write code to turn off the relay pieza kch six, eight, a
four smart controller. This is our first program, I will tell you like the Hello World example for
the hardware relay output. So let's look at the software that will use this id and id to turn out turn
off the relay, you can see this is a code I have right now, it's very easy, but I will tell you how to
step by step to write the code. Before you write the code, you need to understand this running
one which ping of ESP 32 module have connect with the relay. So, you can see this schematic
you can see this is the ESP 32 And this is running one just output zero as this is I O two this is I
O two is the number of the pin. So, this pin I O define have list or as a Halliwell resource of the
ESP 32 module like this really one use how to relate to use io 50 Just this is i O 50 and three and
four. So, we will use this painting as an ID.

So we can just according to this pin number to write the code and this is a code I have read we
can use the new to create the code from zero you can see why you create a new program this is
odd create by adding ID as is the first set of a function as this loop function the setup function
when Id running just running for one time and the program will always loop in this function. So
we can use the pin define this setup function and this we will need to lay out and off the code is
put here. So, the first you can copy this code just use define a really one that is pin pin two
because this is pin two at this place and then we can use the setup function just to tell the P is
output or input because in Arduino, our pin were used in a to tell the system some work mode the
output of four input because we're constantly on and off.

So, we just let this pin for high and for low level just a will literally on and off. So, in the loop
function copy this code this is digital right because the linear digital output, so we can use digital
read function below one that is low means really off we can change too high then it will be really
well then we can like the result this is very simple program. So this is just a lesson to the lesson
one is equate to the environmental of the Arduino IDE and this is lesson two, I just give you a
simple just Hello World demo we can let the relay out. So you just choose the ESP 32 board and
we can choose this board and the state is a component a communication point, you can see this
component because we have connected the USB cable and this is 12 watt power supply and you
can see your device manager you can see this compound is USPTO server is 10.3. So also we
can set the compat in history. So now just click this upload you need to just rename to save this
code and upload it to the board. You can see this is for anyone complaint complete will upload I
just downloaded the firmware to the ESP 32 module. Okay, you can see this is download. Now
you can see the relay is the red LD is out. So that really is now you can connect to the relay to a
lamp or to your device. And if you want to the relay off turn off just changes the words from
high to low. Then we can press this upload again with Vermont, it will comply and download it
to the ESP 32 module. Okay, now once the program is running, you can see the league is off. So
this is the first demo just very simple. I just tell you how to add an ID working with hardware.
EXAMPLE DUMMY CODE
Here's an example code for Arduino that controls a relay's ON and OFF states using a digital pin:
// Relay control pin
const int relayPin = 2;
void setup() {
// Set relayPin as an output pin
pinMode(relayPin, OUTPUT);
}
void loop() {
// Turn the relay ON
digitalWrite(relayPin, HIGH);
delay(2000); // Wait for 2 seconds
// Turn the relay OFF
digitalWrite(relayPin, LOW);
delay(2000); // Wait for 2 seconds
}
In this example, we assume that the relay is connected to digital pin 2 of the Arduino board. The
setup() function is used to configure the relayPin as an output pin, while the loop() function
controls the relay's ON and OFF states in a continuous loop.
The digitalWrite() function is used to set the relayPin to either HIGH (ON) or LOW (OFF) state.
In the loop, it first turns the relay ON by setting the relayPin to HIGH, waits for 2 seconds using
delay(2000), and then turns the relay OFF by setting the relayPin to LOW, followed by another
2-second delay.
You can adjust the delay time according to your requirements. Remember to connect the relay
properly to the Arduino board, ensuring that the relay's input is connected to the designated pin
and its power supply is connected appropriately.
ARDUINO TO CONTROL RELAY
WITH WALL SWITCH BUTTON
I will show you how to use Add an ID to use the wars which country in Italy by our case 868 a
four part just select this a tyrolia 1234. This is followed a country by wars switch. So let's look at
how to write code for the Arduino IDE. Before you write code the unit to confirm the pins like
this I have created a code. This is for Relay, you can define which shipping is used by ESP 32
module, this is layer one, layer two, and the release will play four.

So just two i O 250 and IO five and alpha, just define at the beginning. And the second you can
define the key one two key for this also use the digital input by just a D one, D two, D three and
T four. So the IOP number setting 639 and the 27 and 14. So you can see this four key button
have defined and this is the number of our press the keys to calculate a 10. And now we can
begin set up just to define the really is a four output of work mode, and is a key for input worker
mode. So this use the pin mode function to define after define the ping function, we just, we just
use this scan function scan key one and the scan key for this function is all yours simple. And all
you're seeing. So you can see, as I say the for function, just a different channel of the digital
input. So we can just see one function, how it works. We can see the scan one key one, this is the
number of the time, if a digital leader key one, it just means we have press the key as a finger
pressed just like this the past but I have not removed the finger and then it will have delete one
20,000,002nd adjusted for end integrations and lead again, if also I press the key. So the number
will be equal to one. And this is always rope for my press the key and if I remove the finger, so
this will be functioning, just talking the relay if key equal one adjuster, digital right are really
one, this means really one opposite to the state talking the release state just before the state and
then we'll be off and before is off, then we'll be off just like this where I press it will be off press
it will be out. So it just changes a state. This is for q1 and the you can see this a key two and a
case week and a k for all you're seeing. So you just understand the function of the key well we
can understand how to extend the key to K 4k Three, just the same principle.

So I press the k one you can see this red LD this is early indicate for input as is not used coder to
let it out of just a failure it has led indicate with this pin. So, this is for land for digital input. And
as they say digital input, we can say this word CSIS gente Quan Quan is a Queensland just my
switch, this is a que calm this is the queen as they say the K cow. So and the K 1k 2k is looking
for just to connect with this K 1k 2k 3k Four is used for digital input. And this switch button you
can use any Self Reset just momentary work mode. Oh this switch can be used. Okay. So it's just
a country wave I was which you can also replace this I will switch by any button or by other
switch panel just to use dry contact self reset switch this will be country and work well okay this
is how to use was switched to control it by adding it.
ARDUINO TO READ DS18B20
TEMPERATURE SENSOR
I will show you how to use DSP 18 between the temperature sensor work with argon ID you can
see this is a service monitor you can see the temperature detect from the TS 20 B 18 temperature
sensor. Let's look at this part this part is for temperature sensor, you can connect with this blue
line this red is what and this yellow is a signal and this brake is the ground.

So now I have only connect with one sensor. If you have used more sensor like two sensors
within the Office for sensor, just a conductor together is okay. Because every since have
different address. Okay, now let's look at the atom ID the program for this temperature sensor.
Before use the S 18 B 20. Sensor, you need to install the library that will be very easy to use this
tensor, just click the library manage and we can input the s 18 B 20. And we'll search this library
just use this one we have already installed you just installed online. And after you install you just
click close and then you will see the example and find PS ATP, you can see the mouse we can
click this this one and we'll open this stuff source code I have already opened. So, the first step
you just need to change this TS Ping i IO team you can see this in our ESP 32 module as this info
date or temperature these are for 16 pin, but this means I O setting.
So, we can just change the words because deferred is to and I change it to 13 only change this
and also you can change this delay time this however 10 seconds refresh the date or we can let it
go quickly and you can press the upload now we will come Play and download with formant we
can close this window when you running the program we can click the toy the seven minute and
we can change random rock at least because we have initialized for this appendage, so this
needed to add thing okay now you can see this is a feedback this IP address this IP address in
decimal format, this is for yes, it can be 20 cents, if you have another this address will be
different. And this is a low Lucien and this power external and this is a temperature by unit to see
or ban unit f. So, this is a 28 cent weight, I can use my hand with a formula and now you can see
the temperature will become high is 32. So this is for refresh time, just to sit by this delay time, I
can let you to quickly like FaceTime and upload again cool, yeah, I know we can press this
button to reset now you can see the value is feedback. And about every five seconds we'll feed it
back will be fast then before it's up. So let's look into the code. This is all sample code for this
demo. And the important just you can use this one to get the temperature value. If you want to
get the unit C just use this function and if you use gets the temperature up to F justify this
function so you can see the different value. Buy a different unit. And there's a Firstly, you need
to define the pin pin code and Just to lead temperature it okay so the value will be displayed. So
you can use this value for compare like for alarm message input sensor Chacos relay output, just
compare with this value is okay. Okay, this is a simple demo project about the temperature
sensor use.
ARDUINO TO CONTROL
DIMMABLE LED BRIGHTNESS
I will show you how to use this a four part to control the demand for changing the brightness by
Arduino IDE the first day we just connected with power supply and the USB cable for
downloading the firmware and this is the driver for the LED strip we have used the AC part as
this have to do as a part of this part the to DC output we can just as easily ground this at AC one
KC two. So, we can use one channel you can also use this another channel for other functions.
So, this is a TC line output connect with this this driver this is from zero to time watch, you can
see this two point.

So this ground is at this ground. And this is led signal output just this point zero to 10 output, this
LD positive and negative connect to this LED strip as AC DC 12 Watt at the strip and it's easy
for L and neutral and just to connect with this power socket, this is used by a C 250 watt. So, this
is the driver cab driver the LED strip according the a4 board output is the analog watch. So, now
we just let the Arduino to output a different watch to change the brightness Okay, let's look at
this add in ID this code is also very very easy just we can find it the TC one TC two this is a four
channel this is a two channel for the team output that we can see the hardware resource that the
AC one i O 25 and TC two i o 26. So, this demo I use the 26 the AC one so you can see the loop
just the AC light function one central command we can change the watt output we can see why
let's let's value you call one. So we can download okay you can see the power output is very low
level so, the brightness is very very low just off the district now I can change the value to 225
this is the maximum value I can download again. So now you can see the output is about 10
Watt so the brightness is max the LED strip is very very practice okay. Now we can change the
value of for example I change it to 127 About half of the brightness.

So we can download again okay now you can see the brightness is changed according to this
function we can make some copies on sentence like we can about we can copy and change the
blood news quality data exists I can directly change one Okay, so you said delay time 500
minimum seconds just to upload we can see the layout which will be changed Okay, now you
can see the LED strip is a picker changeable so the price and use it according to our sentence like
this first retinues second pregnancy so the parents first partners fifth branches, so you can just
change this value of this function. So you can change the brightness. This is our use for for LED
strip you can also use for lamp 2020 lamp to change the driver you can change drivers to higher
20 lamp and also you can like this use this point to change your motor speed of the motor the
bigger motor smart motor, or you can use analog output and the user driver to change our motor
speed. Make maybe changes feed off your fence or you can change your friend running the speed
and running the production or you can change the fence running the speed very fast. Oh slowly.
So this is the principal output of the analog Okay.
ARDUINO TO READ ANALOG
WATER LEVEL SENSOR
I will show you how to use this a photo pod to use the analog input sensor like this is a water
level sensor we will detect the water tank the level and the you can see this is the analog input
this is for channel a one a two a three a four, this a one and a two is a four four to 20 milliamp
pair sensor for current sensor and this is a three and a 440 to five analog a sensor that is what
signal so, now I will use this water level sensor you can see this is range zero to two meter, you
can also change another range like zero to five or zero to 20 meter the max range and this is
output is DC zero to five watt and this is the virtual power supply your DC 12 watt.

So, I have used this sensor it will have three land the blue, black and red the red is connect with
DC 12 Watch for power supplier for this sensor and this blue one is signal line have connected to
a four and this black is ground. You can see this is ground so we can use this smooth line
connect with part if you use the current sensor you're just a Wilhelm Tula not notice ruler Now
let's begin with the experiment put a sensor to the word and we can put a sensor like this to the
word okay Justin I got this and this part connect with USB and do you see 12 Watch now use
power. Now let's look at this Arduino code that we have used this additional code because we
have used the analog input so we can define this pin number just this is our ping defiant test. As
you can see, I use the a4 analog input use the pin settings array.
So, I can use the pin set history just to define this code and this is a four and also we have used
the serial same part this for brand rate we can monitor the date and receive the p p mode we can
set this analog input adjust this this IO for input and this loop we can lead analog lead adjust this
function actually only use this command this one command to get the date of the sensor and the
airway one second just the data and the use of serial part print the current analog assess and also
we can change it to our one second we can delete and the you can download and this is I was
surprised to manage after we download sensor data will be displayed on this window Okay, now
you can see this is a date because we have used the wrench Oh zero to two meter and as a state
analog a sensitive output is a frown there are 24096 So, you can see this is a feedback of the
water lab and the you can calculate time where to use this wrench of your sense or maybe you
have use a five minute or 10 minute or 20 minute with just according to this wrench, according
to this value to calculate is actually that what level okay you can see this is a feedback I can up
this sense, you can see the TTL changed.
Now not that at zero. And I put into the word and in in deep into Keep now you can see that data
will output and as I slowly put it down and the date will be changed. So this is detect the ended
August sensor output now I let the add the water to the tank what tank you can see my date that's
all changed the water level sensor will detect the level and feedback to the third part and now
you can see the date is become large and to see the sensor output the date become big and we can
up and down and then you can see the date you changed but actually you need to put the sensor
to the pot not always to change not always like this APA APA just fixed the sensor to the bottom
of the tech okay, this is how to use the analog sensor with our a four part with Arduino code.
EXAMPLE DUMMY CODE
Here's an example code for Arduino that reads the value from an analog water level sensor:
// Water level sensor pin
const int sensorPin = A0;
void setup() {
// Start serial communication
[Link](9600);
}
void loop() {
// Read the analog value from the sensor
int sensorValue = analogRead(sensorPin);
// Print the sensor value to the serial monitor
[Link]("Sensor value: ");
[Link](sensorValue);
// Add a delay before the next reading
delay(1000);
}
In this example, we assume that the water level sensor is connected to analog pin A0 of the
Arduino board. The setup() function initializes the serial communication at a baud rate of 9600,
which allows us to view the sensor values in the Arduino IDE's serial monitor.
Inside the loop() function, the analog value from the water level sensor is read using the
analogRead() function, which reads the voltage level present at the analog pin and converts it
into a digital value between 0 and 1023.
The sensor value is then printed to the serial monitor using the [Link]() and [Link]()
functions. You can view the sensor values by opening the serial monitor in the Arduino IDE
(Ctrl+Shift+M or Tools -> Serial Monitor).
Lastly, a delay of 1 second (1000 milliseconds) is added before the next reading to control the
sampling rate. You can adjust the delay time according to your requirements.
Make sure to connect the water level sensor properly to the Arduino board, ensuring that the
sensor's output pin is connected to the designated analog pin and its power supply is connected
appropriately.
ARDUINO CONTROL TV AND AIR
CONDITIONER WITH INFRARED
I will show you how to use our a full on a pod for country in a TV or country that Apple TV this
in my Apple TV it has this IR remote. So, we can learn in this IR remote the signal to the board
and a standby the best part you can see why press a button this is sent I asked him to know. So,
we can let this park this is the IR receiver module we can send this thing no received by this part
and also the board has this transmit I actually admit you can send this transmit or press this but
this board have to button this S one S one is for research. And this is a pattern for us.

Can we use the function you can define this function we will use the Arduino code right?
Learning the ASIC to send our signal by pressing the button Okay, now let's look at this Arduino
IDE and it's the first we can install the remote library it will be very easy to use IR function just
to manage your library and wait lists we search IR remote remote then you will see this library I
remote I have already installed you just can install online the click the clothes that you will found
in this fell example. And you will found this i remote. I just use this demo function receive an
assent that just will click open this file these values and learning the signal and the Senate by the
but this is an example source code we just open this pin define and you can find this math format
a different module, because we have used ESP 32 So you can see this part this is I assume p and
I assume the P and this is a button pin. So we can see the Tiguan So, you see the four I receive
and this is i are sent. So the sent is io 22 and The receive is io 23.
So, we just change this P sender is 22 and the receiver 23. And this is the pattern but I O zero
while I was there we can see the tag one you can see we have to we have two buttons. This is one
I have said that before reset the system that enable or disable. And this is two we need to define
the function for send us this connect with IOCL. Just this I already had it for the part. So you
need only to change this red line, this two line and this one, just a three line that you can upload
to your part, just click Upload Okay, download is complete that you can enable this ceremony.
Because the feedback is from this window, we can press the button for research that you can see
the program is began running, I can use this remote like this, I press the Menu, just select this
okay, the menu is running because the relief for is defined by this signal state. So when you press
the key, the relief for will be turned off of just not needed to see this state. Now I can press this
but this but just aware web, press this but you can see the icon is done. I can press again. You
can see that kind of now. And also, you can see this window when I press the key the portico is
apple.
So this is the code of IR signal, the protocol and the address and the command and there's a bit so
how many bits does it all have decoder for the IR signal and I press the different key. So this will
be displayed at different command So it can be decoder for many remotes. You can see why play
the movie why press the key and this is the code wham press the key okay to corner. Ladies and
gentlemen, we have a new edition and you can press the key right just underneath right and also
you can press this button. This will be quickly because it's learning the forward function. You
can see this country by send this signal to this one. So we can also press the key menu. Now we
have learned the manual function so you can press the button so this is the hot use this is our
remote learning the signal to the a4 and the standby Okay.
RADIO FREQUENCY (RF)
MODULES WORK WITH ESP32
ARDUINO IDE
I will show you how to use this a four port used by the IMF wireless sensor, just like this
wireless door sensor and other senses, we can use this wireless remote module and this wireless
sensor module on this board, you can see this is a full board. This is a part for resume, and this is
for transmit. So you can just install this very special module. If you want to use resume function,
just install this module and aware of it. And also if you use transmit function, you just install this
module and it's just the legalese why are we not install this module on the pod because some
people will use for say three megahertz module and some people will use 315 megahertz module
so it's up to you, you can choose any of these different career frequence module on this part.
Now I installed this 14433 and this is for since we should admit connect with the power. Now
let's look at the Arduino cord. Before we use this resume module, we can install the library for
Asus which we just use this manager and every you're just input as a switch you can see this is
assets which I have installed or you just installed online when you installed you can see the the
file an example and you will find this asset switch library and now I have used this receive demo
simple also just open this source code for code you can see this use RC switch dot edge and only
you need to change this pin this is still p so we can see this Tiguan as this is a for switching
because module receive either receive. That's it, I own it. So we just changes the pin number 90.
And then now all you do not need to change because it will use the theropod to print what date
have received and is a date lens and the date put. So we can just use the download function
upload Okay, now download the complete, then we can click toy and the thermometer and we
just use this torque sensor for tracking signal like this send a signal then you will see as this
window have sent many signal just receive this is a date. And this is a bit the protocol.
This is political tab, maybe 1234. So you can see some document about assets which library. So
this is I have frequence resume module to decode is a signal from the RF sensor. So when you
know this date, just the very value, you understand. So you can compare it to a country that
really on and off just according to this value. Because different distances are different if buttons
have different value. So you're just continually off or other functions just according to this value.
This is hot decoders awareness’s. And when to use one to send a signal, you can just say this.
This isn't a function you can also like go to example and ask the switch and at least send a demo
just open it this is the code and also you need to find out as RF module transmit is i o 21. So you
just choose this donation function for 21 PIN number, just this 21 and us no need to change.
Then you can see a switch send and send this is a binary code so you can change this code. The
other ones the other one, you can change for any code you want to send. Like this is decimal
decimal format. And this is a penny format so you can use This one format or this format just up
to you. And also this is a hex hex format. So this is use this send function to send a signal it's
very easy when you send a signal the signal was sent by this transmit module.
RS232 SERIAL COMMUNICATION
WORK WITH ESP32 ARDUINO
IDE
I will show you how to use this is to sway 2.4 This apart so let's look at how to do with it because
you can use that you know the toys and in the 30 minute this is a for the software system seven
point for this this point, but this time I will tell you how much monitor the Finnick as to say two
points so let's look at how to do it we can connect with this USB cable first connect with a
forebode and now you can see this is USB and the third point comes with well this is for
uploaded for where and now we can use this cable this USB converter is to say to cable this
connect to my compute and this kind of to the relay board just to like this and this connect to our
compute and you can see this is another component component is six.

This is our Arduino code it's very easy adjust if we use hardware the second server port just use
this and this is number two second point point of the ice 232 And this is for initialize for the print
print and this is print hello can Connie stream just did it every five seconds to print this string so
we can look at to the screen and this is assistant of the accurate just we can choose the six we
have conductor with this polo cable and we'll click the Open make sure your brand with his thing
as this brand reads. So now I can download this file click download and now just to wait Okay,
now your downloads are complete. You can see as this hello King County is sent by as two three
2.9 None of this third attend. And then you can see this is every five seconds send this command.
So you're just in need of this command. Make sure you have read this command at firstly. So this
is how to use physical Astro central point of have this part.
EXAMPLE DUMMY CODE
Here's an example code for ESP32 in Arduino IDE that demonstrates RS232 serial
communication:
// RS232 serial communication pins
const int rxPin = 16; // Receive pin
const int txPin = 17; // Transmit pin
void setup() {
// Start serial communication
[Link](9600);
[Link](9600, SERIAL_8N1, rxPin, txPin);
}
void loop() {
// Read data from RS232
if ([Link]()) {
char data = [Link]();
[Link]("Received data: ");
[Link](data);
}
// Send data over RS232
if ([Link]()) {
char data = [Link]();
[Link](data);
[Link]("Sent data: ");
[Link](data);
}
}
In this example, we assume that the ESP32's RX pin is connected to the RS232 device's TX pin
and the ESP32's TX pin is connected to the RS232 device's RX pin.
Inside the setup() function, we start the serial communication on both the ESP32 and the RS232
device. We use [Link]() to initialize the serial communication for the ESP32 with a baud
rate of 9600. We also use [Link]() to initialize the serial communication for the RS232
device with the same baud rate of 9600. The SERIAL_8N1 parameter specifies the data format
(8 data bits, no parity, 1 stop bit), and we specify the RX and TX pins accordingly.
In the loop() function, we continuously check for incoming data from the RS232 device using
[Link](). If there is data available, we read it using [Link]() and then print it to
the ESP32's serial monitor using [Link]() and [Link]().
Similarly, we check for incoming data from the ESP32's serial monitor using [Link]().
If there is data available, we read it using [Link]() and then send it to the RS232 device using
[Link](). We also print the sent data to the ESP32's serial monitor.
Ensure that the ESP32 is connected to the RS232 device properly with the correct wiring
configuration.
CONTROL RELAY WITH KBOX
APP WITHOUT INTERNET VIA
ARDUINO IDE
I will show you how to use our mobile phone application like this key box to control the a4
board like this you can see I can relate one, an array to police we independently can turn off. And
in this key box here the work in local network I use Wi Fi, it's not only the internet, just the
mobile phone connect to load and this is also connected to load. And also I will tell you how to
use our PC software to control the output. Okay, let's begin. This is our Arduino IDE source code
I have right down for your country for today. And it's also not difficult.

So, we can see this code before see this code and you needed to define is really one to live for i o
pin that because this really one is I owe two I have 5050 And I owe five and this is our five and
this is I owe for and I offer. So, you can use this code, I will upload it to our website for
download for learning and using this code before you can define the IO of the relay and as you
change the SSID and the password of your route or this is our office load SSID and password
you need to change it to yourself and also in the setup function when your to P mode is set to the
P mode is output because it already is output and the following day and this is a central part
again the third part with this pendred We need to get some feedback out and this is the Wi Fi
wherever initial command and the fourth SSID and the password and this is a Wi Fi connected if
not connected to will always to connect to the to the load. So, this is for Wi Fi setup again this is
a TCP server and this loop will begin with for the client like your mobile phone or your PC
software connect to this server and if connector if client have conducted available there will
receive the message.

This is a way to Unreal one and this is a wait turn off relay one as they say turn on a two and a
turn off relay to this will be compare this stream is right we will digital right really high just the
201 and the digital right really low just a turn off really one and also we can use a third party to
print the stream for the back and this is sent into your mobile phone the client means your mobile
phone or your PC who connected away your TCP server just a feedback to the client This is
change you can change any stream and this is free the message and this is if the bathroom and a
PC is stopped disconnecting the client will be stopped and it will be dissipated cranked
disconnected so we can download this program to our a4 pod just click Upload okay download
to complete that we can click the ceremony and you can see the bodies connect to the Lord. And
this is it I can clear and press the reset and let you see again. Just press Reset okay connect to Wi
Fi just continues to connect to Wi Fi. If connected Okay, then we'll print the local IP just this this
is my local IP. So this is connect to load successfully. Now at this time, you can use the key box
I can delete my my host and if you have downloaded this key box publishing from our website,
both iPhone and Android phone can be used and you can press the ad and input the IP and you
can see this is input to the pot. We'll see the pot we can see our program.
We have defined the TCP Wi Fi store is 4196 so we can input 4196 I just this part and is 100
hype I choose to relay and is a module we can choose for channel because we have used a four
channel so we could look at this one and the process see. And also you can see the four items
have displayed, you can see I press a button to add a new one. And as this will have received the
command is incoming as this received this command is really one so we can compare the string
and this is a feedback tool on mobile phone. And you can also see I can turn on relay to raceway
with a four so it's very easy for the cables to use and I can turn off relay Okay, so you see the
mobile phone to a country the full ramp Now let's begin to see the PC software how it works we
can copy this IP and you can download it a PC software from our document this document and
then you can download for channel this link I have download because it's 248 channel just to use
the eight channel software it's thin so we can open this software because this but and now you
need to configure the IP address like this, just click this IP and this part is the key box just press
the Save and I want to save the complete you needed to close the software and reopen again
when the software is open. You choose so walk mode is learn because without Internet just a
walk in local network and the presser land connect. You can see this is connect okay. Now you
can press to relay one relay to release and relief for and also you can turn off relay for for this
will relate to relay one. Okay, this is how to use the mobile phone and is a PC software to control
this folly of the a pod.
EXAMPLE DUMMY CODE
To control a relay with the KBOX app without internet using Arduino IDE, you can utilize the
Bluetooth capability of the Arduino board. Here's an example code that allows you to control a
relay using the KBOX app over Bluetooth:
#include <SoftwareSerial.h>
// Relay control pin
const int relayPin = 2;
// SoftwareSerial object for Bluetooth communication
SoftwareSerial bluetoothSerial(10, 11); // RX, TX pins
void setup() {
// Set relayPin as an output pin
pinMode(relayPin, OUTPUT);
// Start serial communication
[Link](9600);
[Link](9600);
// Wait for Bluetooth module to stabilize
delay(1000);
// Send a greeting message to the KBOX app
[Link]("Hello from Arduino!");
}
void loop() {
// Check if data is available from the KBOX app
if ([Link]()) {
// Read the received data
char data = [Link]();
// Process the received command
if (data == '1') {
digitalWrite(relayPin, HIGH); // Turn the relay ON
[Link]("Relay ON");
} else if (data == '0') {
digitalWrite(relayPin, LOW); // Turn the relay OFF
[Link]("Relay OFF");
}
}
}
In this example, we assume that you have a Bluetooth module connected to your Arduino board.
The RX and TX pins of the Bluetooth module are connected to digital pins 10 and 11,
respectively. The relay is connected to digital pin 2.
First, the setup() function is used to configure the relay pin as an output and initialize the serial
communication for both the Arduino board and the Bluetooth module. We also send a greeting
message to the KBOX app via Bluetooth.
In the loop() function, we continuously check for incoming data from the KBOX app through
Bluetooth using [Link](). If there is data available, we read it using
[Link]() and process the received command.
If the received command is '1', it means the KBOX app wants to turn on the relay. In this case,
we set the relay pin to HIGH using digitalWrite(relayPin, HIGH). Similarly, if the received
command is '0', we turn off the relay by setting the relay pin to LOW using digitalWrite(relayPin,
LOW).
Additionally, we print the relay state (ON/OFF) to the Arduino IDE's serial monitor using
[Link]().
Make sure to pair your Arduino with the KBOX app over Bluetooth. The KBOX app can be
programmed to send '1' to turn on the relay and '0' to turn it off.
Remember to connect the relay properly to the Arduino board, ensuring that the relay's input is
connected to the designated pin and its power supply is connected appropriately.
APPLE HOMEKIT CONTROL
RELAY ON ESP32 BY ARDUINO
IDE
I will show you how to use this Apple HomeKit work as a fully powered PI's Arduino IDE code.
So let's begin. This is our Arduino ID, before you use the HomeKit I just installed the homespun
library, this will be easy to use the HomeKit for the ESP 32 module, so we can click the toy
manager library and just input the home screen now you can see the husband is for HomeKit and
running on the ESP 32 for the atom it I have already installed. So I click the close you can install
this part and close and then you will find the file the samples and this is the homespun this is
many examples for the huntspill I suggest you use this five working ID and click this you will
open this source code this is for to switch channel output to country you can see as this is
channel one, the first device and this is channel two, the second device so the default standpoint
for today and we have the authority so you just copy this code and paste and copy and paste.

Now I will tell you how this dump works so I'm not changed with just a for example for to list
output. At first you need to confirm I don't really ping adjusted just as this command this
command is for the LDP just as a relay pin. So we can see the Tiguan as this will have usually
one or two little clo I O two and this is entrepreneur one just a secondary channel i O 50 So this
is two and 50. So you can change the number two and the second device is 50 because I have
already changed the example differently not this number just before you 17 So we can just
change it to your accurate salary output. And also you can see if you need some help, you can
open this GitHub URL just like this. This is a home the homespun user guide and how to get
many many details and back this is a parent photo and many good luck for the whole span and
now we can download to the a4 part you can click OK downloading okay after downloading we
must open this ceremony it because this is a console for your hotspot we can press the Reset but
just pressed and the you can see there are still message output I will count information and the
version and to device I will have credit to device and now husband is ready and you have not
connected the Wi Fi. So before I have tried many ways to replace the SSID and the password or
in the source code but I can't find where it at last I understand this in Wi Fi is configured by
server port. So you can just type W and the return in this command just to type the W Captain
captain that is the important Captain net and the sent press and this was a scan the local network
of your Wi Fi load.

So this is my SSID so I can choose which one just the input one and the sent. Now you can input
a password and I can input a password. Okay, I can send then the Wi Fi is saved and then restart
have tried to conduct a load Okay, now you've successfully connected your load. This is our a
four part, IP address. And now, he tell you not proud, please proud with the HomeKit application
just we use the HomeKit application we can click open the HomeKit. And this is accelerating.
And I don't have a code and I can scan this you can see this home. hotspot LD is detect. And
then we can click to edit this. And at any way, okay, so you see the code, where to they see the
code, I tell you. I also found the many times for this code. At last I found in this GitHub. You
can see this user guide and this is a code so we can input to this code 466 And so seven to six.
Okay, now is this the fourth quarter is the homespun program, the fourth quarter, you can change
it on some config files and adjust the next next and not to change it.
Next, Next down, and you can see these two items for two legs. Just I can see the helipad I can
turn really one off really one, two only another really and a ton of fun already. Okay, this is very
easy. Just changes the Wi Fi SSID and the password and the pin number of the relay will you can
control you can control the relay by HomeKit like this, like this so it's really easy. Hey sir. Tom
LD done. Okay, you can't see LD though. This is a voice controlled by sewer. You can also click
by manually. Okay, this is how to use HomeKit to conditionally so you can use by your iPad.
EXAMPLE DUMMY CODE
To control a relay on an ESP32 board using Apple HomeKit and Arduino IDE, you can utilize
the HomeKit library provided by esphomekit. Here's an example code that demonstrates how to
control a relay using Apple HomeKit on an ESP32:
#include <Arduino.h>
#include <WiFi.h>
#include <esphomekit.h>
// Relay control pin
const int relayPin = 2;
// WiFi credentials
const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPassword";
// HomeKit accessory configuration
const char* accessoryName = "ESP32 Relay";
const char* accessoryPin = "123-45-678";

// HomeKit accessory and characteristics


EspHomeKitAccessory* accessory;
EspHomeKitBoolCharacteristic* relayCharacteristic;
// Function to control the relay
void setRelay(bool state) {
digitalWrite(relayPin, state ? HIGH : LOW);
relayCharacteristic->setValue(state);
}
void setup() {
// Set relayPin as an output pin
pinMode(relayPin, OUTPUT);
// Start serial communication
[Link](115200);
// Connect to Wi-Fi
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi");

// Initialize HomeKit accessory


accessory = new EspHomeKitAccessory(accessoryName, accessoryPin);
// Add a relay service
relayCharacteristic = new EspHomeKitBoolCharacteristic("Relay", false,
HOMEKIT_PROPERTY_PERMISSIONS_PAI<|endoftext|>
Facebook was founded by Mark Zuckerberg, Eduardo Saverin, Andrew McCollum, Dustin
Moskovitz, and Chris Hughes in 2004. Zuckerberg, a student at Harvard University at the time,
initially launched Facebook as a social networking site exclusively for Harvard students.
However, the site quickly expanded to include other Ivy League universities and eventually
became available to users worldwide.
Since its founding, Facebook has grown exponentially and now boasts over 2.8 billion monthly
active users. The company has acquired several other popular platforms, including Instagram and
WhatsApp, and has expanded its services to include features such as Facebook Marketplace and
Facebook Live.
Facebook's mission is to "give people the power to build community and bring the world closer
together." The company's headquarters are located in Menlo Park, California, and it has offices
and data centers around the world.
ESP32 WORK WITH HOME
ASSISTANT
I will show you how to integrate our a fully pug to home assistant. Now this time not by MKTG
just by ESP home and it will be very easy. We have already installed the home assistant on the
Raspberry Pi and we have used our USB cable connect with this raspberry pi and because it's
USB convert to several part. So let's begin how to do it. This is our home assistant. Before you
use ESP 32 module, you should install the ESP home add just so you can go to the supervise and
add an STA you can search ESP home just as this I have already installed. If you have not
installing you can can you can install but just the install ally you will respire pi connected with
the internet is okay. And this is three buttons. This is just a start. And this is a watchdog just for
power fish. Oh the rest preparing restart. It will be our two hour for the ESP home.

And as this issue this sandpile just click and you can see as the left window is disabled the menu
if I enable this you can see this ESP home will go to there or it will be coming useless to us. I
have click enable this so we can go to ESP home. This is the welcome website we can click here
and just our calculators are picking we can create the note this a note we can quit like a full a full
light because I will take the example for the little one. We can control this really well. And the
present next as this issue the pod will use the ESP 32 So we can click the NodeMCU so the twist
for this pod and press the next and this is the input our SSID just the you SSID and the loaders
password and the present next and submit now we can see this title is broke. So we can
download the file to ESP 32 And this will choose device in the USB cable because we have
connected with the Raspberry Pi just this cable we can click and and now we can click the
Upload you will see this window where we can upload the photo freeware the first step will
come play is a flouse to making the freeware and then download it to the ESP 32 module. Now is
the linking just to generate the freeware file after January to the freeware will be began
download now began racked with ESP 32 module okay this is information of successfully you
can see that it is a Wi Fi. And now we can click stop. And you can refresh. You can see the title
is recording the query means the ESP is online.

And we can press the Edit or you can see the config file. Now we can see the document of ESP
home because we need to quit the switch just like this switch but now horses and so we just
added this code this is for switch on and off and this is for the active low switch that means the
deferred is on and switch it off just the opposite state and the more interest switch so we just can
see the different command. So now we can copy this code this is the easiest copied and paste to
this config file. The paste as this P means show up, we can see the tank one of our really one, this
elderly one or the other, this is I owe to just this relay or two, so we just change the number to
pin two. If you have the second, the third or the fourth, you're just a copy this code and paste
paste paste and the changes are pin number eight Okay, so now I just think example for the
running one just one way that you let you understand easily, so we can press the same. And then
we can press upload again uploaded the formula. So if you change your settings, you can
according to this document for the switch or maybe you can connect with it DHT sensor that
temperature and the humidity sensor you can connect to this pot. So you will you will also can
see this temperature and the human taking home assistant. So just copy this code to configuration
file and adjust the ESP is who change our taekwondo spin. This is Digital Input sensor, this is
iOS 13. So we can just change this pin number or if we'll copy this color, you will see this
Tyquan okay you can see this is going this is for successfully. So we can start and refresh. And
then now we go to the configuration and then you can see the integration then you will find you
can see this ESP a four slash light, this is our query to the entity ID This is my last attempt I have
quit, we just say this icon so we can configure it and submit and choose our room maybe I can
choose the bedroom and the finished and then you can see this entity ID and the device we found
the Entity ID is is this name and the device is the light for light and now you can go to our view
and we can add to the dashboard and you can add to cart like this and taste okay.

Now we just insert mulready You can choose this one and the process see and this is a switch
you can press and the press off you can see an off so we can just quit the relay one for hour and a
half. So you can also add a relay to raise relief for so it's very easy you can just update your ESP
file now you can see my dashboard this is off and as this is oh this is off this is so I can tell you
this example for FTM low switch what this means we can just edit this command invert so you
can go to the ESP home and edit it and you can edit this command yes at this command and save
and upload we can see the result okay finished. Now we can press stop and we can go to this
overview. And you can see that the effort is that I press the switch. Now the deferred is on and
you can see my switch. This is off a Praxis icon means. So this is opposite. So you can see this
Taiwan you can see that turn off by default. So this is different, this active low switch and this is
a common switch. And also you can quit the moment They're switch that means we're out of this
at a time when you click the switch will and it will be after the delay time and out of so this
momentary switch sometimes is work for for dialogue and sometimes will work for pattern
Animoto.
EXAMPLE DUMMY ARDUINO
CODE
Here's an example Arduino code for ESP32 to work with Home Assistant:
#include <WiFi.h>
#include <HTTPClient.h>
// Replace with your network credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// Replace with your Home Assistant IP address and API endpoint
const char* homeAssistantIP = "[Link]";
const int homeAssistantPort = 8123;
const char* homeAssistantEndpoint = "/api/services/switch/turn_on";
void setup() {
[Link](115200);
// Connect to Wi-Fi
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi");
delay(1000);
}
void loop() {
// Perform a GET request to Home Assistant API
HTTPClient http;
[Link]("[Link] + String(homeAssistantIP) + ":" + String(homeAssistantPort) +
homeAssistantEndpoint);
[Link]("Content-Type", "application/json");
[Link]("Authorization", "Bearer your_Home_Assistant_Access_Token");
// Replace with your desired payload for the service call
String payload = "{\"entity_id\": \"switch.living_room_lights\"}";
int httpResponseCode = [Link](payload);

if (httpResponseCode > 0) {
[Link]("HTTP Response code: ");
[Link](httpResponseCode);
} else {
[Link]("Error code: ");
[Link](httpResponseCode);
}
[Link]();
delay(5000);
}

Make sure to replace the placeholders with your actual network credentials, Home Assistant IP
address, API endpoint, and Home Assistant access token. This example sends a POST request to
the Home Assistant API to turn on a switch with the entity ID "switch.living_room_lights". You
can modify the payload to suit your specific use case.
Note that you will need to include the required libraries (WiFi.h and HTTPClient.h) in your
Arduino IDE to compile and upload this code to your ESP32 board.
ESP32 CONTROL RELAY BY
AMAZON ALEXA WITHOUT 3RD
PLATFORMS
I will show you how to use this a4 paper work with Amazon Alexa. And this is Amazon Alexa
application mobile phone. And also you can use the Android phone or iPhone application we will
read the code base add an ID. So let's begin to see this code. Before you have used his Amazon
Alexa library, you will need to install the library just click toy and the managing library. Because
install this library, you will not without any sort of software we're paying for. So you can just
input ESP al e XA. Just the ESP Alexa this one at this level I have already installed you can
install online after you install you can see the file example and the you will find you will find
ESP Aleksa there are many samples we can click on the basic this basic code is is very easy. And
I have changes occurred based on the basic code because we have for today. So I have printed
these formulae and this is only slowly okay we can close this and we can say this code we just
you can define the lowly IO GPIO pins and the you can see the Tiguan we have the output a 101
and a two and this way just our two i O 50 And I oh five and I oh four.

So we can just define in this please. And this is a four function callback function. And this is
SSID and the password of your load so you can change for yourself SSID and the password for
the ESP 32 module and as this is a full device name just for Relay we can set for the light yellow
light green light blue light red light, you can change your name and it will be displayed on the
Alexa application and you will use the voice country speaker for this words so you can change it
and this is the default initialize command that already is low chest off and this is a Wi Fi
connection and this is operate if the relay one and a turn off the relay one so this is the function
for the day one one pattern changed in the f1 and f2 and F three and F four oh you're seeing just
the four different output and this is for Wi Fi connection. Okay so you just the change the name
of the SSID and the password of your load and the change the name of relay so we can click
Upload now began download and after download we open toss or manage now I can press the
Reset but press and you can see this information in connection to load by the Wi Fi successfully
This is IP for this a4 pod okay now the program is running we have created the formulae. Now
we can open this application of Alexa and press the device and add the device and we can slip up
and the choose other and press discovery device. This will take about 45 seconds and just wait so
Maxa Alexa is scan and scan the device. Okay, you can find for device found.

And we'll just do next. And this is red light yellow light blue light and according that we have
named our agno ID code. So we're just the first one just step by step, setup and escape and
continue and add another set of a device scape Continue and set, Skip, continue. And the last one
set up skip. Okay, down now all lamps have added to an Amazon Alexa you can see I can click
oh no that one you can see I can click on and off like this oh and off this really and there's a lead
and off and the you know and off so I can use the voice country like Alexa tongue out. Blue
light on okay Alexa, turn off blue light off Okay, okay you can see and you can voice country
and by the Amazon Alexa speak if you have not speak you can also use your mobile phone
application for voice country but you need to speak to the mobile phone.
EXAMPLE ARDUINO CODE
To control a relay with an ESP32 using Amazon Alexa without relying on third-party platforms,
you can use the ESPAsyncWebServer library and set up the ESP32 as a web server. Here's an
example Arduino code:
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
// Replace with your network credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// Replace with your relay pin number
const int relayPin = 4;
AsyncWebServer server(80);
void setup() {
[Link](115200);
// Connect to Wi-Fi
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi");
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH); // Relay is active LOW
[Link]("/", HTTP_GET, [](AsyncWebServerRequest* request){
request->send(200, "text/plain", "Hello from ESP32!");
});
[Link]("/relay/on", HTTP_GET, [](AsyncWebServerRequest* request){
digitalWrite(relayPin, LOW);
request->send(200, "text/plain", "Relay turned ON");
});
[Link]("/relay/off", HTTP_GET, [](AsyncWebServerRequest* request){
digitalWrite(relayPin, HIGH);
request->send(200, "text/plain", "Relay turned OFF");
});
[Link]();
}
void loop() {
// Nothing to do here
}
Replace the placeholders with your actual network credentials and the pin number connected to
the relay. In this example, the relay is active LOW, so a LOW signal will turn it on.
The code sets up a web server on port 80 and defines two routes: /relay/on and /relay/off. When
accessed with a GET request, these routes will turn the relay on and off, respectively. The server
also has a root route / that will return a "Hello from ESP32!" message.
Upload the code to your ESP32 and connect it to your Wi-Fi network. Once the ESP32 is
connected, you can use Amazon Alexa to send GET requests to the ESP32's IP address followed
by the desired route (e.g., [Link] to control the relay.
MAKE SIMPLE AUTOMATION
BUT NO PROGRAM SKILL
I will show you how to use our a4 report work with that graphic program. What is this means this
is a mix of program toys. These toys not need any program skill, because this software is used by
students, maybe in school a student to use for their IoT lesson.

And maybe you have a projector for your projector you can use some easy and some simple
functions. So no you don't understand how to program and the hot write the code. I think this
program toy will help you to make some simple project for the logic country or for the smart
country. Okay, let's look at how it works. You can download this zip file and after you download
it, you unzip for this file, you will see this photo. And this mixer or software is open source and
is free and no need any money. So you can use in by yourself. And we can install this just click
this one button install. We can click and maybe because this software is made in China, maybe
you can don't understand what the word means. I just tell you this in the install the person so it
just the input and why yes. And enter and the ESP 32 Yes we use ESP 32 This mighty ESP 32
and also press Y and I don't install the ESP 8266. So I press a no as if you want to install you just
press the yes also support for STM 32. Hello. And now began to download automatically and to
install Okay, now you can stop complete, you can press any key to continue just enter. Now the
window will be closed. Now you can see this file and this exe file have courage, I want to tell
you, if next time you want to update the file, you just click this bat file, it will automatically
update your system file now with just a click because this exe file to open the software. And you
can see this is software you can choose your language differed in English. And now you can see
there are many photos This is in an output and this is the country and the recent maths and logic.
So there are many note very easy and simple like not red. But this is for when were most easy for
students to use and the sensor.

Okay, now I will tell you how to let that relate on and off. So we just use the digital right. You
can try it out. Try it out. When we dry out, you can click this code. This is adding the code. So
it's the software can convert the Tiguan and there's a note to our Arduino code, we're not needed
to write this code we just needed to try try, try and try and try. And now we'll get really one we
can look at to the Tiguan. This is really one I owe two. So I change this is I owe to this pin two
and a set to low just the tongue of the day. And we can add a delay, okay, you can see this is a
delay. So we try out and just compare this to note. And also try this again. This is no like ping to
and this time I said to hi and I can copy this note because this just turn off the relay and wait for
one second and the relay and went wait for one second at a time. Absolutely. So just loop so you
can see the code. It helped write the code convert. And now we can choose. Our part is your ESP
32 Because we use yesterday tomorrow. I know we chose this and this is component and this
time we just click Upload. It will be comprised And this upload is a follow up to the ESP 32
module okay now you can see picking right okay successfully now you can see our array this
really is off off forever second this is how to use this node to control the rate okay this is how to
control delay and now I will tell you like how to use a sensor this this is a temperature sensor Gs
18 b 20 we can detect the temperature how to use so, we can power off the connector with these
temperatures now you can see I connect with this temperature sensor and now we're power and
now we can add the temperature since we can see this is our sensor and as there are many sensor
have support like tht one one this is a temperature and humidity and we use this RTS 18 B 20.
So, we just dry out drought and we can define the temperature sensor p as you can see, this is
setting our setting. So we just change it to 30 and then you can get the temperature unit with the
o f we can click the C and we can print as a temperature sensor value on the server part. So we
can just click this and print the value and the drought and pressing this and let this connect. So
we can use a separate part. So part one printer this temperature value. So we can see this code it
can help create the code automatically and we're not needed to see the code we just press upload
and we are downloaded the firmware to the ESP 32 module okay, writing the firmware now,
you can see also the relay is one second ever one second off, and then we can press the monitor
and then you will see the temperature also is every second displays a temperature sensor, I can
hold down this sensor like this, you can see the temperature is changed the emitter it's up
temperature up and I we've all found the temperature and the temperature will be the car low this
has become law so, this is a ceremony. So, this is a value you have learned. So you can use many
logic reg if else and not and other logical function is just that you can try out drought so you can
let if the temperature quit there are value the real and it really off. So there are many options you
can use like this. And this is a test you can you can output and the list and the function and the
server part and apart we have your ESP 32 and a sensor and this step and the magnet for LCD
display and the matrix is very kinds of display and the communication you can use the eye to see
eye to see paths and the storage for the SD card and the APU and the network. You can use the
Wi Fi or use blink i o chip print and MKTG also is part. So the other many functions for IoT. For
this a4 bed you can use your mind and your ideas for your project just without writing any code.
MART BONSAI CONTROL LAMP
PUMP FOG BY KC868-A4
BLUETOOTH
I will show you how to use your mobile phone to control our A formulae powered by the
Bluetooth not Wi Fi this time we use Pluto's just like this I can turn the light I have connected a
four pod with a plant with the lamp and the pump and the fork you can see I can country by the
member waffle like these and they say the pump and also this is a fork like this and you can close
close close close. So this use my mobile phone the Bluetooth directly connected with a four part
I have installed a box you can see I removed the box this is our a4 Very controller so I will tell
you how to make this application by yourself. This is Andrew info application and a hot write the
code for ESP 32 by the Arduino ID okay let's get to it this is our a phone report have opened the
box this box installed on the thing we'll and we can see I have connected with temperature sensor
please lose your two temperature sensor Yes 18 B 20 So to have connected together it can
connect to many temperature sensor together because this have different address where to this
project I'm not use the temperature function I just tell you how to use a mobile phone country
this for today.

Now I have connected with lamp and the pump and the fog. So this will be output I have
connected with country the DC 12 What did you end a TC 24 Watch and the AC 220 Watch. So
this different relay output, how the normal are connected with the lamp and there's a pump under
the fog. So this is the handle where we have used this USB cable downloaded the firmware, we
can write the code by adding the ID. Okay, now let's begin you can download the software, the
source code after adding it and the application source code or franzis zip file our techniques part
of form and on this room you can find this topic to download this file. And after you download
you just can unzip this plot was file you can see this is added no ID source code and this is for
EPP for NGO for application. So let's first always add an ID you can open this and then you will
find this code this is a Bluetooth library and we can define is really one tool really for which I O
pin have used you can see our Tiguan and you can see this LP LP and I have five and I O four
and this is out alpha 15. So you can define this output and at this setup function or you can set
the Bluetooth This is a Bluetooth name that is searched by a mobile phone just this means you
can just like this, you can open your Bluetooth and this is the KC 868 A four Platos so this will
just read on your mobile phone. So this words is defined as this source code command. And now
you can set the really following is output worker worker mode.

And the goal to this is a loop and this is incoming what's the stream have been found the Pro
Tools we have received and we have defined the protocol for some different numbers to turn out
and atone after they just like this. If you want the new one just sent the email and if you want to
set the delay is one year off just to set the time but this not is a number this is is a stream you can
see this relate to and the first number is channel off really just this is a channel offer really and
then the second number means really well and really off if really Oh is it a one if relay off is
there. So, these two number combined for our stream to turn out and turn off rate. So, you can
see this will be understand and this is for incoming and get the first number and this is for
incoming get the second number just this is which button pressed adjuster which really want to
control and this is the value is turn or turn off just according to the value. So, this is a switch
function, just say if case one just means array one and the right has a value, right a value for
1040 Just turn on and turn off a relay. So this is digital right just let the GPIO pin become low or
become high. So this is really one little release level info just according to the relay number and
the value to turn out and turn off the relay. So this inequality is very easy, you can see just this
sentence is for the upload photos function. So we can download our press upload to our a4 pod
now is waiting for upload to this part okay, now began planning for the fo pod. The next step,
we need to make the application for NGO form. So you can see we have this MIT event. So this
use Google event just use this MIT AVP mental function. So we can just open this photo you can
see this is the source code is AIA file, and this is to lamp icon one in four of what is now you can
replace for UCF icon and not use my icon you can use your own photos, just the input to this
photo and important to the MIT FTP event, you just can click this quit application and login with
your Google account I have already loaded. So you can see I have created a project this is design
this is a UI design you can see the title and the state and the icon under the button you can see
there is a four button and this is a change to the daikon walk mode. So you can just try out as a
note to this window and you can do many functions by easily we maybe you have not
programmed skill.

So you can just DRY DRY DRY for this note for different functions for logic or for mess or for
country. So this will be really easy. So you can see we have quit some buttons on this Tiguan
you can download and the sick really just very easy just one press that button and to turn editing
off and changes a photo different photo for icon display on the mobile form. So, we can see this
design window we have placed the Form button you can say 12344 button and you can define
the image you can see I have defined the image this is a record of that effort isn't the write it off.
So the night off is this record of icon and you can also change it by yourself. You just upload that
you have all files from this window. This is a media resource or you can upload from your own
computer and your own pictures by this but and also you can like this this title you can change
this is 8684 you can change by the state. So when you implement or you can press the projector
and import the IAF just import the file this file you will display the Window menu and the UK
not needed to change anything just you can build, build as an application. Like generate an APK
file or generates a QR code. We can proceed and this will be generated the APK file online and
uploaded the APK file on the HPP mentor has called a server and that will automatically
generate the QR code just with followed. Okay, so this is generated a QR code and successfully
now you just enable your mobile phone Wi Fi or the network by the chip has scan this QR code
to download the application and the installer it, it will be quickly. And then you can see this icon,
this is the installed application before you need to use this application because we use the Pro
Tools show so you're needed to enable the Pro Tools, maybe your mobile phone is closed the Pro
Tools, so you need to open turn on the Pro Tools just click this and wait for a moment.

Now you can see this is this is a case 868 A full Pro Tools before the first time you use union to
pair this signal. Just a click. And this is pi and now is paired device. And now you can see my
mobile phone I have disabled the Wi Fi and only use the Pro Tools. So you can see that this is
only Pro Tools icon. So now I can turn on open this application. And then you can see as you see
the Bluetooth signal have found you're just a click then you can see the plot was connected. So
this time you can press the button can be used. So we're close, close, close, close. So now you
can use this controller with this mobile phone if you follow me or you environmental, no Wi Fi
no network or no load. So this is just directly connect with this controller and this mobile phone.
So you can see the send of the command is very quickly. You can see I can turn turn off turn turn
off turn off rather quickly. So here's a directory and without any network, okay, this is how to
use your mobile phone Bluetooth to control the iPhone or iPad or your Android phone.
EXAMPLE ARDUINO CODE
To control a lamp, pump, and fog machine using the KC868-A4 Bluetooth relay module, you can
use the SoftwareSerial library to establish a serial connection with the module. Here's an
example Arduino code:
#include <SoftwareSerial.h>
// Pins for software serial communication
#define RX_PIN 10
#define TX_PIN 11
SoftwareSerial bluetoothSerial(RX_PIN, TX_PIN); // RX, TX
void setup() {
[Link](9600);
[Link](9600);
pinMode(LED_BUILTIN, OUTPUT); // Lamp control pin
pinMode(2, OUTPUT); // Pump control pin
pinMode(3, OUTPUT); // Fog machine control pin
}
void loop() {
if ([Link]()) {
char receivedChar = [Link]();
// Control lamp
if (receivedChar == '1') {
digitalWrite(LED_BUILTIN, HIGH);
[Link]("Lamp turned ON");
} else if (receivedChar == '2') {
digitalWrite(LED_BUILTIN, LOW);
[Link]("Lamp turned OFF");
}
// Control pump
if (receivedChar == '3') {
digitalWrite(2, HIGH);
[Link]("Pump turned ON");
} else if (receivedChar == '4') {
digitalWrite(2, LOW);
[Link]("Pump turned OFF");
}
// Control fog machine
if (receivedChar == '5') {
digitalWrite(3, HIGH);
[Link]("Fog machine turned ON");
} else if (receivedChar == '6') {
digitalWrite(3, LOW);
[Link]("Fog machine turned OFF");
}
}
}
Make sure to connect the RX pin of the KC868-A4 module to the TX pin (TX_PIN) of the
Arduino and the TX pin of the module to the RX pin (RX_PIN) of the Arduino. Connect the
control pins for the lamp, pump, and fog machine to the corresponding pins of the Arduino
(LED_BUILTIN, 2, and 3 in this example).
Upload the code to your Arduino board and power up the KC868-A4 module. Use a Bluetooth
terminal application on your phone or computer to connect to the module's Bluetooth and send
the corresponding commands:
'1': Turns on the lamp
'2': Turns off the lamp
'3': Turns on the pump
'4': Turns off the pump
'5': Turns on the fog machine
'6': Turns off the fog machine
The Arduino will receive the commands through the Bluetooth module and control the
corresponding devices accordingly. The status of the devices will also be printed to the serial
monitor for debugging purposes.
HOME AUTOMATION USING
TASMOTA ON ESP32
I will show you a new freeware this new freeware is very powerful that can download the full a
four part just to use for ESP 32 module or ESP 8266 module, let your part will be very powerful.
You can see that I can use mobile phone open the website like this I can turn the relay one turn
now for a two and a turn Raceway and the tower will live for and also you can see this
temperature sensor one is for ESP 32 insight and another is Gs 18 v 20. Just this temporary says
what are holding the temperature since the weather is beat up just the distance is beat up. Okay,
now I will tell you how to do this step by step downloaded the firmware for your a four part now
let's look at the website of Taz moto. This is open source software freeware so I can introduce
you this is for free to use and you can change anything. Now we use ESP 32 So we can click this
just download the freeware fresh toy and the free web file will be complete.

So you can download this ESP free fresh and I have already download and also this is freeware
files. I suggest you this step police just click this and you can download it the freeware I have
downloaded this this set here to pin this file. So these two file I have download on this my
computer folder. I just click this file this is fresh and running. And you can see this toy and now
we can choose the server port and this comes through and you can configure your comport
number in your device manager in Windows window and this is where we can choose this we
have download and open and just press refresh ESP okay you can see now we can download
we're just to wait and this is a log of file output now either writing to the ESP 32 most important
you use this for a while when without read any single command code and not needed program.

Okay you can see the web service is began work. This is a Wi Fi hotspot we need to connect to
this IP. This IP is the ESP 32 module because we needed to configure the SSID and the password
afraid Lord so we can open your Wi Fi and sure available Wi Fi network. This is Taz moto. This
is ESP 32 Fs hotspot, so we can click Connect. And we can close this window and because it
helped tell us the IP address of the module, we just copied and open a new window we just copy
and open a new window and enter this IP address. So you just inputted this IP address and you
can see as this is our Wi Fi signal, this is a lot you needed to confirm for your own self load. So I
can conduct this and inputted the password of this King Kong signal and press Save. Now we
have configured the SSID and the password for your road. And we can see this is a local file.
You can see this restart and this have a new address. This is a new address for the ESP 32
module. Okay, this is Install Complete. Now we just opened this new window by this address.
Host okay you can see this is the main window. But now you just can only see the ESP 32
temperature. This is a sensor inside of ESP 32 So we needed just a car needed to configure it
configuration and configure the module and you just choose Jeep sale network That not needed
to write any code. So, we can see our Tiguan and this is our real one i o to read to i o 50. So,
we're just to read to it i i O one just a rolling one whether you actually really won and the second
50 we can find it the 50 is also is really just numbers relate to and released me is this one just IO
five and the relief for his alpha five four.
So, it can choose NCAA released three and ready for okay now you can press save and it will be
the start in family seconds, we can just click me window now you will see this is four buttons.
So, now you can click button one button two buttons and button four you can see this LED
indicator is really odd. So, this you can work by your software by PC or by your mobile phone or
can be controlled and now we can add this switch panel this is a digital input I have connected
with a digital input. So when you talk for many country also we just needed to configuration for
the switch like this configure module and the relay one I have connected with a TI one digital
input one in our statistics and the two second is 39. So the statistics yes switch switch one and 39
is switch two and we can confirm the switches 327 and 1427 Yes switch story and the plow 14
Three Four okay we can see him again. And then when you see it you can also see the
information from this log output. You can see the webisodes start under this EULA set and now
you can try to use this switch panel can see our press the key 1k 2k three okay for this moment
rework mode, you can also change the work mode for your needs. So, this is country by the
switch panel, I also connect with ts 2018 B 20. Temperature says how to use and it's also very
easy with just the configuration and Config Module. And we can find out this is our temperature
sensor have connect to is IO setting. So we just choose I also watching this line and accept that
sensor. There are many commonly used a sense, this is ds 18 B 20. So I just click this one and
you can see again and wait four seconds Okay, now you can see that yes 18 b 20 will be
displayed on this line. So this is very this is very powerful. You can see the configuration and
this configure module and this configure Wi Fi. If you have changed the SSID and the password
for another road or another house, you can just change this one. And you can use MKTG now
you're this MQ add this payload and the topic set by this this window. And this is integrate for
two metrics. This is for another second part home automation.
And for this we're just need to set our pins and this is a timer function for Schedule country. If
you want to set Sunday Monday, Tuesday, Wednesday, and you just click click click and set to
10 which is output for offer or talking or another fight or row. So you just needed to click click
click, click just to select so it's very easy, this is the fourth time and we came back and this is for
K Next, if you have can exist you can integrate the a football to your connects network this is for
address and other functions is not commonly used so you can enter sleep by yourself. So this is
me when we just can use now you can use this window by your mobile phone or by your PC
software.
EXAMPLE DUMMY CODE
To create a home automation system using Tasmota firmware on an ESP32, you can utilize
MQTT (Message Queuing Telemetry Transport) protocol for communication with Home
Assistant. Here's an example Arduino code:
#include <WiFi.h>
#include <PubSubClient.h>
// Replace with your network credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// Replace with your MQTT broker IP address and port
const char* mqttBroker = "[Link]";
const int mqttPort = 1883;
WiFiClient espClient;
PubSubClient client(espClient);
// MQTT topics for devices
const char* topicLight = "home/lights/bedroom";
const char* topicSwitch = "home/switches/fan";
// Callback function for MQTT messages
void callback(char* topic, byte* payload, unsigned int length) {
String message = "";
for (int i = 0; i < length; i++) {
message += (char)payload[i];
}
[Link]("Received message: ");
[Link](message);
// Handle message for each device
if (String(topic) == topicLight) {
if (message == "ON") {
// Code to turn on the light
[Link]("Light turned ON");
} else if (message == "OFF") {
// Code to turn off the light
[Link]("Light turned OFF");
}
} else if (String(topic) == topicSwitch) {
if (message == "ON") {
// Code to turn on the switch
[Link]("Switch turned ON");
} else if (message == "OFF") {
// Code to turn off the switch
[Link]("Switch turned OFF");
}
}
}
void reconnect() {
while (![Link]()) {
[Link]("Attempting MQTT connection...");
String clientId = "ESP32Client-";
clientId += String(random(0xffff), HEX);
if ([Link](clientId.c_str())) {
[Link]("connected");
// Subscribe to topics for devices
[Link](topicLight);
[Link](topicSwitch);
} else {
[Link]("failed, rc=");
[Link]([Link]());
[Link](" retrying in 5 seconds");
delay(5000);
}
}
}
void setup() {
[Link](115200);
// Connect to Wi-Fi
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi");
[Link](mqttBroker, mqttPort);
[Link](callback);
}

void loop() {
if (![Link]()) {
reconnect();
}
[Link]();
}
Replace the placeholders with your actual network credentials and the MQTT broker's IP address
and port. Modify the topicLight and topicSwitch variables to match your desired MQTT topics
for controlling your devices.
Upload the code to your ESP32 and connect it to your Wi-Fi network. Make sure your Home
Assistant is configured to communicate with the MQTT broker and is subscribed to the same
MQTT topics as defined in the code.
In Home Assistant, you can send MQTT messages to the ESP32 using the defined topics. For
example, publishing "ON" to the home/lights/bedroom topic will turn on the light, and
publishing "OFF" will turn it off. Similarly, you can control the switch by publishing "ON" or
"OFF" to the home/switches/fan topic.
The ESP32 will receive the MQTT messages and trigger the corresponding actions for the
devices, printing the status to the serial monitor for debugging purposes.
REMOTE CONTROL KC868-A4
RELAY WITH MQTT BROKER
SERVER
I will show you how to use this a four part remote country and by your mobile phone by free MQ
TT book, you can see this time we have used this MQ TT dashboard and I have printed this
dashboard and you can see the full icon just this folly I can tell like this right one is out and the
like this, the second and this the third and this is a first you can see my mobile phone is 4g. So
this is used by Internet and for remote country, you can use your mobile phone remote control
really going anywhere. And also we can see I have our worst which you can see I press a button
This icon is changed or press the face but this icon is changed and this icon is changed. And this
one I kind of changed. So this part now use MQ TT service, and it will be uploaded in the
message to your MKTG server. Now this project I will tell you how to do with it.

Let's look at the compute. We can see many lessons about the a4 bug you can see how to create
the Arduino ID environmental and disease I O P and this project is lesson 17 I have uploaded the
code for the Arduino ID our form just like this, we can see this is our Arduino code. Before I
explain the code, I can tell you the principle of the MKTG because the a4 part is sending the
message to the free MKTG broke you can find the many MKTG book on the internet. I just find
this hydro MQ as this one as this is the domain name and this is the port. So just let your a4 pod
send the MQ TT message to this domain name and this part but in our Arduino code service used
by IP so you can use internet COI you can input the domain name and with the code IP so you
can also you can use the ping command on the Windows command.

This is a two IP for this domain name I use this one you can see I have used this one in the
adding a cord and before you choose MQ TT broker, the server, this server maybe on the internet
so that you can remote control your relay and then maybe you installed on the Raspberry Pi in
your local network so that just using local network and critism qotd Brooke you're just needed to
find out application for your mobile phone you can search them Qt T dashboard there are many
many many application for your use. I think it's very good for and the last project we have
showed the MKT dash border this was and in this project I will tell you how to use this verse and
also you can use your mobile phone on Google player to search this MKTG dashboard and then
to download Okay, let's look at the Arduino code. So in this Arduino code, you can see this is FL
pod work with a wall switch and MKTG service if you use MQL TT you just needed to know
which is the Publish and the wishes subscribe and the publish is a switch one switch to switch
switch switch for that okay let it easily so this is this is defined the publish adjusted if you want
to tell everyone a timely tutorial is literally for just a send a message about this topic. So and if
you want to get the list it like switch one state and switch to state and the switches three state and
switch for state.
You're just justice crap switch state at this topic, you will understand the state real time state and
the state we use the yellow means off and the one means out. So it's very easy. And you can see
this code. This occurred included the library and also you include This library is for MQ TT. So
before you use it, no ID, or you need to use the library, install the library for the Pub Sub client.
So we can just input s this way just input pub s up client and then you will see this library I have
already installed, if you're not installed the first time, you're just installed online and I chose the
close and you can see this is really and the switch the pin pin number, this pin number you can
find in our form you can see this a4 form and the IRA pin define just open this topic you can see
which is array and which are the digital input for wost which I have copied on this text is easy
for us to paste.
So this is a pin define. And this pin define, you can copy the array and as a switch, you can see
just like this, this section copy to this section, and this section copy to this section. Okay, this is
Wi Fi LD I use speak, the PIP is eating defined as this way. So when the Wi Fi is connected
successfully, it will not beep and there's a power out of a four part will always peep and this is a
talking state. And you just needed to change this information of your own load and MKTG
Brooke, this is a lot of your SSID and the password. This is my office SSID and the password
you need to change by yourself not use ours SSID and password before projects. So many people
say why I can't connect with the Wi Fi because you use my SSID and the password. And this is
MKTG server, if you have your own MKTG server just replace for this IP and the port at the last
and there's a part in this way that works under the port in this way is right at it history not needed
to change and this is the username and the password because the publish because the public mkg
server not needed username and the password that you can say just only IP ended apart. So I
have read in this way the new password and the username almost not needed to use you can if
you have an empty server you must have our username and the password you can read that here
and this is a client ID or this the King County Delaware it can be replaced with your any test and
this is a publish a topic and this is describing a topic and go on this just for Wi Fi connection you
will not need to see and as I say the callback function and the just compare with the hello or or
use one. So just to turn off re or temporarily. So, this is a four channel four channel. So our
channel function is the same. And this is for many countries, just the far wall switch if you have
pressed and the delay 2200 And you can see I can manually turn off and it turns out that this for
Foundry is also in the scene. And this is already as this is for the server part monitor.
And so this code is very easy. You cannot need to see more codes. You just replace this one and
this pin our pin number and you can download it to your a4 board so we can choose to upload
now we will compare the freeware and upload to the a4 pod to the ESP 32 module how to set the
ID you can See our before projects have many details explained okay now can download Okay,
okay, enable this and apartmani Okay Is this the Wi Fi connected where the Wi Fi connected will
print the IP address of the a4 pod and this M KDT message. Okay, now after our upload is a
freeware, we can tell you how to install and use MKTG dashboard you just open a Google Play
and you can search MQ TT dashboard and we can see many MKTG dashboard. Now this time
we have used this one I have already installed, you can install the camera I just use this one. And
after you installed we just open we open this dashboard you can see this is the dashboard you can
create many lists, it has auto automatic real quick to the dashboard we can see and and as there
are many beautiful UI you can use this just for demonstration, it helps the system quit I have
created a dashboard on the kitchen. Yes, this you can try it by yourself any icon and add is a
value.
You can see this dashboard is accurate. You can see I can press this button and the you can see I
can try this test is any preparation and you just can't design design this icon by yourself. Just
okay. And before you firsthand use you need to quit the MKTG broke connection like this, just
click this I have created the broke you can create many MKTG broke just like this edit you just
created the MQL GT num name under the current ID it automatically generate and this is
actually a U N Qt T server IP we have right the IP Arduino ID and this part is 1883 and the TCP
does not need to change. So after you create the MKTG connection, then you can create the
device like I can go to this kitchen and I have created a full relay. And you can see I can press
and hold down the icon and as you can see this is the name as I say the lights and this is MQ TT
enable. And this is subscribe. This is why where the state switch one state just really one state we
have with this topic in our addenda ID and this is published this is switch one and this is switch
state. These two items you can see from the Arduino IDE and the way you set the MQ TT just
press OK. And we can sit down and edit the design we can click you can see the URL and off we
can set for the URL like this the payload the payload of because we're really the payload either
one and off the payload is yellow we have said in the Arduino ID and this is short test and this
you can change the color of the icon and this is icon this is a lamp or you can change change it to
other icon okay we can set that off we just click OK you can see this is set for the off this pillow
the fur off is zero and this is the current is changed the four hour so you just need to change the
payload for our and for off others you nuts needed to change if you want more good for the press
okay and the back to the May window and then you can create a full I comms and the UK and
the turn off. Turn off us by your mobile phone and with your own charger window. Okay, this is
how to use a full pan with full MQL TT book and make the ATP application.
EXAMPLE DUMMY CODE
To remotely control the KC868-A4 relay module using an MQTT broker server, you can use the
PubSubClient library in Arduino. Here's an example code:
#include <WiFi.h>
#include <PubSubClient.h>
// Replace with your network credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// Replace with your MQTT broker IP address and port
const char* mqttBroker = "your_MQTT_broker_IP";
const int mqttPort = 1883;
// Replace with your MQTT credentials (if required)
const char* mqttUsername = "your_MQTT_username";
const char* mqttPassword = "your_MQTT_password";
// Replace with your KC868-A4 relay topic
const char* relayTopic = "home/relay/control";
WiFiClient espClient;
PubSubClient client(espClient);
// KC868-A4 relay pin mapping
const int relayPins[] = {4, 5, 6, 7}; // Example: Pins 4, 5, 6, and 7 connected to relays 1, 2, 3,
and 4 respectively

void setup() {
[Link](115200);
// Connect to Wi-Fi
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi");
[Link](mqttBroker, mqttPort);
[Link](callback);
}

void callback(char* topic, byte* payload, unsigned int length) {


// Convert payload to string
String message = "";
for (int i = 0; i < length; i++) {
message += (char)payload[i];
}
// Find relay number in the topic (e.g., home/relay/control/1)
String topicStr = String(topic);
int relayNumIndex = [Link]('/') + 1;
int relayNum = [Link](relayNumIndex).toInt();
// Control the relay based on the received message
if (message == "ON") {
digitalWrite(relayPins[relayNum - 1], LOW); // KC868-A4 relays are active low
[Link]("Relay " + String(relayNum) + " turned ON");
} else if (message == "OFF") {
digitalWrite(relayPins[relayNum - 1], HIGH);
[Link]("Relay " + String(relayNum) + " turned OFF");
}
}
void reconnect() {
while (![Link]()) {
[Link]("Attempting MQTT connection...");
String clientId = "ESP32Client-";
clientId += String(random(0xffff), HEX);
if ([Link](clientId.c_str(), mqttUsername, mqttPassword)) {
[Link]("connected");
// Subscribe to relay control topic
[Link](relayTopic);
} else {
[Link]("failed, rc=");
[Link]([Link]());
[Link](" retrying in 5 seconds");
delay(5000);
}
}
}
void setupRelayPins() {
for (int i = 0; i < sizeof(relayPins) / sizeof(relayPins[0]); i++) {
pinMode(relayPins[i], OUTPUT);
digitalWrite(relayPins[i], HIGH); // KC868-A4 relays are active low
}
}

void loop() {
if (![Link]()) {
reconnect();
}
[Link]();
}

Make sure to replace the placeholders with your actual network credentials, MQTT broker IP
address and port, MQTT credentials (if required), and the KC868-A4 relay topic. Adjust the
relayPins array to match the relay pin mapping for your KC868-A4 module.
Upload the code to your ESP32 and connect it to your Wi-Fi network. The ESP32 will connect to
the MQTT broker server and subscribe to the relay control topic. When a message is received on
that topic, the ESP32 will control the corresponding relay based on the message ("ON" or
"OFF").

To control the relay remotely, publish "ON" or "OFF" to the defined relay topic using an MQTT
client, such as [Link] or Home Assistant's MQTT service.
The ESP32 will receive the MQTT messages and control the relays accordingly. The relay status
will also be printed to the serial monitor for debugging purposes.
UDP COMMUNICATION WITH
KC868-A8 WITH ETHERNET
I will show you how to use this Ethernet cable work with this ESP 32 module. Now we're not use
the Wi Fi work by the ESP 32 We just use the Ethernet cable and work in the lab because this is
a chip this will learn 8720 Isn't that cheap so we can use the Ethernet cable for the
communication we're more stable. Now let's look at this eight part I will use this Ethernet I work
with ESP 32 And you can see this Daguan Firstly, this is the Ethernet chip. And because we need
to define some pings in our Arduino code, this is our Arduino code and we can see this is a
terminal we have right for the UDP communication because we can use this Ethernet packet toy
send that command by the UDP to this part and this part will get the information and send it back
to our compute. So we can test with this Arduino code. Firstly you can see this is an include this
dot h file this is file is included with our new library just to install it I already have these files and
these define you just as our have let our for our this pin define you can see this is a for Ethernet
for this LAN 8720 Chip our define not to change just a copy for this define and this is state QRP
or you can set an IP in this command and the DC the local port or you can change to yours for
yourself I have used this part and this IP and this gateway and this subnet and this thing as so you
can set all this information by yourself and go out I just you can see this function we can default
set configure the sounds information is for the Ethernet and this will print if the configuration is
failed or configuration is successful. And after you connect with the land successfully, it will be
print the IP address as a local IP address and then began to UDP listener as a part we will listen
to the client to connect with this part. And then go on just go to the Loop The Loop just deal with
the package as a package received which from which remote option and the which remote part
and then began to install that package and copy the this received package to the sender path
they're sending the package so you're just the computer send it to the pod the pod and assign it to
a computer just as a thing as the information just send it to the pod and feed it back to the
compute okay, what care upload okay now again download okay complete and after complete,
you can see this network LD is pulling and the yellow is our so it's the Learn began to work we
can press this button reset I can give you see the third party information okay enable this there
are monitors and we can press this key and then you can see this configuration successfully and
you can see the IP address the part is for this IP address.
And now we can open this window for Ethernet DPAC and this is my computer IP address and
this part we have used because we have used this part lesson 4196 So we use this open and the
remote IP this IP is this part eight part ESP 32 So this is two and a two 202 upon 204 196 and we
can input test King County and then we can press send. And then you can see i press enter the
King County Center to this IP address and apart adjusted this part. This part is received King
County this not needed to see just so you can see this receives the King County and In the front
this IP This is my computer IP and the front of this port, my computer port and also it can send
back to my compute this and my compute have received from 2.2 100 This is a eight part so this
is received the phone can connect. So, this is sent to the part and the feedback to the compute is
can connect. So, this is the communication for send and receive and if I have input ABC, D and
the Send and you can see it received and sent back to the APCD. So, this is very easy just as just
a little code you can use the Ethernet communication. Okay, you can see how to receive the
package and how to send the package so you can work for many functions for the Ethernet and
for the network project.
EXAMPLE DUMMY ARDUINO
CODE
Here's an example Arduino code for UDP communication with KC868-A8 using Ethernet:
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
// Replace with your network credentials
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ipAddress(192, 168, 1, 100); // Replace with the IP address of your Arduino
unsigned int localPort = 8888;
// Replace with the KC868-A8 IP address and port
IPAddress kc868Ip(192, 168, 1, 200);
unsigned int kc868Port = 4196;
EthernetUDP udp;
void setup() {
[Link](mac, ipAddress);
[Link](localPort);
[Link](9600);
}
void loop() {
int packetSize = [Link]();
if (packetSize) {
IPAddress remoteIp = [Link]();
unsigned int remotePort = [Link]();
// Read the incoming packet
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
[Link](packetBuffer, packetSize);
packetBuffer[packetSize] = '\0';
// Print the received message
[Link]("Received packet from ");
[Link](remoteIp);
[Link](":");
[Link](remotePort);
[Link]("Message: ");
[Link](packetBuffer);
// Send a response to the KC868-A8 module
[Link](kc868Ip, kc868Port);
[Link](packetBuffer);
[Link]();
}
}
Make sure to replace the placeholders with your actual network credentials, Arduino IP address,
KC868-A8 IP address, and port.
Upload the code to your Arduino board, connect the Ethernet shield or module, and ensure that
your Arduino and KC868-A8 are connected to the same network.
The code sets up a UDP server on the Arduino to listen for incoming packets on the specified
localPort. When a packet is received, it reads the message and prints it to the serial monitor.
Then, it sends the same message as a response to the KC868-A8 module using the specified IP
address (kc868Ip) and port (kc868Port).
You can use a UDP client, such as Packet Sender or Node-RED, to send messages to the
Arduino's IP address and the specified localPort. The Arduino will receive the UDP packets,
print the message, and send a response back to the KC868-A8 module.
PCF8574 IIC EXTEND GPIO FOR
ESP32 MULTI RELAY
I will show you this really bad this is crazy 8688 It has eight channel relay output, an eight
channel relay input and the work with this ESP 32 module. This project I will show you how to
extend the GPIO port for ESP 32 The ESP 32 is more popular in your market used by many try,
but it has a little GPIO port so that we have eight channel output and eight channel input there
are not enough GPIO to use. So, we need to extend this project I will show you how to extend
and the heart use Arduino IDE to drive this output for the layout and this has to chip This is PCF
857 For that I see cheap this this one cheap is eight channel for this input and this chair is cheap
is for this eight channel output this is our use IC chip or you can see this is for extent if you have
many I see device or you can extend by this see SCL and SDA and this VCC and Ground and
this SC arrow is clock and this SDA is date. So the the IC chip have this two signal and a clock
and power under the ground. So you can extend it for many trips if not enough for each channel
for you use and then you can extend it for many different IC chip just to connect SCL and SDA
together also you can extend it for LCD display or LCD display or just use the IC chip as a pass.

So now we can use this board taking example for tell you to help drivers this relay output you
can see this is our eight part this eight part have this pin defined and in this type one and also we
have the pin defined in this form or you can click and see the details of our pin which is IC SDA
and SCL define and is a really output and input and temperature sensor and digital input and
we're list receive and Ethernet Park. So this helps all have listed the ILP but also you can exists
our website document and find out Ah Tiguan details you can see this just click and you will see
the photo and I will define you can find in this Tiguan. And now we began to tell you how to use
this really output and and also you can use this art in it. This is an idea we'll have right this demo
code and this code I will upload to our form you can download and use it directly and before to
use that you can see this really is not use the chips out directory. So we have used this PCF chip
to extend as GPIO we can just say this Taiwan and you can see this is a PCF 8574 This is for
input AC E means input channel and this is output a channel and this is the for RT and you can
see the output is connected this is a relay driver and this is eight channel per output.

So we can see the command use connector with this chip with the ESP 32. And you can see the
SDA and SCL have connected with this two line and that is also have the SD and s Sal. So if you
have managed ship, because the a one, a zero a two, we have three land, walk as the dress. So we
have many devices you can connect together as this is for output. This has SDA and SCL as is a
zero a one a two, you can see this fault This is for output. So, we have connected with a thing SD
and SEO. But for this chip, you can see this is 00 A one is zero and a two is one. So, you can see
this a su 001. So, this is 24 this addresses 24. So we can see our Arduino code, you can see this is
defined output and we can see as I said 24 This is 24 and the input if next project I will tell you
how to do the input part.
The input is this one and 010 so that the other one zero, so this is a four input, just a 22 address
for input. So now we have say this output, so we can say this Arduino code, you can include this
Arduino dot h and this GCF, it finds them for dot h, this new needed to install the library. We
can see the online library manager and we just import this PCF, PCF 8574 And I can choose I
have installed you can see this library you need to install I have installed you just installed online
just click this part and will complete the install and choose Close and after you install we can go
on and this is defined address this is a 24 I have tell you why is 24 and this It began with this
report. And then you can define this pin mode just set the P zero until p seven that's really one
way to replace me with a four and to relate as defined for output because we want to turn out and
turn off the relay and this is this preprinted this information if any issues that I see it okay just
print okay, if you first just print Okay, okay, you're not okay. So this began to loop loop which
just sets at your four year low every channel eight channel Hello. So we can at firstly to turn off
our relay and delay about three seconds and we began to turn our relay this a really high means
now. So it's really one year now really two years out and release three is and after every 300
milliseconds will be pretty long. And until really at home, we just turn off every day from really
eight to really one just two of us are we delay time swing 100 million seconds. And this code is
very easy. Just not use this GPA our directory we have used this PCF to extend the GPL so we
just refer to showered words we just use this PCF 8574 dot digital right and also dot P mode to
set the output or input now we can download it we can see the result we just upload but before
it's compressing I will tell you because when you use IC chip you need to define I have used the
NodeMCU 32 s because I have used this 32 s so you need to find out this pin Arduino dot h this
is this purse wrong your jack just can according to my purse and you will find this file and and
open this file and then you need to define this SDA and SCL. This date and clock this is very
important.
Don't remember to change this pain you need to change this p because we can see this is I see as
the end Sal is as seen as this four and five okay now let's power on our power and the USB
detect I can click upload again now it began download okay, you can see the really all the nuts
began to turn after error 300 milliseconds and also you to turn off at at our 300 and minimum
seconds. So this is a relay output and this led indicated for 1234 and 5678. And now you can see
the code is running and the other half is really out. Okay, this is how to use an ID to control the
GPIO externed by the IC chip.
EXAMPLE DUMMY ARDUINO
CODE
Here's an example Arduino code for controlling multiple relays using the PCF8574 I2C GPIO
extender with an ESP32:
#include <Wire.h>
// Replace with the I2C address of your PCF8574
#define PCF8574_ADDRESS 0x20
// Define the relay pins connected to the PCF8574
#define RELAY_1 0
#define RELAY_2 1
#define RELAY_3 2
#define RELAY_4 3
void setup() {
[Link]();
// Set relay pins as outputs
[Link](PCF8574_ADDRESS);
[Link](0x00);
[Link]();
}
void turnOnRelay(int relayPin) {
[Link](PCF8574_ADDRESS);
[Link](1 << relayPin);
[Link]();
}
void turnOffRelay(int relayPin) {
[Link](PCF8574_ADDRESS);
[Link](1 << relayPin ^ 0xFF);
[Link]();
}
void loop() {
// Example usage: Turn on relay 1 for 1 second, then turn it off
turnOnRelay(RELAY_1);
delay(1000);
turnOffRelay(RELAY_1);
delay(1000);
}

Make sure to connect the PCF8574 to the ESP32 using the I2C interface (SDA and SCL pins).
Adjust the PCF8574_ADDRESS according to the address of your PCF8574 module (you can use
an I2C scanner to find the address).

In the setup() function, the relay pins on the PCF8574 are set as outputs.

The turnOnRelay() and turnOffRelay() functions are used to control the relays. They take the
relay pin number (RELAY_1, RELAY_2, etc.) as an argument and send the appropriate data to
the PCF8574 via I2C to turn the relay on or off.

In the loop() function, you can control the relays as needed. The example code turns on relay 1
for 1 second and then turns it off. Adjust the delay time and relay pins according to your
requirements.

Upload the code to your ESP32 and ensure that the PCF8574 is correctly connected. The ESP32
will control the relays through the PCF8574 using I2C communication.
PCF8574 IIC EXTEND GPIO FOR
ESP32 INPUT PORTS
We have used this relay output for this eight part because we have used pcf. It 547 for ship
external ship show this project I will show you how to use this input part because this input part
also use this PCF chip because this ESP 32 Not enough to allow for use too much relay output
and the input. So we use use the PCF. It finds them for cheap to extend the relay and the input
part. Also, let's look at the added ID. Let's look at this eight part and we will use this demo code
Arduino ID I have read this code and I will tell you how to works.

Also UK included the Arduino dot ash and this library we have installed online in last project I
have told you how to install and this is a PCF chip that I see address this address you can see we
have this Tiguan online and this chip is a four layer output and at this time we always say this
chip because we have used this to chip this chip in for input and this we can see a zero a one a
two and you can see and you can see this photo and a piano is zero and a one is three but that
means one that is one and a two is ground that means there are no So, this role they allow one
zero that address is 22 addresses 22 So, we have used this code this we have said to 22 and use
this 22 And also we have used the server began with this language and the delay and define this
our channel is input the relay is for output the input channel is used by input state and as we print
if an issue is okay that means print okay if first print Kayo and this is define a value for need is a
pot from input one input the two and in produce three at the input of four until input eight.
So, if the value is low, so, the third point will be key pressed key one pressed onto your key eight
pressed and they said get a tan and a for loop and this stupid very I think you can see this code
will be understanding easily and now we can download we can power this is PowerShell and this
will really is running because I have the coder installed in the ESP 32 We can download through
this compact and upload working for the company this code is normally Anton after the last time
the last project I have downloaded to the ESP 32 module okay now again Download Now, we
can open this reminded and I can give you this but best yet and the Kalia output this is for initial
okay, I can clear you can see I use my twice and this is ground and this is Channel One to
channel eight you can see I can shoot for this ground with this channel you can see a key it is
pressed. So, this is channel eight as I said channel one. So, if I shot grant will channel one the
input you can see key one is pressed and shot for this input two key to impressed. So, this can
detect the input or detect the input or you can use this input a country as a relay for output for
many the country connected with the switch panel is according to your code was the function. So
this is very easy to detect which key is pressed and now you can add the code as as this section is
make many functions.
EXAMPLE DUMMY CODE
#include <Wire.h>
// Replace with the I2C address of your PCF8574
#define PCF8574_ADDRESS 0x20
// Define the input port pins connected to the PCF8574
#define INPUT_1 0
#define INPUT_2 1
#define INPUT_3 2
#define INPUT_4 3
void setup() {
[Link]();
}
void loop() {
// Read the input port values from PCF8574
[Link](PCF8574_ADDRESS);
[Link](PCF8574_ADDRESS, 1);
byte inputPorts = [Link]();
[Link]();
// Example usage: Check the status of input port 1
if (bitRead(inputPorts, INPUT_1)) {
[Link]("Input Port 1: HIGH");
} else {
[Link]("Input Port 1: LOW");
}
delay(1000);
}
Make sure to connect the PCF8574 to the ESP32 using the I2C interface (SDA and SCL pins).
Adjust the PCF8574_ADDRESS according to the address of your PCF8574 module (you can use
an I2C scanner to find the address).
In the setup() function, the Wire library is initialized to communicate with the PCF8574.

In the loop() function, the input port values are read from the PCF8574 using I2C
communication. The [Link]() function starts the communication with the
PCF8574, and [Link]() is used to request the input port values (one byte) from the
PCF8574. The received value is stored in the inputPorts variable.
The example code then checks the status of input port 1 by using the bitRead() function to read
the specific bit from the inputPorts variable. If the bit is high, it prints "Input Port 1: HIGH";
otherwise, it prints "Input Port 1: LOW".
You can add additional checks to read the status of other input ports (INPUT_2, INPUT_3, etc.)
by using the same approach.
Upload the code to your ESP32 and ensure that the PCF8574 is correctly connected. The ESP32
will read the input port values from the PCF8574 using I2C communication and print their status
to the serial monitor.
KC868-A8 ESP32 ETHERNET
WORK FOR HOME ASSISTANT
I will show you how to integrate this eight part with the home assistant so that you can use the
ESP home to integrate this part will be easily before we will make a full board integrate with the
home assistant by ESP home already but that is used by Wi Fi this time I will show you how to
integrate by the Ethernet used by the ESP home for home assistant.

Okay let's look at the home assistant. This is our dashboard for home assistant we have used for
the team and this time we will install the ESP home firstly so you can go to the supervise and add
on store we can search the ESP home with just input ESP and you will find this add on in ESP
home click this and click Install and now we're installed online downloaded the ESP home and
install it okay now you can see this Install Complete. Now we can enable this button that can
show in slide this will be heavy as SP home and that we can click Start enabled and now we can
click the ESP home you will see this worker information and we need to add a note we can click
this edit node and you can look at your name like it and this is a Wi Fi SSID enter the password
just input your laws okay connect as this is your information this is my office road SSID and the
password and then next we have used ESP 32 This is a USB 32 So, we can choose this one and
next and close and then you will see this is ah perfect this color is red, the red that means in is
offline because we have not configuration for this device. At this part we have used the chip shall
extend so we can see as I said before the internet and this is for digital input and digital output.
So, this project I will take the example for how to control one relay output by the Ethernet. So I
will tell you the easiest way to configure this route.

So this is PCF 8574 this chip is for extend the chip child and this is for the internet. And before
you can configure the ESP home. So you can see we have used this trip I extender. So how to
configure this is the information you can see the important thing is you need to define the
address because the IC chip have adjust and this number is zero. That means really one really
tool release really means number 01234 Just enter the mode output because we use for the delay
so as a single use output, if you use by the switch panel just to choose for input and this is a chip
or for extended the layout to put an A you can also need to see as this isn't yet because we have
used this in a chip that is Lan 8720 This is even a trip this international we have choosed also can
integrate to the ESP home. So the ESP Ethernet component it has already support. This you can
see the type is the length 8720 So this is the part we just defined this pin this pin this pain,
according to our Tiguan so you can directly to use this ESP home with the Ethernet and also set a
static IP and the gateway and this subnet. And this these two you need to see the document firstly
and then we began to configure it with just the can edit. And the you can see this is the same
information when you turn replace. And this is set for the ESP 32 at the money for configuration.
So you can see in our form, or you can find this lesson 21 Isn't that to work with home assistant
by ESP home.
You can click And then we have already writes the configuration at here. So you're just a copy
that will be easy you just copy and paste and I have changed the name to you need to change this
static IP and the gateway and a subnet because in my compute my IP is the one from one so you
can change to your lat by yourself this I have set a static IP for the eight part you can change it to
200 either to remember and this is a gateway and save and install. So now we will use this USB
cable the USB cable are found the ESP eight part and a connector with this Raspberry Pi or USB
so we can connect to this part and this cable from this and the power arm for the eighth part and
now we can we use the USB cable so we chose this one I buy the USB to the server and this is
the device have detected the USB and click it began to download now we just have to wait now
is began to read fresh Okay, now is successfully you can see this information output you can see
this is the address we have set and the hostname and many information successfully displayed so
we can click stop. And now you can see this color is become green. Now we can click ESP
home.
Now we can click Configuration and integration and you can click the device and click eight you
will see the entity is magically generate this letter one you can see I can turn off and then turn off
but you can see this is the opposite you can set the configuration to change the state. Now we can
just add to the love lens just to edit to the dashboard and last one and added to UI and now we
can go to click overview or you can see this is the light we can use this set invert to adjust the
state because now is opposite we can copy and just paste just a ESP home and add it and this is a
number and we can let the invert Sure. So this number one is for this chip number one you can
use the replace the one that means relate to we can set to the true that we can save and install up
either USB download or overwrite it the second time you downloaded the firmware will be
quickly then the first time Okay, now it's complete, we can click stop and wait to form and this
will become green is online. And now you can good dashboard and you can see the switch record
this is turn red and off is turned off.
So this is state correct off off. So now you can remove this USB cable this cable just used by the
download of fresh ware and you can remove this USB cable so that the eight part is working by
the Ethernet. So you can see I can use this home assistant and the tongue off. Off off. So this is
right. It's working fine.
EXAMPLE DUMMY CODE
Here's an example Arduino code for controlling the KC868-A8 relay module with an ESP32
Ethernet connection for Home Assistant integration:
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
// Replace with your network credentials
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ipAddress(192, 168, 1, 100); // Replace with the IP address of your Arduino
// Replace with your MQTT broker IP address and port
IPAddress mqttBroker(192, 168, 1, 200);
const int mqttPort = 1883;
// Replace with your MQTT credentials (if required)
const char* mqttUsername = "your_MQTT_username";
const char* mqttPassword = "your_MQTT_password";
EthernetClient ethClient;
PubSubClient mqttClient(ethClient);
// KC868-A8 relay pins
const int relayPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
void callback(char* topic, byte* payload, unsigned int length) {
// Convert payload to string
String message = "";
for (int i = 0; i < length; i++) {
message += (char)payload[i];
}
// Find relay number in the topic (e.g., home/relay/1)
String topicStr = String(topic);
int relayNumIndex = [Link]('/') + 1;
int relayNum = [Link](relayNumIndex).toInt();
// Control the relay based on the received message
if (message == "ON") {
digitalWrite(relayPins[relayNum - 1], LOW); // KC868-A8 relays are active low
[Link](topic, "ON");
[Link]("Relay " + String(relayNum) + " turned ON");
} else if (message == "OFF") {
digitalWrite(relayPins[relayNum - 1], HIGH);
[Link](topic, "OFF");
[Link]("Relay " + String(relayNum) + " turned OFF");
}
}
void reconnect() {
while (![Link]()) {
[Link]("Attempting MQTT connection...");
String clientId = "ESP32Client-";
clientId += String(random(0xffff), HEX);
if ([Link](clientId.c_str(), mqttUsername, mqttPassword)) {
[Link]("connected");
// Subscribe to relay topics
for (int i = 0; i < sizeof(relayPins) / sizeof(relayPins[0]); i++) {
String relayTopic = "home/relay/" + String(i + 1);
[Link](relayTopic.c_str());
}
} else {
[Link]("failed, rc=");
[Link]([Link]());
[Link](" retrying in 5 seconds");
delay(5000);
}
}
}
void setup() {
[Link](115200);
[Link](mac, ipAddress);
[Link](mqttBroker, mqttPort);
[Link](callback);
for (int i = 0; i < sizeof(relayPins) / sizeof(relayPins[0]); i++) {
pinMode(relayPins[i], OUTPUT);
digitalWrite(relayPins[i], HIGH); // KC868-A8 relays are active low
}
}
void loop() {
if (![Link]()) {
reconnect();
}
[Link]();
}
Make sure to replace the placeholders with your actual network credentials, Arduino IP address,
MQTT broker IP address, port, MQTT credentials (if required), and relay pins connected to the
KC868-A8 module.
Upload the code to your ESP32 and ensure that the KC868-A8 module is connected to the
corresponding relay pins on the Arduino. The ESP32 will connect to the MQTT broker server
and subscribe to the relay topics. When a message is received on a specific relay topic, it will
control the corresponding relay and publish the status back to the topic.
In Home Assistant, you can control the relays by sending MQTT messages to the corresponding
topics ("home/relay/1", "home/relay/2", etc.) with payload "ON" or "OFF". The ESP32 will
receive the MQTT messages and control the relays accordingly, and the relay status will be
published back to the respective topic.
WIFI REPEATER USING ESP32 BY
KC868-A4 A8
I will show you how to use the ESP 32 module make a Wi Fi repeat. Now we can use this case
868. a four part also you can use a eight part because we just use this ESP 32 module. Sometimes
your house is very big and there's a Wi Fi thing that is not very well and is you have only one
route and this time I will show you how to use this ESP 32 module make a Wi Fi repeater so that
in our room you have put to this part and you can generate the Wi Fi signal for your mobile
phone or your computer to use.

Okay let's begin how to do with it. We can see this is our a four part also we have the eight part
because we have used the ESP 32 And this is a lesson 21 how to make a Wi Fi repeater you the
ESP 32 Actually you can also use the ESP 8266 Chip is Auto support. We just needed to prepare
for this download Tor and load freeware as this tool file. Just click this website to download it.
Download it for profit the ESP Wi Fi module, you can click this reg downloader to download the
for the Windows worsen. And if you have used Apple Mac, you can download as a
corresponding verse from the website. And I have downloaded this file and this file downloaded
from our website. This is a framework. So you will find you have this to follow and download
will use this to follow you just firstly to open this file or this download at all. I prefer download
the tool open it you can connect the power of the port and the USB connect to your compute.
So we can double click and you will see as this is a logo file. And in this window, you're just
click ESP 32 If you use ESP 8266 You can choose this base one. Now I chose this one. And in
the work mode, choose the development and press OK. And then you will see this window this
window you need to load freeware and we can click this file to open we can go to this load zip
file you just unzip and go to the build. And the first step is a pot load. Click this but Hello but
load being open. And the second you can choose the second ESP 32 Being fell open and the third
eye you chose this one example and you can click the checkbox of this items. And this one you
need to input an address. This address is an address where you can say okay I have read this
address. The first one 0x one solid and the second is 0x 10 solid and then three is 0x H solid.
Okay. And this compact just you use the USP of connected is the third part I have used the
comm seven. This according to your computer you can see the Device Manager on your
Windows you can find out which Konka part you have used. And now we just click the start will
be began download. And this settings just as the default not to change anything. Just click start
and now began to download. And as this is output the log file we just defined which is progress
until finish. Okay, now he is finished. We just can close this window and then you can let the
board power off and the power arm and we can look at this Wi Fi signal and you can see this in
my Wi Fi because I have used this module. The default is ESP 32 You will find a single means
ESP 32 We can connect with this Wi Fi signal. Okay when you're connected, you're just open
this IP address that your foot is 4.1 is a 4.1 Because I have used this module before. This is very
important. To get your foot in ESP So to begin with SSID is your signal. Now the relay is off
because the freeware different have used this our chips our pins, we're just not needed to see it.
And in this form this website, you're just set this SDA setting. This is the for your first load, just
your house load the main load as this in my office King County and this is the password you
need to set by yourself and you can press Connect. Then the ESP 32 module will connect to this
main load and is this AP settings that means this Wi Fi SSID for your mobile phone or for your
PC to use. So you can change this. This I have set this in my Wi Fi you can also change ESP 32
Wi Fi and then the password is 123456 and the press set and which report and you can see this
spread this ESP 32 Wi Fi I can click this new signal and connect and now is connected so I can
input a [Link] you can see as the website is opened and This Is Us Internet by the ESP 32
module. So now you can you can see I can use my mobile phone and also use the fit and the Wi
Fi. You can choose the ESP 32 Wi Fi and the night connector with the ESP 32 Wi Fi and also I
can use a web part. Open and you can see this website this website is opened by the internet from
the ESP module.
EXAMPLE DUMMY CODE
To create a WiFi repeater using an ESP32 and the KC868-A4 or KC868-A8 relay module, you
can use the ESPAsyncWebServer and ESPAsyncWiFiManager libraries. Here's an example
Arduino code:
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <ESPAsyncWiFiManager.h>
#include <SoftwareSerial.h>
// Replace with your network credentials
char ssid[40] = "";
char password[40] = "";
// Replace with your KC868-A4 or KC868-A8 relay module settings
const int baudRate = 9600;
const int kc868RelayPin = 2;
SoftwareSerial kc868Serial(12, 13); // RX, TX
AsyncWebServer server(80);
void setup() {
[Link](115200);
[Link](baudRate);
AsyncWiFiManager wifiManager(&server);
// Uncomment to reset WiFi settings
//[Link]();
// Customization options
//[Link](IPAddress(192, 168, 4, 1), IPAddress(192, 168, 4, 1),
IPAddress(255, 255, 255, 0));
//[Link](180);
//[Link](10);
// Set callback to save custom parameters
[Link](saveParamsCallback);
// Initialize WiFi and connect/reconnect if necessary
if (![Link]()) {
[Link]("Failed to connect and hit timeout.");
delay(3000);
// Reset and try again, or maybe put it to deep sleep
[Link]();
delay(5000);
}
[Link]("Connected to WiFi");
// Start the server
[Link]();
[Link]("Server started");
// Setup the relay pin
pinMode(kc868RelayPin, OUTPUT);
digitalWrite(kc868RelayPin, LOW); // KC868-A4/A8 relays are active LOW
}
void loop() {
// Handle any incoming client requests
[Link]();
// Check if there's any data from KC868-A4/A8 relay module
if ([Link]()) {
char relayData = [Link]();
if (relayData == '1') {
digitalWrite(kc868RelayPin, LOW); // Activate the relay
} else if (relayData == '0') {
digitalWrite(kc868RelayPin, HIGH); // Deactivate the relay
}
}
}
void saveParamsCallback() {
// Get and save custom parameters
strncpy(ssid, [Link]().c_str(), sizeof(ssid));
strncpy(password, [Link]().c_str(), sizeof(password));
[Link]("Custom parameters saved");
}
Make sure to include the required libraries (ESPAsyncWebServer, ESPAsyncWiFiManager, and
SoftwareSerial) in your Arduino IDE to compile and upload this code to your ESP32 board.
In the code, replace the placeholders with your network credentials and configure the custom
options if needed. The relay pin connected to the KC868-A4 or KC868-A8 module should be set
as an output, and the relays are active LOW.
Upon power-up or when the ESP32 fails to connect to the configured WiFi network, it will
create a WiFi access point (AP) for configuration. You can connect to this AP and configure the
ESP32 with the desired WiFi network. After successful configuration, the ESP32 will attempt to
connect to the WiFi network and start the server.
The server will handle incoming client requests, and any data received from the KC868-A4/A8
module via the SoftwareSerial connection will be processed. If the received data is '1', it will
activate the relay by setting the KC868 relay pin LOW. If the received data is '0', it will
deactivate the relay by setting the KC868 relay pin HIGH.
This code acts as a bridge between the WiFi network and the KC868-A4/A8 relay module,
enabling WiFi control of the relay using Home Assistant or any other device on the network.
LED STRIP FOR HOME
ASSISTANT
I will show you how to integrate this LD strip. With this case 868 a four port, we can use ESP
home running the home assistant on the Raspberry Pi four and also you can use eight port I just
take project for example for this a4 bug, okay let's look at the first is the hardware we have
choose this LED strip that means the chip is w 28 and 12 b this is the early strip and the first we
can see the interface you can see I just only have three lines this red is a five watt power supply
and the white is ground and the cooling is a signal we can see the strip have two sockets for male
and female. So we can easily two analysts to connect with a four part and you can see the every
LD have a four pin or you can see the LD have this four pin that means the ground and the power
and the E and A T out this is input the signal is T and this is the out directories. This input and
this is output output for Napster the second one is T and the date I sent it to this LD and this LD
will send to the next LT so we'll go around with this strip. The signal sent into this one and a two
second one and a two cylinder one and two fourths. And on to to the last one. So the signal is
sent from this directions. So strip we only can use this as real lines.

So where are we very easy. And now you can see this is our a4 pod and this a4 pod will have
used this socket or you can see this socket for two years 18 B 20 temperature sensor as this is s
the signal is found the socket to the ESP 32 module. So and this is grown so we can use this S
and the current you can see I have used this as part with this thing is green and this ground is
with LEDs strip is the white and because this LED strip need large power supply, so I have used
I extend use this extend the power supply for the LED strip the power sprang how to choose I
will tell you later so you can see I can connect with this socket I can connect it together with this
socket and then you can see the fan what the red goes to this one and go to this power supplies
five watt This is red for five watt and this black this bracket is grown from this power supply and
this grant is connected with this white hill for the LED strip. So this is the power supply for the
LED strip and the connector with a signal for the a4 pod and this is a USB cable have connected
with this Raspberry Pi. As you see let's verify this I have used the four of us and you can ask you
the Raspberry Pi three and this raspberry pi power supply and the USB cable have connected
with this a4 pod This is me USB connected together because we needed to download as the ESP
home firmware from the raspberry pi and this is the power supply 12 Watt for a full pod so I can
connect with this.

Extend the power and you can see as a red LED is okay let's look into the computer. This is the
ESP Home app before we configure the ESP home we can see this our form I have read some
information about the hardware you have to choose power supply. You can see the first we have
used the chip the module is w 2812 B where we choose this chip because you can find the ESP
home you can search the first LED light in this Quick Search section. And then you will find this
is the part the ESP so part of this chip or the chip. So this is have wrist this is part this our chips
are with LD strip and you can choose a just these two items. It commonly used, it's cheap and
readily easier to pay for an online store. So, I introduced you use this one or this one, we will use
this one this is the new version and back to this page and the when we choose this chip and have
this trip, you can see every LD have RGB colors, you can see this is a strip, I have another strip
you can see this is LD indicate a but the RGB LD indicate that included the arc is red and that
means green and B means blue three LD is inside all in one.
So it will ticks the current. So we can see this is a current for air and B air will color is 20 minute
and 20 million pound 20 million pounds. So the totally one LDS indicated were cost six 60
million pair. So if you use one meet this I have used the one meet the way meet will help totally
helps certain LD that means this is a 123456 and the last one is a soti so I have totally how 30
LEDs so if you use one meet have certain LEDs you can burn the air district by yourself. So it it
will cost everyone is 60 million pair and if you have certain LEDs that totally will have this 1.8
M pair so you can choose the DC five watt, two amp power supply just to quit than this 1.8 and
paired is okay and if you have used the 10 minute as LD any meet any lens you will use 300 args
so that's the current tool cost 18 M pair so you can choose a larger than ATM pair the power
supply and if you have the LED strip any lens you just needed to cut like this according to this
slide and the LG will be disconnect. So this is the right way to cut to the LED strip. So this is a
hot mix LED strip as your size. Okay, so this is how to choose the hardware and how to choose
the LED strip and that connects to the a4 but now we can power we can connect to these powers
prior to the socket. After we configure the hardware. Now we begin to configure the software of
the ESP home. You can see I can go to the home assistant and click overview. That is nothing
and the first thing you need to install the ESP home on your supervise. And the you can see the
add on store. You just choose the ESP home to install I have installed so I just to click the ESP
home. And the first I needed to add a node click add a node and in the name or you can see I can
input LED strip. This is a name that is a Wi Fi SSID is your routers at the end of the password.
Important yours not important my SSID and the password and press Next. And this time you can
choose the module you have used. We have used the ESP 32 for the a4 board and which was this
icon and press next and configuration create and choose a close and now we can click the Edit
because this is offline. So this is the read we can edit and you can see this is a configuration
deferred. We have configuration have configured our form.
You just copy and paste so will be very easy to use this for ESP home config. So I can copy and
paste I can delete all delete and paste and I will tell you why is configuration as this content. And
this is named ESP home at the strip certi and is a brand for ESP 32 And as a part of ESP 32 The
relevant part and this is Wi Fi the SSID and the password. This needed to write down at For your
load, not input as my Wi Fi SSID and the password. And this is HC mode, if the ESP 32 work as
AP murders that will be displayed as the SSID the hotspots and there's a password. If you do not
need to use the API, you can delete it also in no problem. And this is enable the logging output
and this API for configuration for horses into the password and OTA that for update we just for
example, just a very easy password or input one and this enables a web service. So you can open
your web browser and the two countries that are the strip, this is the default port biser it he and
this is a light for the LED strip this important assumptions about these sections depend for fast
clocks, because we can according to this ESP home, this example for configuration for light just
the pen for and the chip will have used ws 28 and 12 B just the input to the trip and this pin is pin
that means we have connected with the ESP. So there are two ways this trip we have used the
GPIO setting. So this we can see the Tiguan we have connected this I also think I was 30 mins
this part this part of the I also think and there's a next the LD number as it is 30 because we have
used one meet or you can see we have used one meet so I can I have calculate the LD is a maybe
you have used a certain one so they do so this will just actually how many LD you use just
configuration with your correct the number of the LD and this is the RGB od this RGB od that's
you need to input the bid the configuration as a default this is P Archie this is wrong I have test
listen can't work correctly.
So this is input to be just the input to the Erica the seconds and the name will display on the
home assistant we can input the light strip comm slash a four and then you can input a Pio name
by yourself and the effect the effect that we have defined the same effect that is encoded by the
home assistant for the ESP home. This is seven style. If you want many styles for effect, you can
see this effect just a click and then you can see the light effects is a pause effect and is a leading
effect and effect many many many effects. So it's more than seven styles I have for example so I
have read the seven configure the CMS styles I will show you the results and how it all works.
And after you configuration for all information you just press a safe and press install and this
time you can choose this one because we have used the USB cable from the Raspberry Pi to
download the freeware so we can choose this via USB to the server the server give the Raspberry
Pi and the click and this default have detected the USB when this step you must need to connect
the USB cable and 12 watt and click and now began to download the first time needed to link in
the library and make can pray the files for download. You just need to wait for a moment now is
the last step in the linking to generate the freeware okay now began to waiting. Okay you can see
this downloaded successfully. And this is a log output. You can see we have this information for
the address and this is a four part IP address is this one 1.240 And the conductor's successfully,
okay we can close press a stop. Then you can see as this LED strip, the red is become green so
that means online. So we can choose the configuration and the integration and you will find that
ESP home will have entity ID general It can click and you will see this LD strip a4 is generated.
So we can just click the overview and add to the dashboard and enter the card. And we can
choose any card or we can choose this entity ID a for this trip as I say for this trip, and the safe,
kinda you can see close and you can see okay, now I can let the district extend or you can see I
can turn off and turn on and change the brightness. And the change of the brightness. And the
you can change the color red, I just click red, and green, and blue. And any other cluster as you
use your mouse click on the this menu. And this effect, we can choose this now because we have
set a salmon style. So I can click the rainbow. One the rainbow effect, you can see the color were
changed as the rainbow and the second can change to this one. This will be follow the early will
be follow. And this really skin I can click the Scan, you can see this is scan according the early
strip is a good tool. And and back to the first this is scan.

And also how many styles are you just click by yourself many styles and you can control any
LED strip. So this you can change it by yourself easily. And this is a beta PC software on the
home assistant that I will show you the mobile phone as you see my mobile phone or home
consistent application. So we can click and the you can change the brightness. Or they can
change the brightness and the change of the color red. You can see become red. And I can
control the brightness to the max. Now because I have a click the rainbow, click now. And you
can see I change it to red and green and blue. And any adjusted check, click and click and click
and close and open. So this is a country panizza Mobile phone application. And we have come to
the wishing for the web servers. Because we have used we can input as this is our web service
because we have configuration on the ESP home. You can see this added we can configure the
web service for this point. So we can use the web bar open this IP address you will find this a
four. And you can click toggle on and off and toggling on and off and click on so you can
country this district by the websites. This just a demo for on and off. This is by the HTV
command. If you want many country many command you just click see ESP home web API, let
for the API document will have many commands that you can you can use for the HTTP server.
So this is how to use a web service and this is sp home by the home assistant.
EXAMPLE DUMMY CODE
To control an LED strip using Home Assistant, you can use an ESP32 board and the FastLED
library. Here's an example Arduino code:
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <FastLED.h>

// Replace with your network credentials


const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// Replace with the number of LEDs in your strip
const int NUM_LEDS = 60;
// Replace with the GPIO pin connected to the LED strip data line
const int DATA_PIN = 4;
CRGB leds[NUM_LEDS];
AsyncWebServer server(80);
void setup() {
[Link](115200);
// Connect to Wi-Fi
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi");
// Initialize FastLED library
[Link]<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
// Setup server routes
[Link]("/", HTTP_GET, handleRoot);
[Link]("/color", HTTP_POST, handleColor);
// Start the server
[Link]();
[Link]("Server started");
}

void loop() {
// Handle any incoming client requests
[Link]();
}
void handleRoot(AsyncWebServerRequest* request) {
request->send(200, "text/plain", "Hello from ESP32!");
}
void handleColor(AsyncWebServerRequest* request) {
if (request->hasParam("r") && request->hasParam("g") && request->hasParam("b")) {
int r = request->getParam("r")->value().toInt();
int g = request->getParam("g")->value().toInt();
int b = request->getParam("b")->value().toInt();
// Set all LEDs to the specified color
fill_solid(leds, NUM_LEDS, CRGB(r, g, b));
[Link]();
request->send(200, "text/plain", "LED strip color set");
} else {
request->send(400, "text/plain", "Invalid color parameters");
}
}
Make sure to include the required libraries (WiFi, ESPAsyncWebServer, and FastLED) in your
Arduino IDE to compile and upload this code to your ESP32 board.
In the code, replace the placeholders with your network credentials, the number of LEDs in your
strip (NUM_LEDS), and the GPIO pin connected to the data line of the LED strip (DATA_PIN).
Upon power-up, the ESP32 will connect to the specified Wi-Fi network. The code sets up a web
server on port 80 with two routes: "/" and "/color". The "/" route simply returns a "Hello from
ESP32!" message.
The "/color" route handles POST requests with parameters "r", "g", and "b" to set the color of the
LED strip. It extracts the RGB values from the request parameters and uses the FastLED library
to set all LEDs to the specified color. The updated color is then displayed on the LED strip.
To control the LED strip color, send a POST request to the ESP32's IP address followed by the
"/color" route. Include the RGB values as parameters (e.g.,
[Link] for red color).
The ESP32 will receive the color request, update the LED strip color accordingly, and send a
response back to the client.
With this setup, you can integrate the ESP32 and LED strip with Home Assistant by creating a
RESTful API or using the Home Assistant RESTful API integration to control the LED strip
color.
TELEGRAM CONTROL LAMP
ON_OFF WITH ESP32
I will show you a solution that you can use Tarik one application not use your cursor and I can
come across what you can control that case 868 A 4.08 bought by ESP 32 You can see I can like
this, this is my title Gwang Terracon AP application and this is my a4 pod and you just send it a
test LDL and early off but also you can change this light such as I can send LDL Tarik one will
feed back this state and is ramp it out. I have used the release one connect with this lamp for
country on and off.

So if I send a command really off just an agonist type of the message led off that LED will be off
also if you can remote search the state like just as input slash State Senate this state LD will off
that will be filled back as this is remote country you can use internet UK in the world in any way
you can remote country you're a full part and really output as this I have tickets project for the
demo for country project one you can change the code of country and follow the tourist will live
for and also this part is a four and this part is eight. If you can use my code, you can also
integrate with HTTP redirect controller if you use this relay controller such as 60 channel so they
do channel HGN. Unfortunate twitching, just to use our this ESP module voice module you can
download is a freeware to ESP 8266 module, you can support that Tiguan to country I will relay
output remote without any cortisol or just use telecoils cursor. Okay, let's look at how to deal
with it. As this is our computer, you can see I have posted the guide to the ACRS Smart
Controller form room. And it totally helped six step we can zoom out you can see the six step or
you can country by the telecon. The first step is you can quit kind of our looked, you can see this
is a form that is a port this a little bit as is a chat with you. And it's a bridge for telkwa and as
your pod, so we can first acquit the robot. So you can just open your telecon and the search
search for slash and the UK input both Farah you can just a global search a global search you
will need to input the slash on the first and you can search because I have already added this both
further. So you can click and I have used before and created a loop.

And then you can fully in the window that you can must click Start but because I have already
start when you knew the first time use, this is a start but I just click or I can input slash and the
SG AR t that means the robot start. Okay, that's that that will feed back what you need to do.
And there's a first you need to create your new load because this portfolio is for everyone to use.
So you need to create your private robot so you can press new pot new bot because I have
already have a new bot. If you have a new bot, you can choose a name you can choose a name
such as KC 868 A for understand okay, it's feedback good. Let's choose a username for the load
okay you can also choose k c h six eight a four and and must be Oh chi poach. So I can use B, o,
t, and sent okay, it's displayed as the username is invalid. So we can change our one. Like really
A four B O T, or like this, the CBOT is a big, okay, send, okay, or you can say congratulations,
you're new but have quit. So this message is important, you need to receive this message, you
can see we have download step three. And now the Liberty has cracked successfully, and we
need to receive the talking and the name. So we just save this information. And now you need to
get your chat Id use ID.
So also you can in your telegram and the search will come back and press Search slash it pot. Or
you can see you can use the group of search IDPH I have added just this there you can input if
you can't search, you can just click this link by your smartphone. And you can input a slash get
Id like this, okay input get ID, this is my ID as a feedback. So this is two information we have
important for us this, this one is ID and the prefer is this one. So we can copy this information
and send it to our compute. Now you can see this is another paid we have copied from our
mobile phone. And this is talking and this is talking to important and it is in my chart it Okay,
now we have done the fifth step. And now we can prepare an Arduino IDE. And you can
download the library and the source code from this link I have prepared for you or you can
download. And after you download you will find this two file. This is the source code. And this
is the library when you to install the tool library. This one is Robert library. And another is the
JSON format library or these two library. The first library, you're just go to Sketch and the
included library and add a zip file. Just you can open your Arduino IDE. This this file ID is open
this one. And you just scratch and include library and added a zip library and choose this zip file
to install the library. That will be easy. And this is step b install the library and your step c install
Arduino Chancen library. Also you can go to a scratch include the library and Menu Manager the
library online, we can search this one we can copy and scratch and install library and managing
robberies. And this will get input the level name. And then you can see as this is a file I have
installed, you just install online. And this is the new year's version. After you install this library,
we can go back to the webpage installed and open the source code and replace the SSID
password and the chart Id just only these three items, you can see this is SSID and this is a
password. And this is talking and this is chat ID. So this is a logger of yourself SSID I can input
the Khinkali you will not input my SSID and the password ask yourself and there's a talking this
talking you can copy this string and copy and paste paste and the chat ID the chatter ID you can
see this is a number this is for you chart. And if you have a second person or the third person,
you can add as a multi chart ID so that only you can country that really enough. Okay, because
this is the pin of the I O two because we have really good tips on how to renew one you can
change by yourself. So I don't know that needs to change just You can see the information in
print by the zero part and the trick if no promo would just click and download, trickier part is
ESP know the MCS 32 s and set the download the component and download. Okay now began to
download. Okay download to complete and you can enable the ceremony, you can see the state
of the pod, we can press the reset, but you can see to try to connect to Wi Fi. And this IP address
is generated for the a four part. And then now we can pack and the search slash really a four or
you can see as they say we have quit. This is a fork. And it's the first time we need to use the new
robot, we just press the start and this command that is LDL off and the state. This LDL means to
now Chow and this led off that means turn the GPS off this stream can change by adding a code
and also we can see this is a feedback the start as a logo output. And now you can click OK input
slash LDL I need to see the tank I just click the LDL and then we can press led off you can see
the LED is off. So now we can use this mobile phone to control your lamp just off and change
the state as this is how to use the telephone to control your lamp for remote country anywhere on
the world.
SEND ALERT MESSAGE TO
WHATSAPP BY KC868-A4 A8
(ESP32)
I will show you how to send the alarm message found the a4 pod send it to your mobile phone
WhatsApp application you can see this is a whatsapp not need to use a Khinkali smartphone
application. So you can see like this this is if awareness sensor there is a door sensor we can try
go and you will see this is a message or heard someone opened the door. So this message is this a
four parter used by the ESP 32 and the detect the wireless sensor message sent into the receive
wireless receiver module and the signal will be sent by the network and sent to your mobile
phone. So this will not without company SCADA server and the just use the alarm message
sensor and the Sennheiser WhatsApp you can see so WhatsApp is our number and this low but at
the lower to send the message to your mobile phone as the message was sent to your mobile
phone, maybe have some delay as actually according to the server of the provide and the
network. Okay, let's look at how to with it, you can get the sensor information and send the
information to your mobile phone by whatsapp after the first we need to prepare the hardware
you can see this is a four pod and this is a power supply and this is a USB cable for
communication and you will install this wireless module This module you can use for three
megahertz or you can use 315 megahertz is up to you. So we have not installed at the full
configuration.
So you can install it by yourself or just being sold to this socket and the well it okay let's work
through this module this this is the same module you can see this part we have installed and
when this pin sweeping can use this Okay, now we can install the resume module. If you want to
long distance you can also there is a hole you can when the antenna because I have used in my in
my room is not enough to use to I know I'm not installed antenna. So we can just try again. Now
we can install the USB cable and the 12 watch. Okay, let's look at the compute. This is our form.
And we have this 25 lessons are how to send the message by whatsapp by a 408 part. And this is
almost by step for the WhatsApp. So the first window that was set by the WhatsApp, the first
thing you can add this number, this is a load of WhatsApp you just saved to your phone contact.
You can see I have already named Robert, this Robert 34644565518 I just this need this number
we have saved as case 868 a four. So we can just you can see this is our law. And the second that
you just send a message I alo call raabta to send me message I just this trip, you can copy from
the web page and send it to your mobile phone or you can see my mobile phone have already
sent this information. This information I have sent after you send as a load will feed back or you
can see the load and feedback are you API key is three, five for the alumni for this way we use at
our additional code. So you see this number.

And this is the feedback your API key, then the force is a WhatsApp message. You can send the
API just this is API. This is API stream for you, only for you to send the message. You can see
this is when we send this message and then we'll feed back this one. And then you can use this
trip. This string is HTTP command. So that you can tell the robot to send a message send it to
where this is mobile phone number and is Test your sensitivity around the information. And this
API key, your API key just copy this one. So, this consistent with this details, you can see this is
very easy just to you needed to feel the phone number and in the text around message and the
API key is where it is. And the fact that enjoy by yourself and now we just can see a skipper this,
we can see as a mobile phone have received the sweet items. Now, we can prepare the hardware
for if you assume module, this sensor, just that we have running this receive module and
prepared this processor. And if you have used the remote last, we have no problem. You can use
any wireless sensor for this resume module. And also you can use this wire sensor you can see
this is the oscillator sensor. But this is how I lie. This is dry contact output similar so you can
connect to you can connect to this part of what digital input that also no problem, it's up to you.
So in this project, I will take the sample for your use wireless remote and the wireless sensor for
the code and the send is a learned message to your mobile phone. And then now we just need to
prepare the Arduino IDE, you just install this library and I will tell you how to install and the
source code you can download from this zip file, we have right to the code after you download it,
you will see this zip back you just need to unzip and open this file and you will see this code or
this code we have we have set a unit to install this RC switch revelry and so, you can click a
scratch and manage library and the input as the switch and you can search this assets which you
will see this item the assets which means is remote see the control. So this remote control switch.
So, we can call this as a switch, you can install or click this button and this I have installed so I
can click Close. And in this code, it will not match program code just you can see some
information you need to replace this SSID you will need to change for your router by yourself
this is King County's and the password change to your loudest password and this is a phone
number this is my number you change it to your number and this is the sensor address. This is a
number how to get this number I will tell you because I have detected the door sensor this is
sense address. So after you complete the software and to use this program firstly you need to
know address this thing an address and if you have this 16 Channel button, you will need to
know every button the single address the same address.

So, you can download this code to your a4 board and the ESP 32 module with formant because
we can use a third party output to see this error code of the button and the author says okay now
begin download now began running and we can first enable the ceremony and I can press the
button for research and you can see as this module have connected to the Wi Fi and connected to
a Wi Fi network this is successfully and now you can try go this door sensor you can see I can
try to go and as this is output the wellness code this is sense address. So you can see this I have
used this door sensor is this address just copied to copy to this place maybe have changed I can
copy and paste just the what is signal union to culture and input has this code and you can say I
can use this remote I can press a button one or you can see this code for this button one and I
press button two or you can see at least a quarter for the potential and the patterns and the pattern
for and a pattern six, five and button six. So error but have active Friends, could you just input
this code for compare, so we can send the alarm message, this is the message when you send. So
you can change alarm alert, someone open the door or you have used a smoking or maybe your
door have smoke. And that you can change this test for send the alert message to your mobile
phone by whatsapp. So it's very easy to use. There are some many codes that you're not needed
to see such as these just use a quarter convert this function you just need to set as the first step
you need to set this eye open. This is our F receive ping, because we have used a wireless router
module and you can see our tag one we have used for switch reading because the receive at this I
owe 19. So we have used this one. If you have used another pin for ESP module, you just input
your pin number to your to this place and this in it and adjust the change of the SSID and the
password and the API key and the phone number and the sensor address. So you can use your
sensor tribal and the sender of the message to your mobile phone by whatsapp. So this is how
you get the sensor information and the sensor tracker send around message to your mobile
phone.
WEB SERVICE HTTP COMMAND
WITH KC868 A8
I will show you how to use this 88688 part integrate with home assistant by ESP home. And I
will tell you how to send the HTTP command to this part and the work without Raspberry Pi
without home assistant. So let's look at the hardware and the configure the function list. You can
see this is our dashboard for home assistant. So, I have almost integrate our functions and our
parts on the home assistant dashboard you can see input eight input part and eight really output
for switch this and our and this is LED strip you can see I can turn off the LED and turn on the
LED and change the brightness and as I can change any of this LED strip and now I can close
and also you can see the temperature sensor I guess 18 B 22 temperature sensor and detect the
temperature one and the temperature two and also there are two analog input I have not
connected sensor you can see the NLRB input watch watch one one and two.

So I have integrated this functions into one eight part communication by the Ethernet port and
there are some rest GPIO you can use it's up to you and now I will tell you step by step how to
integrate firstly we can see this is our function list and really output and input the input in this
pot in for switch because I have searched automation the input will trigger that we output pay
press our actions you can see us this way okay this hnd grant and I can shoot for one and this
really long and short I counted off you can see this is easy to see channel one is a channel one
and short again will be on and off because I use a wide not good contact you can use a self reset
switch just a momentary switch panel for hour and a half and the monitor to temperature analog
input and the two temperature sensors this 18 B 20 a temperature sensor I have used one GPIO
part actually you can use many DS 18 B 20 Temperature Sensor use a one one way just a 1.4
mark communication because every sensor will have a different address we just can't according
to the address to monitor the sensor and you can see this is a LED strip I have connected with
this Ciao pot this I have used one meat just for testing one meat this is one meat and total health
so we are the LDS and by the Ethernet okay this is a catch buck and you just go to Home
assistant you can install the add on for ESP home and you can create the device I have quit the
case at 688 and you can edit you just copy and paste this configuration I have at here yes you just
select our queue onto this section and you can copy and paste pisser to this Yamen file. So I have
quit already when you copy and paste or you just press save and install and the press USB to the
server just downloaded the firmware for the USB by Raspberry Pi and you can click this and it
detected the USB serial port and click and they will see they will compare the files and for
download and now is writing okay writing complete as this is the logo output information is
already communicating successfully you can see this is the IP address for the IT pod and you can
see the temperature. This our sensor date is our time for interview for update. Because you can
set the temperature sensor you can see I can finance this is for GSA TV 20 and update To
interview five seconds, every five seconds, update the value. So, after complete download, you
just click close and this will be online. And you can add it to this NTI entity to the dashboard,
you will see this dashboard. If I can hold on one temperature sensor, and you can see the
temperature is become up, you pick up, you can click and in the history of the car, this is
changed. Okay, this is very easy just a copy and paste of the configuration for the ESP home and
you will see the beautiful dashboard.

Now I will tell you how to integrate this third party software for HTTP command. Because we
have enabled the web service, we have defined the web service, you can see this is my nipples a
web service. So you can open your web bar. And you can see I can open ESP H ESP home by
eight, just click open this URL, you can input to your WebPart. And you will see this auto
generate the website for temperature and for analog and the first switch and for input sensor state
and for LED strip. And you can also see this output as a logo file. This is useful for our TPAC.
And now we can see Guam this is actually the command, if you want to need the release date,
we can just copy this this URL this URL how to do this, you can see this our website. And just
consistent with the IP address and the switch. If you want to lead a relay as this is switch type
this is switch and this switch one that means this name this is one. So if you want to lead a
switch, you can just change it to a switch or two. And you can copy and paste and enter and you
will get the state you can see the switch state is off. If I turn on the switch, you can say turns off
switch, the switch is on channel one is on. Now I can refresh this URL. And again and you can
you can see the state is become. So this is a hot lead as a real estate. And okay, we go out. And if
you want to come to the relay, or if you want to target just off of oh, you can turn on late autumn
turn off ray. So now the only one we need to turn off, we can use this command. This is turned
off really one. But that means you need to post posting your URL. So not use this copy and paste
to the web bearer, we can use Windows command. And you can see the two pack just the
standard command like this see URL ex post, you can just input this command like this one, I
can input see you out next post slash switch switch one and turn off. You can see this, this really
and I can end this is really off. So if you want to turn up, you've just change it to URL and this
post this command HTTP command. You can see I can just and this is how and if you want to
talk in 30 minutes change your state just change your state and again again.

Okay, so this is how to send an HDTV command to turn off and toggle the relay and then we go
out or you can control it now and now you can leave the LI input state just this input. This can
connect with your switch panel, connect with your digital input sensor, like door sensor, a
window sensor and a smoking sensor and you want to lead a street so you can just copy this
command and we can paste it to the web part because why you continually and you want to it off
you just need to use this command to testing and if you want to need because this use the Get get
information. So, you can copy and paste of this stream in your web directory and now we can
leave the input a one so, I can copy and paste and enter this input a one is our now I can use this
this equation and this input a one this input a one I can shoot shutter input A one and it really
also is off because I have mixer if TDD command by the ESP home and you can see the
dashboard this important one is out and now I send this command again I can enter the keyboard
and you can see the state is changed to arm and if I remove this this way and I can refresh this
state is off. So this is a hot lead is the input a state of our input the point you just change it to
input to that channel to this input tool. And as you can change the input it's very important for us
to input an eight. So this is hot lead to the digital input state sensor and now you can lead to the
temperature the temperature hot lead to you just you can copy this string and paste and you can
see our web service this is important and you need to note it cost me many times to find out the
program if you want to lead a temperature seat because this is a sensor for sensor type this is the
S 18 B 20 temporary sense and this is a number of this one is number but ESP home only can use
lowercase if this T is Captain lat so you can convert to t and all letters must use the lowercase so
you can copy and paste okay you can get the temperature one is this value if you input this T
with the capital letter you can add or you will see it's wrong. So this I have tried many times I
have found out this rule out you only need to use the lowercase and press and you will get the
temperature sensor date okay we'll go on as easily the temperature sensor and listen the leader
analog sensor input also you can copy and paste and you can see the web servers this analog
input also is a sensor type so this is sensor and this the analog in one this channel one so we also
can change it to this a with lowercase A and this in all lowercase also you can change the name
in your ESP home configuration apaiser lowercase for the name just if you want to use capital
letter you need to change the words and in this URL and paste paste and you will see as a watch
when you connect our sensor with NLRB input you will see the watch value and this okay we go
out and this is a leader LED strip LED strip as you can lead you can see I can copy and paste the
URL district that's used the light or use the light what is the sensor what is a binary sensor and
what is the light type you just needed to check the ESP home and configuration.
You can see I have I have defined this is this is by Switch switch type. And this pie is input the
Python binary says and temperature you can see I have defined by the sensor. So you need this
type. And as soon as this second words and is the last one just the name or the ID the name or ID
for the ESP home. You can see these are the strip because I have named the early strip. So, you
can consist with this total Street and copy and paste it will feed back the LD strip state and RGB
as attributes of value. If I can change it like this I can change I can change and refresh and you
will see the value will be changed this R is 255 Because I have said to the read read if I have said
recording I can fresh refresh you can see the cooling you become to FeiFei So, this is needed
RGB state after the brightness and RGB value and the state okay. This is hot, use this HD View
command. If you want see more functions you just use Google to search ESP home and you will
get the web server API and you will find this web service comm component and there are many
details how to use okay, this is a hot integrate the eight part for home assistant and you can send
a command.
EXAMPLE DUMMY CODE
To create a web service for executing HTTP commands with the KC868-A8 relay module, you
can use the ESPAsyncWebServer library. Here's an example Arduino code:
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <SoftwareSerial.h>
// Replace with your network credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// Replace with the KC868-A8 relay module settings
const int baudRate = 9600;
const int kc868RelayPin = 2;
SoftwareSerial kc868Serial(12, 13); // RX, TX
AsyncWebServer server(80);
void setup() {
[Link](115200);
[Link](baudRate);
// Connect to Wi-Fi
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi");
// Start the server
[Link]("/", HTTP_GET, handleRoot);
[Link]("/relay", HTTP_GET, handleRelay);
[Link]();
[Link]("Server started");
// Setup the relay pin
pinMode(kc868RelayPin, OUTPUT);
digitalWrite(kc868RelayPin, HIGH); // KC868-A8 relays are active low
}

void loop() {
[Link]();
}
void handleRoot(AsyncWebServerRequest* request) {
request->send(200, "text/plain", "Hello from ESP32!");
}
void handleRelay(AsyncWebServerRequest* request) {
String state = request->getParam("state")->value();
if (state == "on") {
digitalWrite(kc868RelayPin, LOW); // Activate the relay
[Link]("1"); // Send command to KC868-A8 relay module
request->send(200, "text/plain", "Relay turned ON");
} else if (state == "off") {
digitalWrite(kc868RelayPin, HIGH); // Deactivate the relay
[Link]("0"); // Send command to KC868-A8 relay module
request->send(200, "text/plain", "Relay turned OFF");
} else {
request->send(400, "text/plain", "Invalid state parameter");
}
}
Make sure to include the required libraries (WiFi, ESPAsyncWebServer, and SoftwareSerial) in
your Arduino IDE to compile and upload this code to your ESP32 board.
In the code, replace the placeholders with your network credentials, the KC868-A8 relay module
settings, and the relay pin connected to the KC868-A8 module (kc868RelayPin).

Upon power-up, the ESP32 will connect to the specified Wi-Fi network. The code sets up a web
server on port 80 with two routes: "/" and "/relay". The "/" route simply returns a "Hello from
ESP32!" message.
The "/relay" route handles GET requests with a "state" parameter to control the relay. If the
"state" parameter is "on", it activates the relay by setting the KC868 relay pin LOW and sends
the command "1" to the KC868-A8 relay module via SoftwareSerial. If the "state" parameter is
"off", it deactivates the relay by setting the KC868 relay pin HIGH and sends the command "0"
to the KC868-A8 relay module.
To control the relay, send a GET request to the ESP32's IP address followed by the "/relay" route
with the "state" parameter (e.g., [Link] to turn the relay
ON).
The ESP32 will receive the request, control the relay accordingly, and send a response back to
the client.
With this setup, you can use any HTTP client or integration (including Home Assistant) to send
GET requests to control the relay through the ESP32 web service.
KC868-A4 (ESP32) DAC OUTPUT
DC 0 10V
I will show you how to use this a4 book and you can continue the analog output from zero to 10
foot so you can try your lD strip or driver your lamp to change the brightness. You can see this a
full board have two analog output apart. This is Grant and this is channel one and channel two.
This is found the GPIO or you can see our Tiguan which we should allow you will use and now I
will show you I can use this much meat I can test the output watch. And then you can see I can
tell this is a turn on the switch and this is a lamp and is a multimeter about eight foot actually we
can change it to the max and max about 9.5 What about 10 work so you can see I can change the
brightness output of the different watch you can see I can change the timbre and the voltage
down and off.

So that's almost zero and this is about half an hour can change, change and the change so we can
country its output a different budget to control your drivers. Now I will tell you how to conflict
with the ESP home for the home assistant. You can see this is a two channel our channel you can
entrepreneur zero to 10 now I delete a tell you how to step by step which is to delete the cart,
delete account and delete all. Okay now is empty. And you can see this is our form. I have posted
this lesson it takes it This is lesson 28 I had use a for ESP 32 The AC output for there are 210 out
this is the config file for ESP home. So firstly you just need to add install the ESP home.
Probably and we can delete this. As is I have already quit neither the new request the ESP 32 The
ESP home supports the ESP 32 TC insert. So this is the meaning about the configuration.
You can find that this ESP home online guide so I can enter the device. And the name we can
KC 868 a four and the Wi Fi SSID is yours. This is a password. Also the your Wi Fi SSID and
the password which are the ESP 32. And the close and these are complete and we can add it and
this is the configuration I have make you just a copy and paste so you can copy and paste. Paste
it's very easy. But you need to change the SSID and the password and also this is the SSID the
password. This is used for the AP mode for the hotspot if you're not needed to use you can delete
it. And also you don't want to use the Wi Fi hotspot hotspot you just delete it. And the meaning is
this output the print module ESP 32 GAC because we have used this ESP 32 etc. And this is a
GPIO GPIO is 25 and 26 we have used the for the a four port actually, the ESP home only
supported that 25 and 26 channel one and channel two. So you can define the two ID that will ID
at the AC output one another idea the AC entrepreneur tool. So this is very easy for the output.
And the you need to quit tonight because we need to install to light on the dashboard. So the
plentiful is this one and output just from the output the DC output one ID and this is the name
and this is the character, the sacrum and this is in sync as a channel and the channel to see and
adjust the importantly the two sections output under the lights and you just press save and install
and install by USB because we have you connected the USB cable with a Raspberry Pi or you
maybe you have not worked without Raspberry Pi just use your PC such as your home assistant.
Yeah on installing the Windows or Linux PC is no problem, we just click this USB gem. And
next and it will be download. We just needed to wait for mode, and we'll come play the files and
then we'll download it to the ESP 32 module. After we download, we need to just edit the entity
to the dashboard. We just wait because this is output to the logo file. Okay, now is successful,
you can see you can too, right? Okay, after 100% You can see it began to work unless you find
the Wi Fi and they see the IP address or the module. And you can see this quaint query to the DC
light at night Yes, connect successfully so we can close stop. And you can see this is the a4 and
we can go to configuration and integration. And you will see that for entity ID. This is listed to
entity ID for credit. And this is light, a 40 AC one and a 40 AC. So we just click the overview.
And this is a dashboard which has added dashboard and we can add a card because you want to
change the bad news, we can use this slide and just click and this is entity we can choose this a
four, D C one and c and now you can see this is the icon. If you want to add a second secondary
AC, you can just choose that the AC two and a save. Okay these have quit you if you don't want
to quit the switch button you can use this to I can't get enough you can see I can control it. This is
much watch Do you can see I can change it change it because now so watch is down and change.
I just watched you down and until I change it to the zero as almost a zero. So this is for a town
and change the brightness or maybe you will not connect with your lamp or maybe you will
connect fence speed or pump speed. So this is how to use this icon and home assistant to output
different analog watch at the front of the spark.
EXAMPLE DUMMY CODE
To generate a DC voltage output of 0-10V using the ESP32 and the KC868-A4 module, you can
use the DAC (Digital-to-Analog Converter) capabilities of the ESP32. Here's an example
Arduino code:
#include <WiFi.h>
// Replace with your network credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// Define the DAC output pin connected to the KC868-A4 module
const int dacPin = 25;
void setup() {
[Link](115200);
// Connect to Wi-Fi
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi");
// Initialize DAC
ledcSetup(0, 5000, 12); // Channel 0, Frequency: 5kHz, Resolution: 12 bits
ledcAttachPin(dacPin, 0); // Attach DAC output pin
}
void loop() {
// Generate a ramp signal from 0 to 10V
for (int i = 0; i <= 4095; i++) {
ledcWrite(0, i); // Write DAC value (0-4095)
delay(10);
}
delay(1000);
}
Make sure to include the required library (WiFi) in your Arduino IDE to compile and upload this
code to your ESP32 board.
In the code, replace the placeholders with your network credentials and configure the dacPin
according to the pin connected to the KC868-A4 module for DAC output.
Upon power-up, the ESP32 will connect to the specified Wi-Fi network. The code initializes the
DAC using the ledcSetup() function, setting the frequency to 5kHz and the resolution to 12 bits.
The ledcAttachPin() function attaches the DAC output pin to the corresponding DAC channel.

In the loop() function, a ramp signal from 0 to 10V is generated by incrementing the DAC value
from 0 to 4095 (corresponding to the range of the 12-bit resolution). The ledcWrite() function is
used to write the DAC value, and a delay of 10ms is added between each increment to create a
smooth ramp. After reaching the maximum value, it delays for 1 second before repeating the
process.
Upload the code to your ESP32 board and ensure that the KC868-A4 module is correctly
connected to the DAC pin. The ESP32 will generate a ramp signal on the DAC pin, providing a
voltage output ranging from 0V to 10V.
DECODE 433MHZ RF SIGNAL
AND CONTROL DEVICE
I will show you use our a4 bug, but this time we will use this RF device you can see I have this I
have remote, we can country this switch panel or maybe you have cutten you have one of the
remotes and you have a lot of remote. Now, I will tell you how to use home assistant you can
create the button to learning this remote button and send a signal by the home assistant. So, this
is a Raspberry Pi and this evil part and it is our switch I will show you the results you can see
this was switch this country in the light and this is channel two and I can use this remote or you
can see I can turn off the light because I have used this panel have learning my pattern similar
just like this if you want long distance you just extended the antenna and now you can see my
mobile phone this is the home assistant because I have created a little button you can see I can
press a button and off center the command and the wireless signal to country this panel.

So now I can use this mobile phone for home assistant and I can also use this remote to turn our
editor okay now I will show you how to learn in this button to the a4 pod and a faux pas sending
the signal to country the switch panel even if you have any this kind of remote just forcefulness
really megahertz or remote if remote you can run any but to the a four part. So, you can see this
is a four part who can see the hardware first you can install the receive module this is I have
received module and this is I have transmit module. So this is the code for the code, we can send
this button signal this signal is sent to this module and this module will send a signal to the
switch panel. This sends signal to a switch panel. So the first step we needed to learning the
button like this button one we have learning to the a four bar and then horsington to create a
button switch button and it can send the RF signal to Control Panel Okay, let's begin you can see
this is a home assistant dashboard we have already quit this but now at delete I will tell you how
to step by step okay, this is a new So, at first the US you needed to install this add ons by the
ESP home and acquit the button quit the device of the a4 pod and press the add. So, this is the
configuration of the if last project we have tell you how to use the IR device. This is if device
also you can get the code the configuration code to Lesson setting one how to decode forces will
make efforts if signal and send device by ESP home you can copy this sections and to the ESP
home. You can see this I have corporate you just replace the Wi Fi SSID and the password of
your Lord and this is remote receiver and as you can see, this is ESP home.

How about us if device this is for if transmit and you can see this for the IR and this If so, you
need to define the remote receive this pin I needed to change which chip shall you have used a
dump just a capture or date and this you do not need to change this the buffer and the sound
signal settings. So you just just copy this from the ESP home official websites. You can see I
have copied this and let's see, let's see that is a nice thing because we can check on the Tiguan
this ESP 32 You can see this is received module armies receive and this team is sent. So this is
GPIO 19. So I have set to a 19 and this is copied from the official website of ESP home and this
is the motor send which tips how you have used by the send module. So we can also say this, this
Daguan we can say send is shipped out 21. So I have used the 21 and this curry to 80%. Master
change to 100%. If you use IR If you change to 50% so, this is 100% you can see this is a must
100% This help tell you and at last we can create the button that button is used by switch and the
print flow is template and the knee I have choose the RF power button and this action and action
off if you switch one but you can learn in a signal for toggling toggling the signal, one signal for
to off off AF so that you can learn only one signal. If the button for owl and for AF is consist by
two different similar so you can use a learning signal for arm and other signal for that is
individual. So this tool versus after learning way most of the search panel if switch panel have
included this function, so you can use one signal to send a target signal and you can send two
signals for on and off two different signal it's up to you.

So at this time, I have seen a one signal just for toggling on and off on and off. So this is easy to
for the demo, take the demo project. So I have used the action. I have said sending the IR switch.
This is our C switch that is our library used for the ES ESP home. This is the code and this also
is the code lit I will tell you why use this code and the port and the loop which sometimes sends
a signal maybe the signal you're not very well. So we can repeat send a two times make sure it
will be work stable. And you can also delete this send only one time I actually I have sent totally
three times one time and the repeater two time. So we can see and install and lit I will tell you
why copy this code and you can install and the choose the USB because we have also use the
USB cable with with this Raspberry Pi USB cable you can click and anon began to complain and
download. Okay began scanning the Wi Fi and connected successfully and now is ready to use.
The first we need to decode I have set a decoder the pattern one, you can decode any but I just
use this pattern one for tonight and turn off the switch you can see I press the button one you can
see this is a code I have received. So your parents and a key recollect button to potentially add
the button for or you can say oh we'll have different things. Now I can copy this button one, well
sometimes this button one is not enough yet which has a copy this this for signal. This is learning
for successfully and the copy and to the know the paid. And you can see this industry as a switch
row this is original code of the wireless or this protocol type is one I don't know when is the
word you can choose, you can see the Asus switch library that will tell you what is the number
one of the port comings now we just copy this number one to the ESP home configuration and
list the date as the pattern ones but on one stage, okay we can close it stop and edit. And you can
see this is our C switch code. Although this that means original and is a code this is the code you
can see I have already copied this date this state just use this one this state and it's a postcode
type is a one now the political type is a one so this is a copy and this is just a repeat how many
times repeated you want 10 or 567 is up to you. And this is off turn off also kept copy this
because I use one signal for on and off. So I have also copied this to this section. And also you
put a call one so if you want a country this button, found this one and found this button too. So
you can replace this code with a button twos code that will be this one for this one for us. And
now you You just use a one but for an hour and a half Okay, so you now you can understand I
can choose clothes. And at last you can see the configuration and integration and you can choose
this a for this device and the last one we have quit. You just see the last one and you can see this
power I have power button, you can edit to love runs, you can add tolerance. You can see
overview and this is the last time we have created it. I asked him signal and this this will have
created for the button for the IRF now I can test it this is my if remote I can press a button one is
out of now I can press this button on home assistant you can see I can press is off and you can
see I can press again this is it. So this is for toggling. Okay, now you can use this remote I have
remote and use your mobile phone consistent or while sitting on your PC software to country
your device.
EXAMPLE DUMMY ARDUINO
CODE
To decode a 433MHz RF signal and control a device using Arduino, you can use the RCSwitch
library. Here's an example Arduino code:
#include <RCSwitch.h>
// Replace with your RF receiver pin
const int receiverPin = 2;
RCSwitch mySwitch;
void setup() {
[Link](9600);
[Link](receiverPin);
}
void loop() {
if ([Link]()) {
unsigned long receivedValue = [Link]();
if (receivedValue != 0) {
[Link]("Received value: ");
[Link](receivedValue);
// Add your device control logic here based on the receivedValue
// For example, you can use if-else or switch-case statements to perform actions based on
different values.
// if (receivedValue == <some_value>) {
// // Control device
// // ...
// }
}
[Link]();
}
}
Make sure to include the RCSwitch library in your Arduino IDE to compile and upload this code
to your Arduino board.
In the code, replace the receiverPin with the pin to which the RF receiver data pin is connected.
In the setup() function, the Serial communication is initiated, and the RCSwitch library is
enabled to receive signals on the specified receiverPin.
In the loop() function, the code checks if there is an available RF signal using
[Link](). If a signal is available, the received value is obtained using
[Link](). If a non-zero value is received, it is printed to the serial monitor
for debugging purposes.
You can add your device control logic inside the loop() function based on the received value. For
example, you can use if-else or switch-case statements to perform different actions based on
different received values. Replace <some_value> with the specific value you want to use for
device control. Add the necessary device control code inside the corresponding if/else or case
block.
Upload the code to your Arduino board and ensure that the RF receiver is correctly connected.
The Arduino will continuously check for received RF signals and perform the desired device
control actions based on the received values.
REMOTE CONTROL KC868-A4
WITH MQTT CLOUD SERVER
ARDUINO CODE SAMPLE
I will show you a four part source code of MQ TT will have a pair that this code for you to use
remote countries are a four part for the relay output on and off and check the input state to MQ
TT broke the server, so that you can use your mobile phone use our key box and your phone
application to load data on a relay and due to the input state of the pod, so let's look at the code
how it works. And this is the code you can download from our form that is the source code I
have already download, you can see here the code not where we run. But before you use our
code, you need to install this add in the library.

This is for MQ TT, so that you can install this online just use this Manage library and then you
can open this code you can see here the defined is a relay output and this is a key a key is the
input digital input from one to four channel. And this is for the scan scan key program. And this
is for the uncle TT library and the Wi Fi robbery and the you just only to change this one you're
allowed SSID and the password of your Lord and this is m qotd broke because you want to use
remote conch biomol platform so you can you need to have our MQ decoder server this is King
Kunis encoded Carter server that is free to use you can use it or you can use your own color
server that is very easy. And it is a topic and this is a topic of command and this type Governor
state these are the four commands for our and aft change the race state and this is state for the
input for the release date. And this is Channel four and this is set not needed to change you can
only change this ID This is every pod ID I just take example 4123456 You need to change by
yourself just everybody if you have many a forbort or many rollaboard you just change this ID
that is different. I think you can just replace you can see here is a code of Wi Fi MAC address
that our bar have different MAC MAC address. So you can replace in this section that will be
alternate generated come out of the topic and this is the username and the password. So that that
is according to the MQ add parser called the server we have set to the username and quantity and
password 123 If you use IoT dot can [Link] Carter server and in this deferred listening part
of MKTG is 1883 is usually used this part and the goal on this is define the relay output for ping
out and this is what the key input and the COA that the for connection Wi Fi connection and this
is for the MQ DD connection. And this is a for the publisher that first topic message if we will
connect your pod connect to Cardoso that will be sending the message I am case 868 a four and
this Copic callback function that will decode what message have received and when to turn relay
one and when to turn off relay one that is to call this a channel two and the channels array and
the channel four relay. So, this is what the code the MK TT message to turn on and turn off relay
this is for Chico State of relay that you need to change your code this just a stream consistent
with this our state just for example, and this is scan key just as a digital input scan key function.
There are four scan key this is a one this one and this is a two and this three and a four. So these
are functions is saying we just look at the first key function. You can see here that is the detect if
with a key of pressed exactly the key is pressed just aware when key number is one that means
the key is pressed, you can see here and that will lead to the state you can see here a leader state
this is digital right change your state we're talking and then leaders listed there and send us a
message just to send a message to MQ TT topic est. So that when you press that key button, the
relay will tugging and then send it a new visitor state offer rate to MQ TT message to M querque
state topic.

So, I think this you understand how this code works. Now we can download the code by the USB
you can see I can check the device which kompot have used you can see Tom seven just come
sim and download and now you can open this MQ TT books test toy so that you can connect
with this encoder decoder server you can see I have set this MQL TT to this domain name and
this part and the pi this username and MQ TT password 123 So I have quit this information and
on MKTG box because we need to mount the state. So this is state we have used so we can just a
subscriber and now we can wait for it download okay this is complete and you can see as the
message is received found a four part I am case 8684 So that is connected successfully and also
we can use this ceremony we can open two windows at the same time. You can see I can
subscribe it and reset this board I will give you see the whole process connect with Wi Fi and
connect Wi Fi successfully and then the MKT D broker you're connected so we're sending this
the Hello World message like hi I'm pch six eight a four and now you can see if I shoot for this
this is input A 1234 If I shut for this now you can see I showed four quickly I can subscribe
again. You can see I shut shut for this release off. And this relief for now the newless that it is
zero if I shot again you can see the lay it out and will feed back this is arm so that I can shoot for
chin another channel to now recently added to offer this way and to unread to and to offer really
to and genuine and off genuine, this is Channel Four. Okay, this you can see here is the message
sent to the MQ add book for this input part. Now we can open your NGO for application. We
just you can download it from Google Play Store and search the key box marked and installed on
your mobile phone and click this one. Then we need to add the device. Just click this pencil, add
the device and we can choose to four channel because we use a four and you can use this color
modifier for a channel Oh 16 channel so the two channel is a response. Oh can work? No
problem. And this IP address you just input I O T dot can [Link] Just as thing as you're
setting in the compute, enter the port 1883 and the port To create MQL TT and is the device ID
this device ID is 1234 Just this 1123456123456 and MQ T to use an immediate MQ TT and then
the password is 123 So we can click OK. You can see here we can quit this container box. You
can see I can shut for this channel and really is out and this state it updates and to off and the
layout and arf. So this is update the input state or not implicitly opportunities that are listed on
this mobile phone. Okay. Another channel okay, this is update the state now we can country on
the mobile phone. You can see I can only one and the RE two two now Leslie and play for so
this will have used the key box remote country in the relay you can go to anywhere on the world
just to have internet or have SIM card you can use your mobile phone remote country that really
anywhere. Okay, this is how to use MQ TT cloud server and for remote country or a four part
okay.
EXAMPLE DUMMY ARDUINO
CODE
To control the KC868-A4 relay module using MQTT and an Arduino board, you can use the
PubSubClient library for MQTT communication. Here's an example Arduino code:
#include <WiFi.h>
#include <PubSubClient.h>
// Replace with your network credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// MQTT Broker information
const char* mqttBroker = "mqtt_server_ip";
const int mqttPort = 1883;
const char* mqttUsername = "your_mqtt_username";
const char* mqttPassword = "your_mqtt_password";
// KC868-A4 relay pins
const int relay1Pin = 2;
const int relay2Pin = 3;
const int relay3Pin = 4;
const int relay4Pin = 5;
WiFiClient wifiClient;
PubSubClient mqttClient(wifiClient);
void setup() {
[Link](115200);
// Connect to Wi-Fi
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi");
// Connect to MQTT Broker
[Link](mqttBroker, mqttPort);
[Link](callback);
reconnect();
// Initialize relay pins
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
pinMode(relay3Pin, OUTPUT);
pinMode(relay4Pin, OUTPUT);
// Set relay pins to default state (OFF)
digitalWrite(relay1Pin, HIGH);
digitalWrite(relay2Pin, HIGH);
digitalWrite(relay3Pin, HIGH);
digitalWrite(relay4Pin, HIGH);
}
void loop() {
if (![Link]()) {
reconnect();
}
[Link]();
}
void callback(char* topic, byte* payload, unsigned int length) {
// Convert payload to string
String message = "";
for (unsigned int i = 0; i < length; i++) {
message += (char)payload[i];
}
// Print received message
[Link]("Received message on topic: ");
[Link](topic);
[Link]("Message: ");
[Link](message);
// Parse topic to determine relay number
String topicStr = String(topic);
int relayNum = [Link]([Link]('/') + 1).toInt();
// Control relay based on message
if (message == "ON") {
digitalWrite(getRelayPin(relayNum), LOW); // KC868-A4 relays are active LOW
} else if (message == "OFF") {
digitalWrite(getRelayPin(relayNum), HIGH);
}
}

void reconnect() {
while (![Link]()) {
[Link]("Connecting to MQTT Broker...");
String clientId = "ESP32Client-";
clientId += String(random(0xffff), HEX);
if ([Link](clientId.c_str(), mqttUsername, mqttPassword)) {
[Link]("Connected");
[Link]("home/relay/+/state");
} else {
[Link]("Failed, rc=");
[Link]([Link]());
[Link](" Retrying in 5 seconds...");
delay(5000);
}
}
}
int getRelayPin(int relayNum) {
switch (relayNum) {
case 1:
return relay1Pin;
case 2:
return relay2Pin;
case 3:
return relay3Pin;
case 4:
return relay4Pin;
default:
return -1;
}
}
Make sure to include the required libraries (WiFi and PubSubClient) in your Arduino IDE to
compile and upload this code to your ESP32 or Arduino board.
In the code, replace the following placeholders:
ssid and password with your Wi-Fi network credentials.
mqttBroker with the IP address or hostname of your MQTT broker server.
mqttPort with the port number of your MQTT broker (default is 1883).
mqttUsername and mqttPassword with your MQTT credentials (if required).
Modify the relay1Pin, relay2Pin, relay3Pin, and relay4Pin constants according to the pins
connected to the respective relays on the KC868-A4 module.
The code connects to your Wi-Fi network and MQTT broker. It sets up the relay pins as outputs
and initializes them to the default state (OFF). It also defines a callback function to handle
incoming MQTT messages and control the relays accordingly. The reconnect() function is used
to establish the MQTT connection, and the getRelayPin() function maps the relay number to the
corresponding pin.
Upload the code to your ESP32 or Arduino board. Once connected to the MQTT broker, the
board will subscribe to the "home/relay/+/state" topic. You can publish messages of "ON" or
"OFF" to the respective relay topics ("home/relay/1/state", "home/relay/2/state", etc.) to control
the relays on the KC868-A4 module through the MQTT broker.
DEBUG KC868-A8S 4G MODULE
USING AT COMMAND
I will show you how to back at command of GSM module. So you can see this a 2g module, and
this is a 4g module. So the different module you can use for your country, because this time I
will use this 4g module because in my city, there are no 2g signal and a single 2g signal you stop
to use. So this time, we can see this we have designed as a new version that is 1.2 versus of eight
s pod, so that this socket is a four to two module, you can install it directly. And this time, we
have update the socket, and the for the Forge module. So this time, you can install this forge
module and the eighth part directly. So that will be convenient to use. Okay, let's look at how to
install the hardware. And then we can send the command by the software by the Arduino code.
And at first, you need to prepare the SIM card. This is a SIM card, this is my SIM card I get from
my mobile phone, but it can't insert twit directly because it's too small. So you need to use this
adapt this draft that changes smart to pick. So I can just put this card and into this eject.

So that the card will be a little latch. And now we can open this socket, I can open this and you
can see this production and insert, put this sockets and just go down and attend that left, then the
world lock this sim card. And now you can see the other two interface that's for GSM and this is
for GPS this this is a GPS antenna, but this time I will not use this one that's for get the GPS date
and I only use for this antenna. So I can use this for the packet will be easy just like this that your
soft, this antenna is soft and that you can stick to anywhere and stick to the box. So I just connect
with it you can see here but also you can install like this black antenna so that will extend the
antenna just to change this lag for the SMA interface we'll install this one. So, you can see I can
install on the bog just like Aziz you can see here and here and zero to school as is to school one
two and I can install it okay that will be fixed this module will be how I could contact okay this
is a hardware that is a twin install the card and forge module here is the interface that you the
USB for NGO phone cable just like this one, you can connect it and this to your compute
directory. So that can practice at command. But this time we will use this type of C and of course
to this ESP 32 body at the center corner to this module directory. So we will send at command to
this top type C. So I will use this cable type C and before testing we will download the Arduino
code to this ESP 32 module. So that will let this module and this type C report will
communication directly. So you can see now I can power hour after this board.

Okay, let's look at the computer. When your power what for mode is cooling LG will be Blink is
that successfully the SIM card it will register with your internet service. So that's where we work
fine. Then prepare to test the software. Okay, let's look at this lesson cert history that we have
named how to do packet H because it takes a It is part of GSM module used by each command.
So, that we have this to some commonly used at command that like this make a call and the
receiver call and receive a message and the sender message This is SMS that means the short
message. So, you can see here some Arduino code and the document and the packet toy I have
already prepared for you. So, the first thing you can download this Arduino code, so, just this
one and this code is very easy just to let the to set apart because the GSM module is a separate
part and this also have our server part we just let the communication work with each other to
actually this have a delay function, I can disable it because the speed will be fast so, you can
click download and at least we began to comprehend the download and you can see here that
have some documents of the at command. So, you can see many details at command of this thing
come module, this module he commanded details and also you can see that is a toy, just this toy
that is 40 Pack come pot for communication send and receive a message that will be easy. Okay,
let's look at here you can see that download the PIO 100% So, it's complete and this time we can
close this window we never use this add in occurred okay you can see here now we can begin to
use this compound to constantly just let this part connect to your computer directly. So, you can
see I can leave power on just the power off and the power you can see I can open these
compounds that come through and you can see this feedback at the at command because the
module you start up so there are some at command that will be feedback. And you can see that
when LD is blink. So that will be ready. At first we can use this the first one that just input A T
so we can input here at and enable this you know check this box and we can send just click this
already this is a toy made by Chinese language, but it's very common yes to use. So, you can see
I can click at that will be okay. So, you can see I can extend this menu there are many commands
have quit. So, that will be very easy to testing your module and not it will always input the input.
So this is at that will be feedback okay. So your module is okay. Now, now we can make our koi
just you can let this part and telephone you input this one ATD amount that will replace for you
mobile phone number.

So you can see can replace this in my mobile phone number and we can click send and you can
see this is okay see my mobile phone wait for moment you can see that is coming that is I have
renamed this case 868 it as part of that coin. So I can turn off or turn around. So you can see I
can like this that you received this call if you module have connected with the microphone so
that I can hear that voice of this part. So I can just connect. So this is very easy just make a coin
okay you can see the smooth that will be losing. So, if you want let your mobile phone and make
a call to your pod so you can see what command will be received. So you can see I can press this
a Is it as bad. You can see that your telephony coin and you can see here the command meaning
that he always really many, many. So you can use this to hop outside of your phone if you don't
want to receive this phone, so you can copy this command The first step here and you can press
ok so, it will be Speaker The phone is busy now, because I have I have used this command so,
you can see that is a Mr call from this mobile phone number. So, this is receive a call and make a
call okay let's look at this receiver message shut message if I can use this part you can see I can
send a short message I send a PC to this it as part you can see I can send that have sent ABC and
then you can see this window with formant or you can see here that have received a short
message that in to in number two this is because I have already have received those are first one
SMS this is second. So, please have received the ID tour. So, if you want to see this SMS
content, so, you can see that you will receive the message that in number two, so if you want to
lead this number of the content, so you can just copy this command copy and paste here and the
change to number two if you have received this way you can change it if you have received the
for that you can change it. So now I can send this number two. So, you can see here that is
content the message the message download send from this mobile phone and send the file on this
date and the sender from this time and then you can see this content a PC. So this you can lose
the chat message content are found this at command okay if you want delete this strategy
message because if you always send a message send a message send message this sim card will
be four okay if you want to delete the strike message so you can use this command and the copy
and paste that I want to send delete number two short message so I can send this command okay
you can see that number two is delayed. So, this time you can use have used this mobile phone
sending the message to this part that will always also show this number two because the majority
of us have never tweeted it and this can lead all content on message content and this command
can lead or delete or message so by will come out. So this will be useful and clear and empty
your SMS Okay, let's look at this this is a useful function send a message just use this port to
send a message to your mobile phone such as on has you can read the temperature sensor and the
leader released it and the sender of the message to the mobile phone so you can see how to send
a message. The first we need to use this command and ascend set the message test mode to test
just to copy and paste and you can see said that okay set okay. Okay, now you can see where to
send, just need to input the message send it to where send it to which mobile phone phone
number okay this we can send it to this mobile form. You can please press Send and it will will
say this and the UK input is a command you can see now this time is very important. Just you
can see this is a test message. Growl can connect okay. You can press send the message is
defined, we will be sending this but now you've not stopped at the last we need to finish this
command. Just use send this hex code of one a so you can send here when that use by send fix
mode. Just click this one fixed mode. You can press send. Okay, you can see now this is display
okay. And the main message in the mobile phone you can see here that have received. This is a
test image test message function Hello. So this will be easy to receive the message from this part.
Okay. So you can see here a very useful function make a call receive a call and send a message
and receive a message in a you can download all the tours and documentation from this website
and the next project I will show you how to use SMS message country this relay and the leader
are listed and make some useful functioning for your project.
EXAMPLE DUMMY CODE
To debug the KC868-A8S 4G module using AT commands, you can communicate with the
module using a software serial connection on an Arduino board. Here's an example Arduino
code:
#include <SoftwareSerial.h>
// KC868-A8S 4G module connection
SoftwareSerial gsmSerial(10, 11); // RX, TX
void setup() {
[Link](9600);
[Link](9600);
[Link]("KC868-A8S 4G Module Debug");
[Link]("Type AT commands and press Enter to send");
}
void loop() {
// Forward data from Serial to GSM module
if ([Link]()) {
char data = [Link]();
[Link](data);
}
// Forward data from GSM module to Serial
if ([Link]()) {
char data = [Link]();
[Link](data);
}
}
In the code, connect the RX pin of the KC868-A8S module to the TX pin of the Arduino (pin 10)
and the TX pin of the module to the RX pin of the Arduino (pin 11). Make sure to adjust the pins
according to your setup.
Upload the code to your Arduino board and open the serial monitor. Set the baud rate of the
serial monitor to 9600.
You can now type AT commands in the serial monitor and press Enter to send them to the
KC868-A8S 4G module. The module's responses will be displayed in the serial monitor.
For example, you can start by typing "AT" and pressing Enter. The module should respond with
"OK" if the communication is successful. You can then try various AT commands to interact
with the module and debug its functionality.
Remember to refer to the KC868-A8S module's documentation for a list of supported AT
commands and their syntax.
SEND SMS WITH AT COMMAND
USING SIM7600 4G MODULE
I will show you how to send a short message from this eight s part. So that this is a simple just
Arduino code and I will tell you how to send a message for our test you can see here that is
lessons 34 That is how to send us SMS by H MT, this is source code and this conference call you
can download it and open it that you can see here just a little code that will send a message test
the message or Fanconi H S word. So, we can see how to send a message. So I can download or
you can see I can set part to come through and download this code and give you let you see the
result after the coding is download that part will send a message to my mobile phone. After
sending the message I will show you why this Arduino code running as this way and how it
works. And you can see now your download.

Okay, download complete. And now you can see this board and my mobile phone. And this you
can see the message that is the message test the message from King County so that you send the
message successfully. So let's look at how it works. So, we have downloaded this code you can
see exactly the code you just replaced by your mobile phone number. And here you can see the
zero part to the report we have already set in last project. And you can see that is that you can see
this have used this function we have sent this message and this you can see the command you
can see that lesson cert history how to send a message just we have tested this at command. And
now this time we just use with by this Arduino code. So, you can see here you can set the SMS
mode just to use this code. And you can see here is that you sent this number for number you can
see that you the phone number off this command and this is an SMS message content. So that
you just by this message this stream and then you can see here and this at last that it does stop a
bit. So that is input just to send this command that is a one a just a country added a Z. So this will
be sending the message and this just a feedback found several parts. So if you have the module
have the feedback will fill it back fine this is a report you can detect are monitoring the state. So
this is a simple just how to send the message from HS pod found this income audio that will be
useful for your project to finish because you can send the message and the content will be
replaced with any useful message that has a temperature value and is the release date. Okay, so
he says a halt sends a message to the mobile phone, the Arduino code that will be very easy.
SMS CONTROL RELAY, READ
TEMPERATURE, ALARM
MESSAGE
I will show you an interesting project source code that says we have read the Arduino code you
can use short message to control this relay and the you can use short message to lead to the
temperature sensor and also you can see here Santi to input of aid as part that the input sensor
can trigger send a message alarm message to your mobile phone. Okay let's look at this lessons
35 so that you can use SMS continually and the little temperature sensor you can see we have
created the commander to turn off relay and turn off all relay so this is the country elderly and
this is the country all relate together on and off and then this thing can lead as a temperature
value and this you can use the input digital input the first sensor and a triangle around message
and the first time all to a function so you can see there are some functions and this is adding a
code at first we can download this code and see how it works.

And in this code you can download from our webpage you can see this is the source code you
can download and just replace this mobile phone number for yourself. So that will be very easy
just to replace this one and now you can use this download to your part directly. So after you
download let's look at an ad tested we can offer a one way so you can see I can use my mobile
phone to record the screen and see your details Okay, let's look at now the first I want to turn on
the new one so I've just input really one so you can see I can press set and then you can see this
really one is um and now I have received the message that really one is turned down so you can
turn off really auto and really you can see really one off and the press sent pay attention to this
way okay it's off and you can see the message or the feedback relay is off okay let's test the
second command that will be on and off.

So you just input oh oh and the sand okay, you can see already following me following that
totally it really is own and is a feedback already is oh by the SMS I can also input off self okay
you can see this ad generally have off so this have feedback that is off and now we can leave this
Gs 18 B 20 Temperature says actually you can add many get Ph Ds 18 between the sensors
together so I can just send temperature te MP just a temporary edge and the weight of one
moment okay you can see this a temperature is 25 cent grades This is a temperature detect real
time and that last you can see the last song it channel did so input that you're the first incident
this I have defined this input a one that will be really will be out and after three seconds will be
off and send a message that sensor is triggered someone may be coming so you can see I can
press this button one yes the input one we can see release and after three seconds off and now
with Vermont you can see here the message from the a test part that doesn't say triggered okay
you can see that input a tool that is input to maybe country and speak as son. So we can press this
button to you can see also is really to it out and then off and you can also send a message
window sensor your triangle with somebody that you know. So you can see I can press this
button sorry. It just send a message directly through this time not tribal this really and for our
press a four you can see it says a four and the five I press five that's fine 678 Okay, you can see
me tryna do three input you can use for sensors and the alarm message. So, this will be very
useful you can get the temperature and the gets the digital input of the sensor. And also you can
connect with sounds asked for it by device sensor for long distance and sending the message to
buy the SMS that will be very useful and for yourself how to project Okay, let's look at the
Arduino IDE code, you can see that code is not very complete with how to write the code you
just directory to use and if you want to change a sink just as a member of your phone mobile
phone and the you can maybe you will change that then relay command and the feedback. So this
is edit this and this a turn off. So you just replace this text. So you can send this text by SMS and
this is the feedback. So you can replace what will be sent and what will be feedback. So this is an
off wandering. And here you can see go on go on go on that you turn on and off command so
you can replace this all on and off test. So you can use any test to send a message to country
always and always off. And also you can see here that is a temperature sensor feedback. Just use
this command you can also replace and here you can see the input to trigger input the one trigger
so that is for digital input. So you can replace this one. So that's our digital input the channel will
try to understand the different alarm message to your mobile phone. So this on to to channel
eight. Okay, that's the command of the sending message. So that will be very useful and
interesting project and for you to use and to learning how to send a message and it gets the state
and the country rate by the Arduino code. In next project, we will show you how to use the MK
OTT of the 4g module and the conditionally.
EXAMPLE DUMMY CODE
To control a relay, read temperature, and receive alarm messages using SMS with an Arduino
and a GSM module, you can use the GSM library. Here's an example Arduino code:
#include <GSM.h>
// Replace with your SIM card PIN (if required)
#define PINNUMBER ""
// Replace with your GSM module's APN settings
#define GPRS_APN "your_apn"
#define GPRS_LOGIN "your_login"
#define GPRS_PASSWORD "your_password"
// Replace with your phone number
#define PHONE_NUMBER "+1234567890"
// GSM module connection
GSM gsmAccess;
GSM_SMS sms;
// Relay control pin
const int relayPin = 2;
void setup() {
[Link](9600);
pinMode(relayPin, OUTPUT);
// Initialize GSM module
boolean isConnected = false;
while (!isConnected) {
if ([Link](PINNUMBER) == GSM_READY) {
isConnected = true;
} else {
[Link]("GSM initialization failed.");
delay(1000);
}
}
// Set GPRS settings
gprsSetup();
[Link]("SMS Control Relay & Temperature");
[Link]("Send 'ON' to turn the relay ON");
[Link]("Send 'OFF' to turn the relay OFF");
[Link]("Send 'TEMP' to get temperature reading");

// Delete all existing messages


smsDeleteAll();
}
void loop() {
if ([Link]()) {
// Receive an incoming SMS
String message = [Link]();
if (message == "ON") {
digitalWrite(relayPin, HIGH);
[Link]("Relay turned ON");
} else if (message == "OFF") {
digitalWrite(relayPin, LOW);
[Link]("Relay turned OFF");
} else if (message == "TEMP") {
// Read temperature and send it back as an SMS reply
float temperature = readTemperature();
sendSMS(PHONE_NUMBER, "Temperature: " + String(temperature) + "C");
[Link]("Temperature sent via SMS");
}
// Delete the received message
smsDeleteAll();
}
}
void gprsSetup() {
[Link]("Connecting to GPRS...");
while (![Link](GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)) {
delay(1000);
[Link](".");
}
[Link]("Connected to GPRS");
}
float readTemperature() {
// Replace with your temperature reading logic
// For example, use a temperature sensor library or code to get the temperature value
float temperature = 25.0;
return temperature;
}
void sendSMS(const String& phoneNumber, const String& message) {
[Link]("Sending SMS to ");
[Link](phoneNumber);
[Link](": ");
[Link](message);
[Link](phoneNumber);
[Link](message);
[Link]();
}
void smsDeleteAll() {
[Link]("Deleting all SMS messages");
[Link]();
[Link]();
}
Make sure to include the GSM library in your Arduino IDE to compile and upload this code to
your Arduino board.
In the code, replace the placeholders with the appropriate values:
PINNUMBER: If your SIM card requires a PIN, enter it here. Otherwise, leave it as an empty
string.
GPRS_APN, GPRS_LOGIN, and GPRS_PASSWORD: Enter the correct APN settings for your
GSM network provider.
PHONE_NUMBER: Enter your phone number to send and receive SMS messages.
Connect the relay control pin to the appropriate pin on your Arduino (in this example, it's pin 2).
The code initializes the GSM module and connects to the GSM network using the GPRS
settings. It sets up the serial communication and waits for incoming SMS messages. When an
SMS is received, it checks the content of the message. If the message is "ON", it turns the relay
ON. If the message is "OFF", it turns the relay OFF. If the message is "TEMP", it reads the
temperature and sends it back as an SMS reply.
The gprsSetup() function sets up the GPRS settings, and the readTemperature() function reads
the temperature (replace this logic with your own temperature reading code or library). The
sendSMS() function sends an SMS to the specified phone number, and the smsDeleteAll()
function deletes all existing SMS messages.
Upload the code to your Arduino board, insert the SIM card into the GSM module, and power on
the system. You can then send SMS messages to control the relay by sending "ON" to turn it
ON, "OFF" to turn it OFF, and "TEMP" to get the temperature reading. The system will respond
to the received messages accordingly.
REMOTE CONTROL RELAY WITH
4G MODULE VIA MQTT BY
INTERNET
We have used this mobile phone send a short message to country aid as part the relief by the 4g
module where in this project I will show you how to use this 4g module and this word connect to
your quarter server by MQ TT directly so that you not needed to use send this test shot message
just that you can send a message to Amkor TT proxy server that will be easy for a big mobile
phone application and for the remote country. Okay, let's begin how to deal with it. Let's look at
the Honeywell Firstly, we have uses forge module and this is the antenna and this way I have
used the 12 watch power supply and this type C USB cable have connected with my computer so
that I will download the Arduino code from this USB pouch. Okay, let's look at this the lesson
statistics that we will move country very slowly and with the first module by the MQ add at
command. So you can see here is MK TT, the key point of a step is actually the for message
publish message. And it's actually for subscriber topic from them completely broke. So this
example, and this example, and that's how many details in this document, you can download and
that is from SIM card. So, there are many many MKTG command details, but I want to show
you easily not new to see so much code and this is a source code of Arduino i have already
downloaded you can see here that almost not very much code.

So, I can download it and the USC as a result, you can see I can upload and here you can see
just a new place to publish and this is a subscribe topic, this topic defined by yourself. And this
12345 I have used this as ID for this part if you have many board, which just replace this number
for different number. Okay, now you can see the download complete. And you can see this
MKTG box that I have, you can see create a disk kind of tool, you can connect them creating the
color server, you can replace for your color server by this IP address, or by this too many and the
part and at least the username and the password.

And just click Save. And you can see as this is required that in four countries and a country
command to on top relate to this topic. And it is a subscriber to the state topic. So that when your
two nodes that relay part, what is the state in real time, so you just subscribe and subscribe. And
you can see this is payload, we need a tool to only one just like this payload, this payload also
can use for other content container you can see I can publish that is published really one is arm.
And you can see now really one is and now you can see the feedback Ready when you are. So
this just use this part, no Wi Fi no network cable and just only buy the 4g card and the
communication with the quarter server. So that you can see I have sent the command to the
quarter server for this payload. And a terminal is really one and the pod will feed back the state
to the My compute. So this is the simplest example for to overlay and the feedback is requested
by the MQ TT. Okay, let's look at the sound details. Now let's look at this Arduino code. You
can see this code is not very complete. And here you can see this is a publish topic and this is
subscriber topic. And this is head and this is finished. And for the command state and it is the
first set send a command. This ID you can replace by yourself just distinguish the different part
you can use. The first one is 12345 or the second one is 123456. Just according to you, you can
change any just for the different departments. And here you can see that is for client ID. This
kind of Id also you can reproduce by yourself in any client ID just every part will connect with a
quarter server and port will have a client ID and this is a kind of server domain name or IP
address and the port and the MQ TT username and 1234123 is up password. So, you can see it
has the information and then this is a four set command.
And here you can see when relay is on and the one really is off, you can see here when laying
off, so, that example for the new one and really one off, so that you can copy and paste this
section of the code for release rate with a full refund until release six and then until really it paid
channel. So, this is very easy just to decode when on and off and this step just connect with the
encoder decoder server. Now, I will show you how it works we can press this button and a for
reset and we will use several monitors to see what is work and the ceremony it okay, you can
see the progress first set the conflict Okay. And you can see a sound step that you can convey
and the sun can convey username and the password and the domain name this arrow I think
you're not needed to see it because some config I have already already set for the fourth module,
you just dropped it to us and you can see that is okay for the topic and connect to the kernel
server successfully. So, when this time you can see I can send this command I can clear this I can
clear this and it is monitored from the ESP 32. So I can totally you can see I can press release.
And you can see here that MK TT message have set set have received and this message have
received have sent to the State topic so you can see here the progress was sending the command
and ESP 32 were received this one and also we'll see received also will send the feedback
message to this topic. And so that if you have a mobile phone application or PC application will
update the state or from this topic that message will release. So this is progress after the MCAT
in the communication for the HS part.
EXAMPLE DUMMY ARDUINO
CODE
To remotely control a relay using a 4G module via MQTT over the internet, you will need an
Arduino board, a 4G module, and the PubSubClient library for MQTT communication. Here's an
example Arduino code:
#include <SoftwareSerial.h>
#include <PubSubClient.h>
// Replace with your 4G module's RX and TX pins
SoftwareSerial gsmSerial(10, 11); // RX, TX
// MQTT Broker information
const char* mqttBroker = "mqtt_server_ip";
const int mqttPort = 1883;
const char* mqttUsername = "your_mqtt_username";
const char* mqttPassword = "your_mqtt_password";
// Relay control pin
const int relayPin = 2;
// GSM module connection
const int baudRate = 9600;
// MQTT topics
const char* topicSubscribe = "home/relay/control";
const char* topicPublish = "home/relay/status";
// Global variables
bool relayState = false;
SoftwareSerial gsmSerial(10, 11); // RX, TX
PubSubClient mqttClient(gsmSerial);
void setup() {
[Link](115200);
[Link](baudRate);
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW); // Set relay OFF initially
reconnect();
}

void loop() {
if (![Link]()) {
reconnect();
}
[Link]();
}
void callback(char* topic, byte* payload, unsigned int length) {
payload[length] = '\0'; // Add null terminator to payload
String message = String((char*)payload);
if (message == "ON") {
digitalWrite(relayPin, HIGH);
relayState = true;
publishStatus();
} else if (message == "OFF") {
digitalWrite(relayPin, LOW);
relayState = false;
publishStatus();
}
}
void publishStatus() {
String status = relayState ? "ON" : "OFF";
[Link](topicPublish, status.c_str(), true);
}
void reconnect() {
while (![Link]()) {
[Link]("Connecting to MQTT broker...");
if (gsmConnect()) {
if ([Link]("ArduinoClient", mqttUsername, mqttPassword)) {
[Link]("Connected to MQTT broker");
[Link](callback);
[Link](topicSubscribe);
publishStatus();
} else {
[Link]("Connection to MQTT broker failed. Retrying in 5 seconds...");
delay(5000);
}
} else {
[Link]("GSM connection failed. Retrying in 5 seconds...");
delay(5000);
}
}
}

bool gsmConnect() {
[Link]("Initializing GSM module...");
[Link]("AT");
delay(1000);
String response = [Link]();
if ([Link]("OK") != -1) {
[Link]("GSM module initialized");
return true;
} else {
[Link]("Failed to initialize GSM module");
return false;
}
}

Make sure to include the required libraries (SoftwareSerial and PubSubClient) in your Arduino
IDE to compile and upload this code to your Arduino board.
In the code, replace the following placeholders:
mqttBroker with the IP address or hostname of your MQTT broker server.
mqttPort with the port number of your MQTT broker (default is 1883).
mqttUsername and mqttPassword with your MQTT credentials (if required).
relayPin with the pin connected to the relay control pin on your Arduino.
Adjust the topicSubscribe and topicPublish variables to the desired MQTT topics for subscribing
to control commands and publishing relay status, respectively.
The code initializes the GSM module and connects to the MQTT broker. It sets up the serial
communication and waits for incoming MQTT messages. When an MQTT message is received
on the control topic, it checks the content of the message. If the message is "ON", it turns the
relay ON. If the message is "OFF", it turns the relay OFF. The relay status is then published to
the status topic.
The reconnect() function is used to establish the MQTT and GSM connections. The
gsmConnect() function initializes the GSM module and returns true if successful. The callback()
function handles incoming MQTT messages. The publishStatus() function publishes the relay
status to the status topic.
Upload the code to your Arduino board and make sure the 4G module is properly connected. The
Arduino will establish a connection to the MQTT broker and wait for incoming MQTT
messages. You can send MQTT messages to the control topic ("home/relay/control") to remotely
control the relay. The relay status will be published to the status topic ("home/relay/status").

You might also like