I am trying to send data from one esp32 to another esp32. But when the receiving end, esp32, receives data, it is something different, so I am not getting how the data is changed there or what I am doing wrong.
Here is my code master which is send data .
#include <HardwareSerial.h>
HardwareSerial SerialPort(2);
String number[10];
void setup()
{
Serial.begin(115200);
SerialPort.begin(15200, SERIAL_8N1, 16, 17);
for (int i=0;i<10;++i) {
number[i] = i;
}
Serial.println(number[5]);
}
void loop()
{
for(int i=0;i<9;++i) {
SerialPort.print(number[i]);
}
}
At void setup, I stored an array with an int and tested with Serial.println(number[5]);
and I could verify that the data is present in that.
and at void loop i am sending a data
for(int i=0;i<9;++i) {
SerialPort.print(number[i]);
}
This is the slave code here, receiving end -
#include <HardwareSerial.h>
HardwareSerial SerialPort(2);
String number[10];
void setup() {
Serial.begin(115200);
SerialPort.begin(15200, SERIAL_8N1, 16, 17);
}
void loop() {
if(SerialPort.available()) {
for (int i=0;i<9;++i) {
number[i] = SerialPort.read();
}
}
Serial.println(number[5]);
}
Here I am checking if the data is received and, if yes, storing it in the array. but when I print
Serial.println(number[5]);
The output should be 5 but i am getting output as 185
The output should be 5
Thank You