Arduino sending information over serial interface to .NET based application...

Hello all,

I am using an Arduino Uno to read the values from a temperature probe.

I want to transmit the temperature values over the serial interface to a .NET based application, where I process the information and merge the values to a database.

However something along the serial configuration on the .NET side seems to be wrong...

The Arduino IDE has an inbuilt serial monitor - If I check the outgoing temperature values with this monitor, everything is correct - the values appear as expected, encapsulated in brackets.

data format: [14.45][14.50][14.75][14.83].....and so on....

In order to help debugging, I show here the concatenated serial string, which was received on the .NET application.

You can see that there are a lot of places where the data was not received as it shall be.

Of cause this messes up the algorithm, which interprets the incoming serial data...

So to conclude... Using the IDE serial monitor, correct data is displayed. Using the .NET application causes errors...

So there must most probably be a misconfiguration of the serial object of the .NET application (parity, stop bits or things the like).

The problem is, I am not a specialist in configuring the serial object…

Maybe there is a specialist here, who could have a look on the configuration of the serial object from the .NET application..

Here is the configuration of the serial object:

and

Help is highly appreciated...

Thx,

Andreas

I used the code at Arduino, C#, and Serial Interface - CodeProject
and it worked fine. The author gets a little fancy with the display of data in C#, but the communication between the Arduino and C# works.

you need to post the whole C# code (zip attach) as the config of the Serial object seems not the problem.

thank you - I will check this...

Here is another example I have just made with a new application dedicated to display the incoming serial data.

It seems after a short while it just gets out of sync for some reason...

Andreas

I just solved the problem myself :slight_smile:

thx anyhow for your help!!

To the problem: The .NET serial thing is nothing else than a thread in the background listening to the serial interface...

This thread can’t directly communicate to the UI thread (the form) - functions or methods have to be called by using invoke or beginInvoke...

invoke executes this synchronously and begin invoke asynchronously.

If in the asynchronous mode of operation, things get messed up! So Invoke is the solution – see screenshot.

To the problem: The .NET serial thing is nothing else than a thread in the background listening to the serial interface...

This thread can't directly communicate to the UI thread (the form) - functions or methods have to be called by using invoke or beginInvoke...

invoke executes this synchronously and begin invoke asynchronously.

If in the asynchronous mode of operation, things get messed up! So Invoke is the solution

We could have told you that at the beginning, if you had posted ALL of your code.

You might want to set the dtrEnable property to true, so you can talk to any Arduino. As is, your code won't talk to a Leonardo or Micro.

thx Paul - this is also a valuable information!

By the way, I have another question:

When I open the serial minitor of the Arduino IDE, the Arduino does somehow an automated reset.

When I open the serial connection with the .NET application, the Arduino does no reset.

So I guess the Arduino IDE serial monitor sends a command to reset the Arduino when opening the serial connection.

I would like to do know how to make this on the .NET side? Any ideas?

thx,

Andreas

Ok - my last question is also solved....

Setting the dtrEnable does exactly what I asked for - the Arduno gets resetted...

thx,

Andreas