0

I am trying to write String to serial in arduino ,

The string has multiple data types :

String sendID=("alarmWithPointer:" + String(12,DEC) ) ;//AlarmOncePointer

and Serial.write(sendID) gives error, so i tried :

 void sendDataSerial(String data)
 {

    int len=data.length()+1;
     char buf[len];
     data.toCharArray(buf, len) ;
     Serial.write(buf);

 }

Which also gives random numbers in the serial .

1 Answer 1

0

Have you tried to use Serial.Print() (ASCII characters) instead of Serial.Write() (binary data)?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.