I am trying desperately to get a Bluetooth dongle working with my Arduino but I can't send it a command that it needs. I can use it when I plug it into my computer via a USB to UART chip and send the command (C
) from PuTTY and then press Enter
.
The Bluetooth dongle's command sheet says that the command I am trying to send it C<cr>
but I can't figure out how to send the proper carriage return character from the Arduino code. I have tried using the Serial.println()
function as well as adding the \r
character to my current Serial.write("C\r")
but neither of those are working.
How can I achieve this?
I found that it is possible to press CTRL+J to send - but I would like to press just enter. Someone advised to set Terminal->"Implicit CR in every LF". But this does not work for me (I assume it is for what putty receives not send).
In Putty, there are several options that are related to CR (“\r”) or LF (“\n”) but none of them makes pressing enter key sends both CR and LF.
The modified PuTTY is the easiest solution. If you want to stick with the standard PuTTY, there's some other options... You can send a newline using ctrl+j before pressing enter, but that's a faff. To automate it, you can use AutoHotKey to change your {ENTER} to ^J {ENTER} when you've got a PuTTY window active:
My scope clearly shows that Putty's default is to send only. This is not documented. @carveone, I found the docs here, see sec. 4.6.14:<br/> By default, PuTTY sends the Telnet New Line code when you press Return, instead of sending Control-M as it does in most other protocols.
Sending CR+LF is possible in modified PuTTY. Source code is available at https://github.com/gniemirowski/putty-crlf and Windows binary at https://www.grzegorz.net/pliki/putty-crlf.zip When you run this version just go to Terminal -> Keyboard and select "CR LF" for "The Enter key" option.
Interestingly, I can report the opposite on Win 7: PuTTY for me and my embedded project is sending ONLY \r
over the COM port. Curious, read: frustratingly unexplainable, but I simply look for either character on the other end of the serial connection.
Then, if you enable "Implicit LF in every CR" under Terminal options it will send both \r\n
. Default behaviour seems to be akin to a Commodore machine :D (http://en.wikipedia.org/wiki/Newline). who knew...
PuTTY emulates xterm which emulates vt100. To have putty send CR/LF when pressing enter, type ESC[20h in putty after connecting to the serial device. This sets VT100 LNM true.
http://vt100.net/docs/vt100-ug/chapter3.html
Line feed/new line New line ESC [20h Line feed ESC [20l
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With