Tool for sending bytes

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 ?

  • Kind a like that, an inexpensive Arduino Pro Min receives ASCII characters on pin 1, convert to byte, transmits out on pin 2.

  • Done similar on RealTerm.

I’m using a terminal program on a tablet for my Arduino setups; it includes that ability, though I haven’t used it. Just a minute…

It’s called SerialUSBTerminal, and was mentioned here on the forum; the author, “kai'“, either is or was a member.

Works like a charm, though there are occasional ‘hangs’ when plugging/unplugging USB a lot; that could be the tablet, not his code, don’t know.

Might require a USB-serial conversion, don’t know from your description.

A standalone tool you could make.

I’m beginning to repeat myself (old :old_man:).

  • An Arduino Pro Mini receives an IR remote character, it then sends a binary character out the serial port.

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

$ printf "ab\000\t\ncd\012\013\014\015\036\037ef" | pbcopy

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 :slight_smile:

I use cool term on my Mac (exists for Linux and Windows)

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.

A few things for me to try !
Thx guys

edit used Real term and a test Arduino program and I can now send bytes !

@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.

$port = New-Object System.IO.Ports.SerialPort 'COM??', 9600
$port.open()
[byte[]] $dataToSend = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,0x08,0x09,0x0A
$port.Write($dataToSend,0,$dataToSend.Count)
$port.close()

I googled this to make sure I had it right and it tested fine

Yep, that’ll do it. But I prefer the wife’s recipe tablet when working on the layout, much lighter, no power cord. YMMV!