Remove char coming from rs232

??? I have rs232 to ttl converter module.
??? I want remove some alphabetic char coming from rs232.

Data was coming from rs232 is,
"SUI 0.00 G"
So i want remove first 3 characters,some space and last one character after then i want write only number
:frowning: So please help me how can i do this........

:slight_smile: This is my code.

#include <SoftwareSerial.h>
// software serial #1: RX = digital pin 10, TX = digital pin 11
SoftwareSerial portOne(10, 11);

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
portOne.begin(9600);
}

void loop() {
portOne.listen();
while (portOne.available() > 0) {
byte inByte = portOne.read();
Serial.write(inByte);
}
}

855802596_127958.jpg

How do you know what is the start of the sequence?
How do you know what is the end of the sequence?

I don't know what is the start and end of the sequence?

Well, if you don't know that, how are you going to write your software?

Does your sequence/message always contain S or SUI as the first character (s) and G as the last character?

:frowning: Yes FIRST SUI and last G both are fixed characters..
:slight_smile: So this characters i want to remove it .....

Since you only want the number, make the Serial write conditional on the byte read being the ascii values for a number, period, carriage return, or line feed.

:oCan you explain by giving a small example?

isdigit

kalp_sony:
:frowning: Yes FIRST SUI and last G both are fixed characters..
:slight_smile: So this characters i want to remove it .....

1. Do you have two Arduino boards?

2. If yes, designate UNO as receiver and NANO as sender.

3. Connect UNO and NANO as per following diagram using software UART Ports.
uartms-1.png

4. Create a sketch for NANO (save as nanoS) to send this message: "SUIxxxxx1.23G" to UNO at 1-sec interval.

5. Create a sketch for UNO (save as unoR) to receive the message from NANO, show it in Serial Monitor, and save in an array. You can use function like the following to receive the string sent by NANO:

SUART.readBytesUntil('G', myData, 20);

6 Your UNO screen will look like:
smFx.png

7. Add codes with your UNO sketch to derive 1.23 from the received string.

BTW: There are many more ways to retrieve the float number from the received string -- see Arduino Reference Manual.
(1) You can the following function to parse the incoming string as it is being stored in the buffer to retrieve the float number.

float x = SUART.parseFloat();

The UNO screen looks like:
smFx1.png

But, there are good reasons for your message to contain the known preamble (SUI) and postamble (G). You must respect these two known tokens and utilize them to be sure that you are extracting float number from a message that is intended to you. Therefore:
(1) The UNO sketch should include codes to check that SUI is found.

#include<SoftwareSerial.h>
SoftwareSerial SUART(6, 7);

bool flag1 = false;

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);
}

void loop()
{
  byte n = SUART.available();
  if (n != 0)
  {
    if (flag1 == false)
    {
      flag1 = SUART.find("SUI");
    }
    else
    {
      float x = SUART.parseFloat();
      Serial.println(x, 2);
    }
    Serial.println("=======================");
  }
}

smfx2.png

uartms-1.png

smFx.png

smFx1.png

smfx2.png

:money_mouth_face: :money_mouth_face: Thank you so much Mr.Golam Mostafa.
:money_mouth_face: :money_mouth_face: its working perfectly thank you very much................