Send array data through HardwareSerial.h UART

Hello,
Sending Array code

#include <HardwareSerial.h>

HardwareSerial SerialPort(2); // use UART2

byte maclist[10];
void setup()  
{
  Serial.begin(115200);
  SerialPort.begin(15200, SERIAL_8N1, 16, 17); 
   for (int i =0;i<10;++i) {
    maclist[i] = i;
  }
} 
void loop()  
{ 
  Serial.write(maclist, 8);

  
}

Now I don't know how to receive this array i tried many times didn't work.

Do you really intend to use 15200 baud instead of 115200? Does the serial port support that speed?

I don't know I think no. can this be a problem??

I'm not familiar with any hardwareserial library, or which board needs that to set up a 2nd serial port, so can't help you much, but you will need to have the sending and receiving boards set to the same baud rate, and it needs to be a baud rate that actually works, I've never tried something non-standard such as 15200 baud.

it's not a common speed. 115200 is. if you open the Serial monitor, the magnifier-like icon near the top right of the IDE, the bit-rate (not baud) can be selected at the bottom.

unless these are the only bytes being transmitted, doesn't there need to be additional information identifying the data?

should this data be sent as an ascii string (e.g. "MAC EA:12:34:56:78:90") with a terminating NULL or line-feed char?

Baud Rate supported by UNO (partial list):

Yes, I was looking to send a Mac address. I have two esp-32s, one of which contains all the mac addresses in the form of an array. and from that esp32, I need to send that array to another esp32 and store it there in the form of an array. I was able to send single data, but in the type of array, I am not able to do it.

Did you try to receive it?
Please show your code.
Without code it is nothing to talk about...

byte incomingMac[9];

if(Serial.available())
    {
     for (int i=0; i<8; i++) { 
             incomingMac[i] = Serial.read();
 }
    }

But when i check incomingMac it's all 0

i'm working on using esp32 as model RR nodes connected vai WiFi.

my understanding is i can either use an IP address or the hostname of the device to establish a connection. so i'm planning on storing a table in EEPROM on each node with a list of other device hostnames, as well as a separate entry for that devices hostname, and i believe i can establish connections using host names (i.e. no need for a unique identifier (e.g. 192.168.1.20 or MAC)

1 Like

As a note EEPROM on the ESP32 has been depreciated. Use

instead.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.