Heltec Wifi Esp32 not displaying the correct entry

Hello there,
I tried to establish a communication between two Esp32 and I managed to send and receive a message I entered (Even though it’s only 1 character…)

In fact, the program sends the character by sending a number, and my other device is supposed to convert it again into a char
The thing is: When I want to display that character, even not converted instead it displays a number which is not the result of the first conversion
For example, I want to send “f”, then my card sends 102
My other card receives the number, but displays 50

I pretty sure the problem comes from how I play with numbers and conversions but I can’t manage to find what’s wrong

Could you please help me ?
Thanks a lot
I’ve attached the Sender and the Receiver

Receiver.ino (1.37 KB)

Sender.ino (1.59 KB)

I updated my code a bit
In fact I can send complete sentences, up to a certain limit
Also my receiver says it received 49 then 48 then 56 for a “l”
I have only one print but these 3 numbers appear on my serial monitor

Sender.ino (1.59 KB)

Receiver.ino (1.36 KB)

  String rx_str = "";
  int rx_byte =0;
  char finalText[100];
  rx_str.toCharArray(finalText, rx_str.length()+1 );

This is complete rubbish. The toCharArray() functions KNOWS how long the object it is called for is. It does NOT need you to tell it that.

The second argument is supposed to be how big the array is.

You KNOW that the String has nothing in it. So why are you copying the data from the String to an array, when you KNOW that there is nothing in the String?

   if(rx_byte != 0 and rx_byte != 10){

If you are entering data in the Serial Monitor app, that app NEVER sends a 0. So, the test for not equal to 0 is unnecessary.


Why on earth do you need a String, to hold ONE character? Is the print() method of that class properly overloaded to deal with a String?

     int recep;
      recep = LoRa.read();

If there is data to read, read() returns the data in the low order byte. Since it was text that you sent, the type to store the data in should be a character type, not an int.

     reception = String(recep);

Converting the int to a string, and storing the string in a String instance is not even remotely close to the way to get the character that was sent back.

I’m gonna try to answer all your questions, but keep in mind that I’m a complete newbie,
even if I could have done things otherwise I’m not at all used to all this

First, for the rubbish, I was sort of preparing for the “drawstring”, because it asked for an array of char’s
Must have messed things up in the process

For the zero, I forgot to remove it; at the beginning I thought the byte could have 0 if no value was declared

For the string, I copied that part of code on another website

I couldn’t get recep in a char form right away because it sends an error if I recall correctly

And last, that’s why I’m here, I have no idea on how to get the right thing

Thanks for your help though

Other thing: I'm getting this while inactive:

Hello there,
I'm still quite not sure of what I can do for this code,

I tried reading the byte then putting it directly into a char instead of an int but I get this error : incompatible types in assignment of 'int' to 'char [3]'

if I remove the array things froml that char I get this error : invalid conversion from 'char' to 'const char*' [-fpermissive]

If I put a * after char I get this one: invalid conversion from 'int' to 'char*' [-fpermissive]

Could you please help me ?

I tried this but it crashes everytime I receive a message

04-06-2018.ino (1.52 KB)

    char *toast[100];
    char recep = 'a';
    int index = 0;
    bool available = false;
    while (LoRa.available() and index < sizeof(toast) -1) {
    recep = (char)LoRa.read();
    available = true;
    index += 1;
    toast[index] = (char*)recep;

Why on earth is toast an array of pointers? Why are you casting a char to a pointer to a char? Some casts make sense. This one does NOT.

Well I'm putting every char from the Read into an array of char
It's not like that ?

Well I'm putting every char from the Read into an array of char

toast is NOT an array of char.

Well you just lost me then

Well you just lost me then

Can you not tell the difference between an array of char and an array of pointer to char?

As much as you'd like to pretend that they are the same, there is a HUGE difference.