0

I'm experimenting with a hc-05 knockoff the JDY-30 and am confused about the Serial data I'm getting from it. I downloaded an app called BlueUino to send commands from my Android to my Arduino Uno via Bluetooth. I then print the data I get via Serial port using the code below:

  if(Serial.available() > 0){ // Checks whether data is comming from the serial port
    state = '1'; //Serial.read(); // Reads the data from the serial port0
    stateData = Serial.read();
    sprintf(data, "Data is %u", stateData);
    Serial.println(data);
    Serial.println();
 }

Here are some of the results I get in the log which I can't make sense of. For example, sending the string "def" doesn't contain the sequence of data from sending the command "e". Also, how does one convert these values to characters ?

Send Command "b"

Data is 128
Data is 0
Data is 248

Send Command "abc":

Data is 120 // doesn't contain the sequence of Data of "b"
Data is 120
Data is 120
Data is 0
Data is 120
Data is 0
Data is 248
  • 1
    Sounds like you have a baud rate mismatch. – Majenko Jun 21 at 19:16
  • you are correct from looking at datasheet. thank you! – I Like Jun 21 at 19:18
  • seems to work now. But still wondering how to convert data to characters. Example: 'b' is received as '98'. Where do i look up the corresponding char for the data? – I Like Jun 21 at 19:31
  • 1
    98 and b are the same thing. Just different ways of representing the data. – Majenko Jun 21 at 19:34
  • 2
    replace %u with %c – Juraj Jun 21 at 19:35
0

This might be sending the data in bytes so convert it and then try. You can convert it by doing String(data).

| improve this answer | |
0

Or just storing the inbound data in a char type and use single quotes when parsing incoming bytes so that the compiler knows your dealing with ASCII, print them out on serial and they should be familiar characters, of course with the baud rate mismatch fixed

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.