Serial Problem

Hello,

I want to read data from a device with serial data

The string 1 want to read is like

0F FB 00 04 00 00 00 01 F1 04

Now i get int the serial monitor converted to HEX

78 2 F7 FF FF FF FD 1D 1F

For

0F FB 01 04 00 00 00 01 F0 04

I get

78 2 7F DF FF FF FD 1F 1F

I cant find wicht conversion i need to do to get the right values.

Thanks

Did you forget something?

You need to post your code - otherwise we are blind.
And please use the code button </> so your code looks like this and is easy to copy to a text editor

Have a look at Serial Input Basics - simple reliable ways to receive data.

…R

I’m sorry,

Here is the code

#include <SoftwareSerial.h>


SoftwareSerial mySerial(11, 10); // RX, TX

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(38400);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("Hello");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(38400);


}

byte ReadOneByte()           // One Byte Read Function
{
  int ByteRead;
  while (!mySerial.available());
  ByteRead = mySerial.read();
  return ByteRead;
}

void loop() 
{
  byte PrintOneByte = ReadOneByte();
  
  Serial.println(PrintOneByte, HEX);

  Serial.println("----");
  
}
[code]

SoftwareSerial is pretty crude. Try it at 9600 baud and see if it is better.

…R

  int ByteRead;
  while (!mySerial.available());
  ByteRead = mySerial.read();
  return ByteRead;

Your function says that it returns a byte. So, why are you returning an int?

  byte PrintOneByte = ReadOneByte();

Why are you then storing that int in a byte?

If your code did what it said that it would, a clue-by-four just might whack you.