Wrong data value in Serial communication

Hi , My problem is that ; In my serial communication between Arduino and nodemcu, 8 data are correct but nodemcu shows only 6 of them correctly.it is not a problem when I send two data alone.I sending serial port with arduino the following data is going
A25B30C0D4E255F255G100P681

But
Nodemcu is reading
A25B30C0D4E0F0G100P681

I mean nodemcu E and F incorrectly reads data
I used serial.parse and Serial.find command

Post both sketches - or a compilable minimal example - in code tags.

A25B30C0D4E255F255G100P681

A25B30C0D4E0F0G100P681

strange conversion happening there...

My Project :

Nodemcu

Arduino

Nodemcu Reading

Wrong data 1 ; if (Serial.find(‘F’)) okunan_sut = Serial.parseInt();

Wrong data 2 ; if (Serial.find(‘G’)) okunan_maydanoz= Serial.parseInt();

arduinosender.ino (14.6 KB)

nodemcuload.ino (10.3 KB)

Please illustrate the problem with two short programs that are only concerned with sending and receiving data. There is far too much other code in the programs in Reply #2 to be able to identify whatever might be causing the problem.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The technique in the 3rd example will be the most reliable. It is what I use for Arduino to Arduino and Arduino to PC communication.

You can send data in a compatible format with code like this (or the equivalent in any other programming language)

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

…R

Arduino Sending is Serial port this ;

Serial.println('A' + String((int)temp_in) + 'B' + String((int)humidity_in) + 'C' + String((int)motion) + 'D' + String((int)light) + 'E' + String((int)weight) + '<' + String(int(okunan_sut)) + '>' + String(int(okunan_maydanoz)) +'H' + String(int(sensorVoltage))+'O'+String(int(digitalRead(dolapkapak)))+ 'P'+String((int)CRC_hesaplanan));

Nodemcu taking

if (Serial.available() > 0)
 {
    if (Serial.find('A')) temp_in        = Serial.parseInt();
    if (Serial.find('B')) humidity_in    = Serial.parseInt();
    if (Serial.find('C')) motion         = Serial.parseInt();
    if (Serial.find('D')) light          = Serial.parseInt();
    if (Serial.find('E')) weight         = Serial.parseInt();
    if (Serial.find('P')) CRC_recv       = Serial.parseInt();
    if (Serial.find('>')) okunan_sut     = Serial.parseInt();
    if (Serial.find('<')) okunan_maydanoz= Serial.parseInt();
    if (Serial.find('H')) gas            = Serial.parseInt();
    if (Serial.find('O')) dolapkapak     = Serial.parseInt();
    
 }

But your sending order is different from your receiving order! How do you expect this to work?

Serial.find cannot search backwards. It can only search in forward direction. Your sender sends data in ABCDE<>HOP order. In receiver code you do this

if (Serial.find('E')) weight         = Serial.parseInt();
if (Serial.find('P')) CRC_recv       = Serial.parseInt();
...
if (Serial.find('H')) gas            = Serial.parseInt();

Once you’ve called Serial.find('P'), you have skipped (and lost forever) all data that was stored between E and P. You skipped <>HO part. There’s no way to return to that data afterwards. So the next Serial.find('H') will not find the H that you already skipped. It will grab for the H from the next data package (skipping everything else) or simply timeout.

If you want to use that Serial.find technique in your receiver, and your sender sends data in ABCDE<>HOP order, then you will have to do Serial.find in exactly this order. Any deviations from this order, and your Serial.find approach will start skipping values.

Also, why is your < and > tags mapped to different values? On the sending side < is okunan_sut. On the receiving side > is okunan_sut.

My friend only works when I install another piece of software with the other code when I add the error I said. like the picture in the plugin
I used ‘<’ and ‘>’ this tags but the others not working I mean just I try its and others char but do not working by the way.

@OP

In your sender sketch, you have used the following codes to transfer your 11 variables to NodeMCU:

Serial.println(
'A' + String((int)temp_in) + 
'B' + String((int)humidity_in) + 
'C' + String((int)motion) + 
'D'+ String((int)light) + 
'E' + String((int)weight) + 
'F' + String(int(okunan_sut)) + 
'G' + String(int(okunan_maydanoz)) +
'H' + String(int(sensorVoltage))+
'O'+String(int(digitalRead(dolapkapak)))+
'P'+String((int)CRC_hesaplanan));

In your received sketch, you have used the following codes to receive the codes.

if (Serial.available() > 0)
  {
    if (Serial.find('A')) temp_in        = Serial.parseInt();
    if (Serial.find('B')) humidity_in    = Serial.parseInt();
    if (Serial.find('C')) motion         = Serial.parseInt();
    if (Serial.find('D')) light          = Serial.parseInt();
    if (Serial.find('E')) weight         = Serial.parseInt();
    if (Serial.find('P')) CRC_recv       = Serial.parseInt();
    if (Serial.find('F')) okunan_sut     = Serial.parseInt();
    if (Serial.find('G')) okunan_maydanoz = Serial.parseInt();
    if (Serial.find('H')) gas            = Serial.parseInt();
    if (Serial.find('O')) dolapkapak     = Serial.parseInt();
  }

Please, observe that there are differences in the (a) 'number of variables' send/receive, (b) in the names of the variables send/receive, and (c) in the order of variables send/receive.

Correct these anomalies and then re-run the sketches; things should be alright.

GolamMostafa:
@OP

In your sender sketch, you have used the following codes to transfer your 11 variables to NodeMCU:

Serial.println(

'A' + String((int)temp_in) +
'B' + String((int)humidity_in) +
'C' + String((int)motion) +
'D'+ String((int)light) +
'E' + String((int)weight) +
'F' + String(int(okunan_sut)) +
'G' + String(int(okunan_maydanoz)) +
'H' + String(int(sensorVoltage))+
'O'+String(int(digitalRead(dolapkapak)))+
'P'+String((int)CRC_hesaplanan));




In your received sketch, you have used the following codes to receive the codes.


if (Serial.available() > 0)
 {
   if (Serial.find('A')) temp_in        = Serial.parseInt();
   if (Serial.find('B')) humidity_in    = Serial.parseInt();
   if (Serial.find('C')) motion         = Serial.parseInt();
   if (Serial.find('D')) light          = Serial.parseInt();
   if (Serial.find('E')) weight         = Serial.parseInt();
   if (Serial.find('P')) CRC_recv       = Serial.parseInt();
   if (Serial.find('F')) okunan_sut     = Serial.parseInt();
   if (Serial.find('G')) okunan_maydanoz = Serial.parseInt();
   if (Serial.find('H')) gas            = Serial.parseInt();
   if (Serial.find('O')) dolapkapak     = Serial.parseInt();
 }




Please, observe that there are differences in the (a) 'number of variables' send/receive, (b) in the names of the variables send/receive, and (c) in the order of variables send/receive.

Correct these anomalies and then re-run the sketches; things should be alright.

I dont understand please do you explain me with example ?

I don't think there's a problem sending data and getting data because when I do a software separately I send the same data randomly, the nodemcu reads it correctly.
I mean, I don't know if this problem is caused by other codes, maybe it's due to the rfid door, but it works when I try with rfid.
Because when anything passes through the rfid gate, one of those values turns from zero to half, but it's still wrong.
I think the weight sensor breaks the job, because the communication takes 1 second. If the weight is added to the measurement, the communication is delayed and some of the memory is misleading.

ThePrelior:
I don't think there's a problem sending data and getting data

Have you studied the link I gave you in Reply #3 and compared it to the way you are going about things?

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with '\0' (NULL).

...R

I understand that you're trying to help, but what you're saying is irrational because the data is going right.
Because the data and flow is perfect when I create an independent software.Answer 7 I showed it to the plug-in pictures.

ThePrelior:
I understand that you’re trying to help, but what you’re saying is irrational because the data is going right.

Then why are you asking for help?

My guess is that it is NOT going right

…R

I find it.This weight sensor "hx711" prevents the two data from going off.
When I cut off the power of "Hx711" everything went back to normal.
But when I give him his strength, it's the same.

ThePrelior:
I dont understand please do you explain me with example ?

GolamMostafa:
Please, observe that there are differences in the (a) 'number of variables' send/receive, (b) in the names of the variables send/receive, and (c) in the order of variables send/receive.

(a) You are sending 11 variables from UNO; but, you are receiving only 10 variables at the NodeMCU.

(b) At the sender side, you have variable named 'CRC_hesaplanan' after the 'P' tag; at the NodeMCU side you have the name 'CRC_recv ' attached with tage 'P'. It is good to have consistent names.

(c) At the sender side, you are sending 'weight' and then 'okunan_sut'; at the NodeMCU side, you are receiving 'weight' and then 'CRC_recv'. You should receive first what you have sent first.