NodeMcu Arduino Serial Communication Send Multiple Data, Up to 12 Data
Вставка
- Опубліковано 10 лют 2025
- This is the Next video tutorial about NodeMcu Arduino Serial Communication. Also, this video fulfills my Subscriber request in the column comment. In this video, I create both NodeMcu and Arduino programs.
The rule is NodeMcu sends 12 different data to Arduino using a software serial program. The data was a combined data type, include int, float, and String data type. Then the Arduino receives the entire data and parses the data. In my opinion, to achieve this process, the most important thing to do is determine the data package. Commonly my data package structure is "Data1, Separator1, Data2, Separator2, ..., End Data Character".
You can watch the full video to make your project, or you can faster to Learn and Built your Project by Downloading The Project Files Here :
-Arduino source code
-NodeMCU source code
drive.google.c...
[Supporting me by joining as a Member FreeCoding-NotProjectFile (it is only 1.92 USD). Currently, this project file is only available for my Members' FreeCoding-NotProjectFile. Please join my Channel and then make a request to download this file. Sometimes you may need to contact me at caturservices28@gmail.com to confirm your request. Please do not sell the original project file to others. This is only for personal use. But sure you can copy or modify this project file for a part of your project and share it]
Playlist
1. NodeMcu Arduino Serial Communication The Basic of Two-Way Communication
• NodeMcu Arduino Serial...
2. NodeMcu Arduino Serial Communication Send Multiple Data, Up to 12 Data
• NodeMcu Arduino Serial...
To join as a Member, please click on the Join button or click the link below
/ @caturpebriandani8422
The Members-only videos are here
• Members-only videos
Regards,
CP
Hi,
First, I will share the code of this video, after that I will share the code if you want to send the data from arduino to NodeMcu
1- CODE Of the Video ( from NodeMcu to Arduino multiple data)
CODE ARDUINO :
#include
SoftwareSerial Arduino_SoftSerial(10,11); // RX,TX
//Below is Global Variable Data
char c;
String DataIn;
int8_t indexofA, indexofB, indexofC, indexofD,indexofE,indexofF,
indexofG, indexofH, indexofI,indexofJ, indexofK,indexofL;
String data1, data2, data3, data4, data5, data6,
data7, data8, data9, data10, data11, data12;
void setup() {
// put your setup code here, to run once:
//Open Serial Communication (Arduino -PC)
Serial.begin(57600);
//Open Serial communication (NodeMcu -Arduino)
Arduino_SoftSerial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
while(Arduino_SoftSerial.available()>0) {
c= Arduino_SoftSerial.read();
if(c== '
') {break;}
else {DataIn+=c;}
}
if(c== '
')
{
Parse_the_data();
//Show All data to the Serial Monitor
Serial.println("data1 = " + data1);
Serial.println("data2 = " + data2);
Serial.println("data3 = " + data3);
Serial.println("data4 = " + data4);
Serial.println("data5 = " + data5);
Serial.println("data6 = " + data6);
Serial.println("data7 = " + data7);
Serial.println("data8 = " + data8);
Serial.println("data9 = " + data9);
Serial.println("data10 = " + data10);
Serial.println("data11 = " + data11);
Serial.println("data12 = " + data12);
Serial.println("=================================");
//Reset the variable
c=0;
DataIn="";
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
void Parse_the_data()
{
indexofA = DataIn.indexOf("A");
indexofB = DataIn.indexOf("B");
indexofC = DataIn.indexOf("C");
indexofD = DataIn.indexOf("D");
indexofE = DataIn.indexOf("E");
indexofF = DataIn.indexOf("F");
indexofG = DataIn.indexOf("G");
indexofH = DataIn.indexOf("H");
indexofI = DataIn.indexOf("I");
indexofJ = DataIn.indexOf("J");
indexofK = DataIn.indexOf("K");
indexofL = DataIn.indexOf("L");
data1 = DataIn.substring (0, indexofA);
data2 = DataIn.substring (indexofA+1, indexofB);
data3 = DataIn.substring (indexofB+1, indexofC);
data4 = DataIn.substring (indexofC+1, indexofD);
data5 = DataIn.substring (indexofD+1, indexofE);
data6 = DataIn.substring (indexofE+1, indexofF);
data7 = DataIn.substring (indexofF+1, indexofG);
data8 = DataIn.substring (indexofG+1, indexofH);
data9 = DataIn.substring (indexofH+1, indexofI);
data10 = DataIn.substring (indexofI+1, indexofJ);
data11 = DataIn.substring (indexofJ+1, indexofK);
data12 = DataIn.substring (indexofK+1, indexofL);
}
CODE NODEMCU :
#include
SoftwareSerial NodeMcu_SoftSerial (D1,D2); // RX,TX
int data1, data2, data3, data4;
float data5, data6, data7, data8;
String data9, data10, data11, data12;
void setup() {
// put your setup code here, to run once:
//Open serial communication (NOdeMcu - PC)
Serial.begin(57600);
//Open Serial cimmunication (NodeMcu - Arduino)
NodeMcu_SoftSerial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
data1 = 800;
data2 = 900;
data3 = 1000;
data4 = 10000;
data5 = 12.12345;
data6 = 123.1234;
data7 = 1234.123;
data8 = 12345.12;
data9 = "UA-cameeee";
data10 = "Google";
data11 = "Subscriber";
data12 = "Catur";
NodeMcu_SoftSerial.print(data1); NodeMcu_SoftSerial.print("A");
NodeMcu_SoftSerial.print(data2); NodeMcu_SoftSerial.print("B");
NodeMcu_SoftSerial.print(data3); NodeMcu_SoftSerial.print("C");
NodeMcu_SoftSerial.print(data4); NodeMcu_SoftSerial.print("D");
NodeMcu_SoftSerial.print(data5, 5); NodeMcu_SoftSerial.print("E");
NodeMcu_SoftSerial.print(data6, 4); NodeMcu_SoftSerial.print("F");
NodeMcu_SoftSerial.print(data7, 3); NodeMcu_SoftSerial.print("G");
NodeMcu_SoftSerial.print(data8, 2); NodeMcu_SoftSerial.print("H");
NodeMcu_SoftSerial.print(data9); NodeMcu_SoftSerial.print("I");
NodeMcu_SoftSerial.print(data10); NodeMcu_SoftSerial.print("J");
NodeMcu_SoftSerial.print(data11); NodeMcu_SoftSerial.print("K");
NodeMcu_SoftSerial.print(data12); NodeMcu_SoftSerial.print("L");
NodeMcu_SoftSerial.print("
");
delay(500);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2- (from arduino to NodeMcu Multiple data) :
CODE ARDUINO :
#include
SoftwareSerial Arduino_SoftSerial (10,11); // RX,TX
int data1, data2, data3, data4;
float data5, data6, data7, data8;
String data9, data10, data11, data12;
void setup() {
// put your setup code here, to run once:
//Open serial communication (Arduino - PC)
Serial.begin(57600);
//Open Serial cimmunication (Arduino - Arduino)
Arduino_SoftSerial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
data1 = 800;
data2 = 900;
data3 = 1000;
data4 = 10000;
data5 = 12.12345;
data6 = 123.1234;
data7 = 1234.123;
data8 = 12345.12;
data9 = "UA-cam";
data10 = "Google";
data11 = "Subscriber";
data12 = "Catur";
Arduino_SoftSerial.print(data1); Arduino_SoftSerial.print("A");
Arduino_SoftSerial.print(data2); Arduino_SoftSerial.print("B");
Arduino_SoftSerial.print(data3); Arduino_SoftSerial.print("C");
Arduino_SoftSerial.print(data4); Arduino_SoftSerial.print("D");
Arduino_SoftSerial.print(data5, 5); Arduino_SoftSerial.print("E");
Arduino_SoftSerial.print(data6, 4); Arduino_SoftSerial.print("F");
Arduino_SoftSerial.print(data7, 3); Arduino_SoftSerial.print("G");
Arduino_SoftSerial.print(data8, 2); Arduino_SoftSerial.print("H");
Arduino_SoftSerial.print(data9); Arduino_SoftSerial.print("I");
Arduino_SoftSerial.print(data10); Arduino_SoftSerial.print("J");
Arduino_SoftSerial.print(data11); Arduino_SoftSerial.print("K");
Arduino_SoftSerial.print(data12); Arduino_SoftSerial.print("L");
Arduino_SoftSerial.print("
");
delay(500);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CODE NODE Mcu :
#include
SoftwareSerial NodeMcu_SoftSerial(D1,D2); // RX,TX
//Below is Global Variable Data
char c;
String DataIn;
int8_t indexofA, indexofB, indexofC, indexofD,indexofE,indexofF,
indexofG, indexofH, indexofI,indexofJ, indexofK,indexofL;
String data1, data2, data3, data4, data5, data6,
data7, data8, data9, data10, data11, data12;
void setup() {
// put your setup code here, to run once:
//Open Serial Communication (NodeMcu -PC)
Serial.begin(57600);
//Open Serial communication (NodeMcu -NodeMcu)
NodeMcu_SoftSerial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
while(NodeMcu_SoftSerial.available()>0) {
c= NodeMcu_SoftSerial.read();
if(c== '
') {break;}
else {DataIn+=c;}
}
if(c== '
')
{
Parse_the_data();
//Show All data to the Serial Monitor
Serial.println("data1 = " + data1);
Serial.println("data2 = " + data2);
Serial.println("data3 = " + data3);
Serial.println("data4 = " + data4);
Serial.println("data5 = " + data5);
Serial.println("data6 = " + data6);
Serial.println("data7 = " + data7);
Serial.println("data8 = " + data8);
Serial.println("data9 = " + data9);
Serial.println("data10 = " + data10);
Serial.println("data11 = " + data11);
Serial.println("data12 = " + data12);
Serial.println("=================================");
//Reset the variable
c=0;
DataIn="";
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
void Parse_the_data()
{
indexofA = DataIn.indexOf("A");
indexofB = DataIn.indexOf("B");
indexofC = DataIn.indexOf("C");
indexofD = DataIn.indexOf("D");
indexofE = DataIn.indexOf("E");
indexofF = DataIn.indexOf("F");
indexofG = DataIn.indexOf("G");
indexofH = DataIn.indexOf("H");
indexofI = DataIn.indexOf("I");
indexofJ = DataIn.indexOf("J");
indexofK = DataIn.indexOf("K");
indexofL = DataIn.indexOf("L");
data1 = DataIn.substring (0, indexofA);
data2 = DataIn.substring (indexofA+1, indexofB);
data3 = DataIn.substring (indexofB+1, indexofC);
data4 = DataIn.substring (indexofC+1, indexofD);
data5 = DataIn.substring (indexofD+1, indexofE);
data6 = DataIn.substring (indexofE+1, indexofF);
data7 = DataIn.substring (indexofF+1, indexofG);
data8 = DataIn.substring (indexofG+1, indexofH);
data9 = DataIn.substring (indexofH+1, indexofI);
data10 = DataIn.substring (indexofI+1, indexofJ);
data11 = DataIn.substring (indexofJ+1, indexofK);
data12 = DataIn.substring (indexofK+1, indexofL);
}
thanks alot bro
you absolute beauty
عاشت ايديك يالمغربي 👍
Thank you very much, for this great help and saving time. I was searching the method to split the serial data for almost two weeks and here I got the perfect solution.
Glad to hear that sir :)
WOW, Channel ini sangat membantu sekali dalam pengerjaan proyek saya.Terima kasih banyak CP
Hey dear seems to be great totorial but i want to ask one question i have two sensors connected to uno and then i am sending its data to firebase using esp01 via serial communication but when it recieved at firebase they are combined one after to the other , as their any way to separate the reading for the both sensors in a separate row each contain only one sensor reading and then so on please need your help thanks in advance
I tried it to Arduino to Nodemcu but it just output question marks? What do you think is the problem there?
Hello, great video tutorial, and your work really helped me. Thanks Bro.
You are welcome sir
Great video, do you have any videos using char array instead of String?
thank you sooo much you just completed my project
If I want to change Arduino to be a data sender and Nodemcu to be a data receiver, what would it be like?
will it work for if the integer values from transmitter are varying?
very useful tutorial, I was searching splitting data of serial read, from many days
thanks
You are welcome sir
Hello, great video that works very well between two esp8266, but when is it for communication between two ESP32? If you can enlighten me? The libraries are different, I think for the ESP32 the procedure is quite different. It would be great of you if you have already touched on this subject to tell us more. Thanks for your help.
Nice solved my problem thanks a lot
Thank you so much for sharing the knowledge... You really saved many people's brain... including me.. Thanks Sir !
can we use it to send the data from Arduino to ESP
Only need a little modification, but the main idea is the same. I have the example code if you need that
On the Arduino side, how would you convert data* variables (string) to useful variables (int / float) in code? The only way I was able to do it was with a character array and parse using strtoul... I would prefer your method however because each data is specifically indexed. Excellent content btw **
thaank you so much
Exelente informacion, entendí todos los gestos que hiciste con el tipiado del código, los compilé sin errores, pero no logro que se comunique, probé la librería SoftwareSerial y no logro que transmita, el conexionado esta bien, que otra cosa puede estar mal?, muchas gracias al que me pueda orientar.
Hello Sir! Is the same method from Arduino to Node MCU??
Yes, it works for both programs. both have the same code.
Vary good 👍
thank you , you saved my project
Is the a way i can parse the data without using substring
I need the output to be an int or float
You only need to convert the data after parsing
sir
Hello sir! Your work really helped me in my studies and projects. If its possible, can you show how to have two way communication where an arduino will request data from another arduino before it send them. Thank you!
Hello. Great tutorial video.
Can you also make a tutorial on how to send ultrasonic sensor data from arduino uno to esp8266 and then send that data to firebase please ?
hello sir..... would it be too much to ask for a copy of the source code for both the arduino and nodemcu?
Please check the video description
You just saved my life
how can i sort this type of data and display in 3.5inch TFT LCD
$WaterLevel$2$m$
$WaterDischarge$0$m3/s$
$AverageSpeed$0$m/s$
$Tiltangle$213$Deg$
$Flowdirection$1$$
$SNRLevel$0$dBm$
$AverageVelocity$0$m/s$
$Battery$11.71262$VDC$
this data recieved by rs232 to ttl conveter in aurdino mega serial2 (16,17)
WaterLevel 2m
WaterDischarge 0m3/s
like this
Excellent :). Very informative.
I have a question. If I want two-way serial communication between two Arduino's what do I need to add in the main loop to distinguish between transmitting and receiving. I don't need a whole sketch. I'll go into the details myself. Thanks
You can watch my first video about nodemcu arduino serial communication the basic of two-way communication. The program for nodemcu in that video also worked for arduino. You only need to change software serial pin, change D1,D2 to 10,11 or other pins on arduino.
Thanks
u r awesome
Thanks man. You saved me. I was trying and searching for exactly this thing from last 10 days. Thanks again. keep uploading.
Glad to hear that bro :)
The download link were no longer avaliable.
Please check the announcement
www.caturcreativeproject.com/2021/09/sorry.html?sc=1662346546703#c76135933624815470
Hi Thankyou soo much for this great tutorial
in this video you have sent serial data from Nodemcu to Arduino
can we try the opposite like sending data from Arduino to NodeMcu ? using the same codes ?
I have been trying it i do read values on serial monitor but when i try to save those values on a local integer on ESP8266 i get 0 in return
Please let me know what could be wrong
meanwhile i will try to use your method
Thanks in advance
@Catur Pebriandani THANKYOUU VERY MUCH
This code works absolutely fine with nodemcu sending values to arduino
I have been struggling on transfering serial data recvd from arduino on esp and then using espnow protocol to wirelessly send the rcvd data to anther esp
this is example saved my project :D
@@iBotsjk
Sure will share my code soon
@@silentknife24 hi, may you share your code of sending data from Arduino to NodeMCU?
@@alianajiha6528 Hi, yes i can
You want me to post it here ?
@@patringl4842 yes no problem
Share me your email and will forward the code
Can you please share the code...Thank you!
Now I add the link into the description
can I use this for arduino to arduino serial connection?
Sure it is. Both use the same programming languange
@@caturpebriandani8422 I have already tried it,, it works. Thank you for your videos.
@@wardenclyffepark486 You are Welcome
really helpfull also safe my project
Nice Bro
can you please send us the code it would be very helpful and we have a review on 29th, please
Now I add Link into the description
Bisa minta kode programnya mas?
Link sudah ad di deskripsi, trims
link not working
You need to donate first in order to get the program
First of all thankyou replying
@@caturpebriandani8422 i have learn something from you
ur awesome 😎