Just for testing purposes I’m looking for something where I can type in a byte value and send it over a serial connection to an Arduino. Best still multiple bytes .
For example if I just use the IDE serial monitor and type “30” , then that is sent as two bytes ( “3” and “0”) rather than a single byte value 30.
I’ve looked at Putty and can’t sort it in that .
Any ideas ? I could only think of having another Arduino that takes in my value off the serial Monitor and I interprets it as a byte and serial.writes it to another port .
Bit messy tho !
Am I missing something obvious ?
Printable -- and therefore easy to type and see -- ASCII is between 32 (space) and 126 (tilde). But if you can get the characters into the clipboard, you can paste them into the Serial Monitor and it will send them, with some exceptions. First the test sketch
void setup() {
Serial.begin(115200);
}
void loop() {
if (Serial.available()) {
Serial.println();
while (Serial.available()) {
auto c = Serial.read();
if (c < 0x10) Serial.print('0');
Serial.print(c, HEX);
Serial.print(' ');
delay(1); // let the next character "move over" and become available
}
}
}
To copy into the clipboard on a Mac, use pbcopy; Linux has xsel or wl-copy. Good luck with Windows
Command-line printf takes octal, and a few hard-coded escape sequences. So that's
ab
NUL (zero)
TAB and NL
cd
10 (newline again) through 13 (CR)
30 and 31
ef
which gets piped into the clipboard. Pasting that into the Serial Monitor, you just see the three pairs of letters, spaced out. With New Line (instead of No Line Ending) turned on, pressing Enter prints
61 62 00 09 20 63 64 20 0B 0C 20 1E 1F 65 66 0A
So the ones that don't work are NL and CR -- they get turned into spaces (20 hex). There might be one or two more. The 0A at the end is the New Line sent by the Serial Monitor.
I use picocom terminal and it is able to send files to Serial port. So I may prepare file anyhow and it sends every byte in the file. Maybe few kilobytes long, mayby just one byte short
For sending raw byte values over serial to an Arduino, use a terminal that supports sending bytes instead of ASCII, like RealTerm. Set it to “Send Numbers” mode or use the “Hex” input, so typing 30 sends a single byte 0x1E instead of characters '3' and '0'. No extra Arduino needed.
@hammy I am glad your question is resolved, I would like to add for you or anyone else with a similar problem if all you need is to test sending a byte or two an alternative is , if you have access to , use Windows Powershell.