NodeMcu Arduino Serial Communication Send Multiple Data, Up to 12 Data

Поділитися
Вставка
  • Опубліковано 25 жов 2024

КОМЕНТАРІ • 68

  • @عبداللهالمغربي-غ6ج
    @عبداللهالمغربي-غ6ج 3 роки тому +7

    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);

    }

  • @danaishrathore2659
    @danaishrathore2659 3 роки тому +1

    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.

  • @KR_FAIZ555
    @KR_FAIZ555 4 місяці тому

    WOW, Channel ini sangat membantu sekali dalam pengerjaan proyek saya.Terima kasih banyak CP

  • @youeng1
    @youeng1 11 місяців тому +1

    Hello, great video tutorial, and your work really helped me. Thanks Bro.

  • @LUCKY007725
    @LUCKY007725 3 роки тому

    very useful tutorial, I was searching splitting data of serial read, from many days
    thanks

  • @janithbandara9552
    @janithbandara9552 3 роки тому

    thank you sooo much you just completed my project

  • @hamdansulaiman6888
    @hamdansulaiman6888 3 роки тому

    Thank you so much for sharing the knowledge... You really saved many people's brain... including me.. Thanks Sir !

  • @mephisto3763
    @mephisto3763 2 роки тому

    Nice solved my problem thanks a lot

  • @IceCream786
    @IceCream786 3 роки тому

    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

  • @ateebhassan4655
    @ateebhassan4655 2 роки тому

    Thanks man. You saved me. I was trying and searching for exactly this thing from last 10 days. Thanks again. keep uploading.

  • @iantcroft
    @iantcroft 10 місяців тому

    Great video, do you have any videos using char array instead of String?

  • @j0hzg4l7
    @j0hzg4l7 2 роки тому +1

    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 **

  • @DanielVila34
    @DanielVila34 Рік тому

    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.

  • @abdelkarimramdani791
    @abdelkarimramdani791 3 роки тому

    thank you , you saved my project

  • @jmn0501
    @jmn0501 2 роки тому

    I tried it to Arduino to Nodemcu but it just output question marks? What do you think is the problem there?

  • @wardenclyffepark486
    @wardenclyffepark486 3 роки тому

    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!

  • @erboy5546
    @erboy5546 3 роки тому

    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

    • @caturpebriandani8422
      @caturpebriandani8422  3 роки тому

      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

  • @taufikanwar31
    @taufikanwar31 3 роки тому

    If I want to change Arduino to be a data sender and Nodemcu to be a data receiver, what would it be like?

  • @nitishgowrydoss6959
    @nitishgowrydoss6959 2 роки тому

    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 ?

  • @derrickakomeah
    @derrickakomeah 3 роки тому

    You just saved my life

  • @a7medza8loul46
    @a7medza8loul46 Рік тому +1

    Vary good 👍

  • @subahashsuman9183
    @subahashsuman9183 2 роки тому

    will it work for if the integer values from transmitter are varying?

  • @pateltejash2043
    @pateltejash2043 3 роки тому

    really helpfull also safe my project

  • @difafadlilah158
    @difafadlilah158 Рік тому +1

    thaank you so much

  • @ziajutt4197
    @ziajutt4197 2 роки тому

    Hello Sir! Is the same method from Arduino to Node MCU??

  • @MarioPerez-vb9hj
    @MarioPerez-vb9hj 3 роки тому

    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.

  • @derrickakomeah
    @derrickakomeah 3 роки тому

    Is the a way i can parse the data without using substring
    I need the output to be an int or float

  • @silentknife24
    @silentknife24 3 роки тому

    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

    • @silentknife24
      @silentknife24 3 роки тому

      @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

    • @silentknife24
      @silentknife24 3 роки тому

      @@iBotsjk
      Sure will share my code soon

    • @alianajiha6528
      @alianajiha6528 3 роки тому

      @@silentknife24 hi, may you share your code of sending data from Arduino to NodeMCU?

    • @silentknife24
      @silentknife24 3 роки тому

      @@alianajiha6528 Hi, yes i can
      You want me to post it here ?

    • @silentknife24
      @silentknife24 3 роки тому

      @@patringl4842 yes no problem
      Share me your email and will forward the code

  • @ziwalouay5849
    @ziwalouay5849 3 роки тому

    u r awesome

  • @aaronye4857
    @aaronye4857 2 роки тому

    The download link were no longer avaliable.

    • @caturpebriandani8422
      @caturpebriandani8422  2 роки тому

      Please check the announcement
      www.caturcreativeproject.com/2021/09/sorry.html?sc=1662346546703#c76135933624815470

  • @ShadowX_Legion
    @ShadowX_Legion Рік тому

    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)

    • @ShadowX_Legion
      @ShadowX_Legion Рік тому

      WaterLevel 2m
      WaterDischarge 0m3/s
      like this

  • @mohamedtahamohamed6050
    @mohamedtahamohamed6050 Рік тому

    can we use it to send the data from Arduino to ESP

    • @caturpebriandani8422
      @caturpebriandani8422  Рік тому

      Only need a little modification, but the main idea is the same. I have the example code if you need that

  • @azizulhakim9009
    @azizulhakim9009 3 роки тому

    hello sir..... would it be too much to ask for a copy of the source code for both the arduino and nodemcu?

  • @sinchanagupta
    @sinchanagupta 3 роки тому +1

    Can you please share the code...Thank you!

  • @wardenclyffepark486
    @wardenclyffepark486 3 роки тому

    can I use this for arduino to arduino serial connection?

  • @starhero6314
    @starhero6314 Рік тому

    Nice Bro

  • @pruthvijagadeesh5158
    @pruthvijagadeesh5158 3 роки тому

    can you please send us the code it would be very helpful and we have a review on 29th, please

  • @andra.laksana
    @andra.laksana 3 роки тому

    Bisa minta kode programnya mas?

  • @navins5638
    @navins5638 2 роки тому

    link not working

    • @caturpebriandani8422
      @caturpebriandani8422  2 роки тому +1

      You need to donate first in order to get the program

    • @navins5638
      @navins5638 2 роки тому

      First of all thankyou replying

    • @navins5638
      @navins5638 2 роки тому

      @@caturpebriandani8422 i have learn something from you
      ur awesome 😎