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
asked Jun 21, 2020 at 19:16
6
  • 1
    Sounds like you have a baud rate mismatch. Commented Jun 21, 2020 at 19:16
  • you are correct from looking at datasheet. thank you! Commented Jun 21, 2020 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? Commented Jun 21, 2020 at 19:31
  • 1
    98 and b are the same thing. Just different ways of representing the data. Commented Jun 21, 2020 at 19:34
  • 2
    replace %u with %c Commented Jun 21, 2020 at 19:35

2 Answers 2

1

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

answered Jun 30, 2020 at 8:07
0

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

answered Jun 29, 2020 at 23:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.