SerialTransfer Library example code can't send other than char

Hello everyone,
i'm having a problem with SerialTransfer library. i want to send a data from my NodeMcu to an arduino nano so i look for a library that can help me with that, and i found this SerialTransfer library.
I've tried to look for the answer in the topic with the serialTransfer, and tried it but in my case it still happens.
i tried the example code that comes with the library and modified the example code for Node MCU and my Nano.
I'm commenting the array cause when i try to send array, i get ERROR: CRC_ERROR in teh receiver side.

This is the code:
NodeMCU code (transmitter)

#include "SerialTransfer.h"
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>

//setting software serial
SoftwareSerial serialEsp(4,5);// 4-> D2 (RX) 5-> D1 (TX)

SerialTransfer myTransfer;

struct STRUCT {
  char z;
  float y;
} testStruct;

//char arr[] = "hello";


void setup()
{
  Serial.begin(115200);
  serialEsp.begin(115200);
  myTransfer.begin(serialEsp);

  testStruct.z = '$';
  testStruct.y = 4.50;
}


void loop()
{
  // use this variable to keep track of how many
  // bytes we're stuffing in the transmit buffer
  uint16_t sendSize = 0;

  ///////////////////////////////////////// Stuff buffer with struct
  sendSize = myTransfer.txObj(testStruct, sendSize);

  ///////////////////////////////////////// Stuff buffer with array
  //sendSize = myTransfer.txObj(arr, sendSize);

  ///////////////////////////////////////// Send buffer
  myTransfer.sendData(sendSize);
  delay(2000);
}

And The code for my Nano (receiver) is:

#include "SerialTransfer.h"
#include <SoftwareSerial.h>

//setting software serial
SoftwareSerial serialNano(2,3);//RX = 2 TX = 3

SerialTransfer myTransfer;

struct STRUCT {
  char z;
  float y;
} testStruct;

//char arr[6];


void setup()
{
  Serial.begin(115200);
  serialNano.begin(115200);
  myTransfer.begin(serialNano);
}


void loop()
{
  if(myTransfer.available())
  {
    // use this variable to keep track of how many
    // bytes we've processed from the receive buffer
    uint16_t recSize = 0;

    recSize = myTransfer.rxObj(testStruct, recSize);
    Serial.print(testStruct.z);
    Serial.print(testStruct.y);
    Serial.print(" | ");

    //recSize = myTransfer.rxObj(arr, recSize);
    //Serial.println(arr);
  }
}

wen i run those code on my system i only get

$0.00 | $0.00 | $0.00 |

It also happen when i tried to change the y with int. i get $0 on the receiver side.

i dont know where did i do wrong....
Thanks in advance

Could be packing difference between the two architectures. On both the ESP and Nano, try adding the following line to the setup() function:

  Serial.println(sizeof(testStruct));

Compare the two values that you get.

Welcome

struct __attribute__((packed)) STRUCT

Why did you remove this attribute? It's important

okay let me try this

im sorry
i don't see this line of code in the uart_rx_data.ino in the example file.
i just add the softwareserial pin an commenting the array. not deleting any other line.

I tried to add the line int the setup and here is what i got:
In the NodeMcu -> 8
In the nano -> 5

does the testStruct size printed should be the same in both side?

The struct is serialized and deserialized, as a serie of bytes, so yes it must be the same number of bytes on both sides

Did you try with __attribute__((packed)) ?

like this?

Yes, like in the example of the library

I see it was added recently, maybe you use an older version of the library

hei it works,
by adding those line to the struct line it now works....
thank you very much..

then i tried uncomment the array and tries to send the 'hello' char array.
but then all i get is the ERROR: CRC_ERROR

can we send array and the testStruct data in one go like one in the example file?

Post your complete new code, both TX and RX.

Hello @gfvalvo, sorry for the delay...just took a day off from work yesterday.
the code is same with the example just add the SoftwareSerial pin.
here is the code on NodeMcu as transmitter:

#include <ESP8266WiFi.h>
#include "SerialTransfer.h"
#include <SoftwareSerial.h>

SerialTransfer myTransfer;

//setting software serial
SoftwareSerial serialEsp(4,5);// 4-> D2 (RX) 5-> D1 (TX)

struct __attribute__((packed)) STRUCT {
  char z;
  float y;
} testStruct;

char arr[] = "hello";


void setup()
{
  Serial.begin(115200);
  serialEsp.begin(115200);
  myTransfer.begin(serialEsp);

  testStruct.z = '$';
  testStruct.y = 4.5;
}


void loop()
{
  // use this variable to keep track of how many
  // bytes we're stuffing in the transmit buffer
  uint16_t sendSize = 0;

  ///////////////////////////////////////// Stuff buffer with struct
  sendSize = myTransfer.txObj(testStruct, sendSize);

  ///////////////////////////////////////// Stuff buffer with array
  sendSize = myTransfer.txObj(arr, sendSize);

  ///////////////////////////////////////// Send buffer
  myTransfer.sendData(sendSize);
  delay(2000);
}

And here is the code for Nano as the receiver:

#include "SerialTransfer.h"
#include <SoftwareSerial.h>

SerialTransfer myTransfer;

//setting software serial
SoftwareSerial serialNano(2,3);//RX = 2 TX = 3

struct __attribute__((packed)) STRUCT {
  char z;
  float y;
} testStruct;

char arr[6];


void setup()
{
  Serial.begin(115200);
  serialNano.begin(115200);
  myTransfer.begin(serialNano);
}


void loop()
{
  if(myTransfer.available())
  {
    // use this variable to keep track of how many
    // bytes we've processed from the receive buffer
    uint16_t recSize = 0;

    recSize = myTransfer.rxObj(testStruct, recSize);
    Serial.print(testStruct.z);
    Serial.print(testStruct.y);
    Serial.print(" | ");

    recSize = myTransfer.rxObj(arr, recSize);
    Serial.println(arr);
  }
}

After i download those code to my board i'm only getting ERROR: CRC_ERROR on the receiver side.