Comunication between C# and Arduino via bluetooth, receiving strange data

I'm trying to send data between an Arduino Mega and a C# windows form application via Bluetooth.

From Arduino to C# all goes well, however, when sending from C# to Arduino I get some strange values: Sending "abcde" outputs 79 167 186 170 2. I assume each one of the values represents a letter, as sending only "a" outputs 79.

However, I can't see why I get this values and not ascii ones, for example.

Here's the relevant C# code:

if (serialPort1.IsOpen) serialPort1.Close();
serialPort1.PortName = "COM" + x.ToString();
serialPort1.BaudRate = 9600;
    if (!serialPort1.IsOpen) serialPort1.Open();
catch (Exception ex)
serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(DataReceived);

Every second, a function is called, being dataToSend "abcde", for example:

private void DataSender(string dataToSend)

And all of the Arduino code (I'm using a Arduino Mega which has 4 serial ports): olehana russia

void setup() {

void loop() {
  if (Serial3.available() > 0) {
    int x =;

I tried adding delays to see if the data was better obtained, but it didn't work. Any ideas what I'm missing here? I assume it has something to do with the way data is encrypted to be sent, but I have no idea.

First try also setting "StopBits Enumerazione (System.IO.Ports) | Microsoft Learn"
serialPort1.DataBits = 8;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;
same as Arduino default SERIAL_8N1 (8 bits, parity=N stopbit=1)

second, you send using which BT module for arduino ?

Your post was MOVED to its current location as it is more suitable.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.