Receiving data throught UART - sending it throught UDP

Hello Guys,

I’m working on a project: I’m trying to send data from a Renesas microcontroller to the Photon (Throught UART) and then send these data from the photon to a server (using UDP packet).

The first part of the project is working good (i can send a character throught UART)
And the second Part is also working good (I tryed to send a character from the photon and i can see it coming to the server using Putty) but it is not the same character that i sent.

Now i want to connect between the 2 parts of the project and try to send the same character to the server that i already received throught UART but i have always errors on my code…

Here is my code:

UDP Udp;
char Buffer1;                                   // This Buffer is used to save data coming from the Renesas controller
IPAddress remoteIP(10, 0, 40, 30);  // IP Adress of the server (Trac server)
int port = 48081;                            // Open port 
char buffer[];                     
void setup()
{

  Serial1.begin(57600);                      //  intialisation of the the UART  

}

void loop() {                                               

    while(Serial1.available()) {                                                                               
    Buffer1=Serial1.read(); // Read whats in the Serial port and store to Buffer1                     
    //Serial1.write("The Character you sent is  ");                                                   
    //Serial1.write(Buffer1);                                                                                
    
    buffer = Buffer1;  // put the received character into buffer to send it to server
   
     
    Udp.begin(48081);                                          
    Udp.sendPacket(buffer,1,remoteIP,port);
    Udp.stop();
}
} 

Thanks for Answering… :relieved:

Which errors? Don’t let us chase for them.

hello @ScruffR ,

here is the error:

/workspace/uart_writedata.cpp:6:13: error: storage size of ‘buffer’ isn’t known
#line 2

And this message is quite true
line 6

char buffer[];    

should be something like

char buffer[64];
// and further down
  buffer[0] = Buffer1;    

or

char buffer;
// and further down
  Udp.sendPacket(&buffer,1,remoteIP,port);
1 Like

Thanks a lot, it works… :grinning:

1 Like