0

Trying to get the weight from the weighing scale through a port connected to a USB that's connected to my android phone. The data is coming through but I don't know how to convert it properly. This is the code I'm currently using to convert the data:

try {
    String data = new String(arg0, "UTF-8");

    if (mHandler != null)
        mHandler.obtainMessage(MESSAGE_FROM_SERIAL_PORT, data).sendToTarget();
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
}

This is what I'm currently getting:

enter image description here

The number 14700t was supposed to show on the textview.

Jeff
  • 12,555
  • 5
  • 33
  • 60
  • Welcome to Stack Overflow! Please review our [SO Question Checklist](http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist) to help you to ask a good question, and thus get a good answer. – Joe C Nov 02 '16 at 20:45
  • you must have specs of the thing u are connected. only it can say which bytes corresponds to the weight and whatever unit it is – ugur Nov 02 '16 at 21:17
  • Try print `arg0` as `byte[]` values and analyze them. Probably `"UTF-8"` is wrong encoding. – Andrii Omelchenko Nov 02 '16 at 21:25

0 Answers0