Arduino Communication with a Texas Chip Over Serial

Hi, I have a BQ76PL455 ti. I want to communicate this chip with Arduino. But I did not find a way to send a hex. When I try to send the following code, the Arduino compiler gives an overload error.

void setup() {
  
Serial1.begin(250000);
}

void loop() {
 
    Serial1.write(0x8901000A00DA83);
  }
}

I added the PDF of the TI chip in case anyone wanted to review it.

Thank you from now.

You need to store each pair of hex digits as a separate byte:
uint8_t msg[] = {0x89, 0x01, 0x00, 0x0A, 0x00, 0xDA, 0x83};

and then you can write it like this:

Serial1.write(msg,sizeof(msg));

Pete

Thank you for your answer.

Also response will be hex too. Which variable should I save this response? Should I parse this coming message too?

Also response will be hex too.

No, it will be in binary which is also what you will send. Hex is just a way to represent the value in a byte. If a byte has a hex value of 0x12 you equally have written this in decimal as 18 or in binary as 0B00010010. If you're an old geezer like me you could even write it in octal as 022. They all represent the same quantity.

Which variable should I save this response?

Depends how long the response will be. You could also re-use this same variable for other responses, in which case you would declare it to be as long as the longest response that you are expecting. If all responses are going to be less than, for example, 20 bytes then I'd declare a variable to have 24 bytes just to be sure.

uint8_t response[24];

Should I parse this coming message too?

You should always check whatever response you get to make sure that whatever message you've just sent was received correctly.

Pete

I solved the problem, thank you. You're really very helpful. :slight_smile:

Rorschac:
I solved the problem, thank you. You're really very helpful. :slight_smile:

But, there are questions to ask -- why the number 0x8901000A00DA83 is to be broken into byte oriented chunks in order to use this command:

Serial.write(msg, sizeof(msg));

The number can also be sent using this command: The number should not be sent in the following format as the the receiving instrument (Q76PL455 ti) demands natural binary numbers. See Post#6 of @el_supremo

Serial.print("8901000A00DA83");

Then, what are the merits and demerits of sending the number using either of the following two commands:

Serial.write(msg, sizeof(msg)); 
Serial.print("8901000A00DA83");

The number can also be sent using this command:

Serial.print("8901000A00DA83");

No it can't. That is not the same as sending this:

uint8_t msg[] = {0x89, 0x01, 0x00, 0x0A, 0x00, 0xDA, 0x83};
.
.
Serial1.write(msg,sizeof(msg));

which is what the device is expecting.

Pete

@el_supremo

You are right! The receiving device (Q76PL455 ti.) demands that the incoming bytes must be natural binary numbers.

Thank you for the prompt reply that helped me to convert my ignorance into knowledge.

I have one doubt. after giving this program we will get a response? or we need to initialise anything?
I want to get a voltage reading along with temperature how to modify the program?
the command for voltage is 81 01 02 01 B95C
for temperature sensor am connecting to the 8 AUX pins. how should I program? please help me, sir

void setup()
{

Serial.begin(250000);
}

void loop()
{

uint8_t msg[] = {0x81, 0x01, 0x02, 0x01, 0x00, 0XB9, 0x5C};
Serial.write(msg,sizeof(msg));
delay(1000);
}

am using Arduino UNO board. while loop testing I am getting an error.
I want to connect with BQ76PL455A-Q1. Could you please help me with this programming part?