LoRa 1278 Usage and Data Transmission

I’m working on a project, and this project is about sending one arduino card’s data to another arduino card. Data received gps coordinate, speed, altitude, voltage, g force measurement and the status of 3 buttons.

However, this data should be organized in a certain format. This format is to put “" between all data. This is because when data arrives in c #, it separates the numbers with "” between them.

as follows: sdgfhkk - ekşi up

Question 1: Is there a way to combine this data into one line on Arduino? If so what is the code?

In my own experiments, I found that the data to the other side was “Hello World”. That’s why I found this article in the code.

int state = lora.transmit (“Hello World”);

I thought he was sending the data after the equal sign. And I tried to edit the equal sign. And indeed I could not.

Here you can see the code I wrote.

The data that has to be printed.
Question 2: How should I edit this code?

http://www.cplusplus.com/reference/cstring/strcat/

For string manipulation. Or you can use +=

https://www.arduino.cc/en/Tutorial/StringAppendOperator

Is there a way to combine this data into one line on Arduino?

Use snprintf(). Example, for integers i1,i2,i3:

char line[20];
snprintf(line,sizeof(line),"*%d*%d*%d*",i1,i2,i3);
Serial.println(line);

I think I should use a join method that can use both int and float.

unfortunately it didn't output as it should.

result : https://eksiup.com/p/v791729nuoqf

t should be like: 32.125236*3.45*1

czu001: http://www.cplusplus.com/reference/cstring/strcat/

For string manipulation. Or you can use +=

https://www.arduino.cc/en/Tutorial/StringAppendOperator

Unfortunately, it did not happen

result https://eksiup.com/p/jf91732hs49c

When making a sentence to send serially I do this thing:

void fSendLIDAR_InfoSerialToBrain( void *pvParameters )
{
  struct stu_LIDAR_INFO pxLIDAR_INFO;
  for ( ;; )
  {
    xEventGroupWaitBits (eg, evtGetIMU, pdTRUE, pdTRUE, portMAX_DELAY);
    xSemaphoreTake( sema_LIDAR_FOR_ALARM, xSemaphoreTicksToWait );
    xQueueReceive ( xQ_LIDAR_FOR_ALARM, &pxLIDAR_INFO, QueueReceiveDelayTime );
    xSemaphoreGive( sema_LIDAR_FOR_ALARM );
    int CellCount = 1 ;
    String sSerial = "";
    sSerial.reserve ( 300 );
    sSerial.concat( "<#," ); //sentence begin
    sSerial.concat( String(ScanPoints) + "," );
    sSerial.concat( String(pxLIDAR_INFO.ServoSweepUp) + "," ); // get direction of scan
    for ( CellCount; CellCount <= ScanPoints; CellCount++ )
    {
      sSerial.concat( String(pxLIDAR_INFO.Range[CellCount]) + "," );
    }
    sSerial.concat( ">" ); //sentence end
    vTaskDelay( 10 );
    SerialBrain.println ( sSerial );
  }
  vTaskDelete( NULL );
} // void fSendLIDAAR_InfoSerialToBrain( void *pvParameters )
////

As you may be able to see, I create a sized string buffer to hold the serial sentence. I then add in the sentence begin and a “#” sing to indicate type of operation. For other operations I’d use ! or @ or % or what every I want to indicate to the receiving parser what that data sentence is about. I then add in the data, delimited by a “,”, then I close the sentence, and send it off to the receiver.

Idahowalker:
When making a sentence to send serially I do this thing:

void fSendLIDAR_InfoSerialToBrain( void *pvParameters )

{
  struct stu_LIDAR_INFO pxLIDAR_INFO;
  for ( ;; )
  {
    xEventGroupWaitBits (eg, evtGetIMU, pdTRUE, pdTRUE, portMAX_DELAY);
    xSemaphoreTake( sema_LIDAR_FOR_ALARM, xSemaphoreTicksToWait );
    xQueueReceive ( xQ_LIDAR_FOR_ALARM, &pxLIDAR_INFO, QueueReceiveDelayTime );
    xSemaphoreGive( sema_LIDAR_FOR_ALARM );
    int CellCount = 1 ;
    String sSerial = “”;
    sSerial.reserve ( 300 );
    sSerial.concat( “<#,” ); //sentence begin
    sSerial.concat( String(ScanPoints) + “,” );
    sSerial.concat( String(pxLIDAR_INFO.ServoSweepUp) + “,” ); // get direction of scan
    for ( CellCount; CellCount <= ScanPoints; CellCount++ )
    {
      sSerial.concat( String(pxLIDAR_INFO.Range[CellCount]) + “,” );
    }
    sSerial.concat( “>” ); //sentence end
    vTaskDelay( 10 );
    SerialBrain.println ( sSerial );
  }
  vTaskDelete( NULL );
} // void fSendLIDAAR_InfoSerialToBrain( void *pvParameters )
////




As you may be able to see, I create a sized string buffer to hold the serial sentence. I then add in the sentence begin and a "#" sing to indicate type of operation. For other operations I'd use ! or @ or % or what every I want to indicate to the receiving parser what that data sentence is about. I then add in the data, delimited by a ",", then I close the sentence, and send it off to the receiver.

unfortunately the codes came very confused and couldn’t.

Could you be more specific?

haliflex_95: Unfortunately, it did not happen

result https://eksiup.com/p/jf91732hs49c

Of course it didn't happen. Look at your code. I don't even see an attempt to add your * character. You need to convert your numbers to a string and then concatenate them to create a new string with delimiters. Try Googling "Arduino Convert numbers to string". The reference in an earlier post to snprintf() can also work.

http://www.cplusplus.com/reference/cstdio/snprintf/