HX750 Load Cell Amplifier

Hi Guys,
I have a HX750 amplifier which uses UART communication.

I am trying the following code but I am getting garbage.
I would be thankful if someone helps me program the loadcell.

I can't upload the amplifier datasheet since I am new here.

Thanks

#include <SoftwareSerial.h>
SoftwareSerial TRY_Serial(2, 3); // Arduino RX, Arduino TX
byte message[] = {0xB0, 0x31, 0xE1};
char val;
String readString;
void setup() {
Serial.begin(9600);
TRY_Serial.begin(9600);
}
void loop() {
Serial.println(0xB0);
Serial.println(0x31);
Serial.println(0xE1);
//Serial.write(message, sizeof(message));

while (TRY_Serial.available()) {
    delay(1000);  //small delay to allow input buffer to fill

    char c = TRY_Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      break;
    }  //breaks out of capture loop to print readstring
    readString += c; 
  } //makes the string readString  

  if (readString.length() >10) {
    Serial.println(readString); //prints string to serial port out

    readString=""; //clears variable for new input
  }
  
}

Garbage could be a baud rate issue. Can you post a link to the device you have?

HX750-TTL232Electronic Module User Manual .pdf (296.5 KB)
I found the datasheet

Thanks @wildbill for replying.
Can you please look at the datasheet
Thanks

According to the data sheet posted by @zeus2kx, the baud rate is right, but it looks like what you need to send and receive from the device is not human readable. It doesn't look especially complex, but it likely explains why what you got looked like garbage.

Thanks @wildbill .
I tried to understand the communication between computer and this amplifier (connected through FTDI cable) using a logic analyzer. Please see attached.
Channel 0 is send and channel 2 is received signal.

The logic analyzer output looks good, or at least it ties back to the data sheet. Can you try it again with some weight on?

@wildbill Yes sure. It does work with ftdi and their windows software.

software

The data input and output is as described in the datasheet.
You're interpreting the entire data you're getting as a humanly readable string, which it is not.
It is comprised of a 1 byte header, a 4 byte high order integer, and a 1 byte checksum.

@cookiefan
Thanks for replying.

I tried changing the serial write command but I need some help with reading the output.
Output of the code is:

?1111
#include <SoftwareSerial.h>
const int BUFFER_SIZE = 50;
char buf[BUFFER_SIZE];
SoftwareSerial TRY_Serial(2, 3); // Arduino RX, Arduino TX
//byte message[] = {0xB0, 0x31, 0xE1};
byte message[] = {0x00, 0xB0, 0x00, 0x31, 0x00, 0x31, 0x00, 0x31, 0x00, 0x31, 0x00, 0xE1};
char val;
String readString;

void setup() {
Serial.begin(9600);
TRY_Serial.begin(9600);
Serial.write(message, 12);
}

void loop() {
if (Serial.available() > 0) {
    // read the incoming bytes:
    int rlen = Serial.readBytes(buf, BUFFER_SIZE);

    // prints the received data
    Serial.print("I received: ");
    for(int i = 0; i < rlen; i++)
      Serial.print(buf[i]);
  }
  
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.