Go Down

Topic: Cannot read the Data from my Arduino Nano (Read 272 times) previous topic - next topic

Dirichlet92

Good day everyone,
I'm very new to this Arduino programming. But I already have a problem and cannot find an answer.
I hope someone can help.

I am using the Arduino Nano and have connected a temperatur sensor to it. When I open the Arduino Desktop App i can see that Data is being send through the "Serial Monitor".

I have now programmed a little programm with visual studio to read the data and have it shown on the screen.
But he never recieves any data. The problem is not the code ( I have checked with a friend, where it works ).

Maybe I have to activate something on my PC? Maybe Enable something? We are pretty helpless as to where the problem is.

Thanks for your help
 :)

PaulS

Quote
The problem is not the code
The problem is in one of three places - the code on the Arduino, the code on the PC, or the hardware.

Quote
I have checked with a friend, where it works
Well, that rules out the hardware then.

So, your initial assertion is false.
The art of getting good answers lies in asking good questions.

Dirichlet92

No, what I meant was that it works on his PC. But unfortunately not on mine.
What I did was, he send me his working exe. Started it on my PC but while it works on his
it doesnt work on mine.

sterretje

How about the Arduinos are on different com ports (for the different PCs) and the exe uses a hard-coded comport?
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Dirichlet92

No, the COM Port is not hard coded.
In the program it is on COM 4 and in the Arduino Desktop App Programm it is also on COM 4 and it works

Whandall

No, what I meant was that it works on his PC.
How could he test the programm with your Arduino?
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

Dirichlet92

He had the Arduino I am using now before. And now he is trying it with a different Arduino.
So I might have to change a setting on my arduino?

Whandall

Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

Dirichlet92

Okay, haha :) But thanks a lot for trying

sterretje

No, the COM Port is not hard coded.
In the program it is on COM 4 and in the Arduino Desktop App Programm it is also on COM 4 and it works
Do you have aerial monitor open while testing the exe? You are aware that only one application can use the serial port at a time.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Dirichlet92

No, the serial monitor is closed. I even closed the Arduino Desktop App just to make sure.

econjack


Dirichlet92

This is the Visual Studio Code, where it gets interesting. I hope it helps

    //Read Button

   private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
   // check if port is ready for reading
   if (this->serialPort1->IsOpen) {
      // Reset the text in the result label.
      this->textBox1->Text = String::Empty;

      // this will read manually
      try {
         this->textBox1->Text = this->serialPort1->ReadLine();
      }
      catch (TimeoutException^) {
         this->textBox1->Text = "Timeout Exception";
      }
      // Disable the init button
      // the asynchronous operation is done.
      this->button1->Enabled = false;
   }
   else
      // give error warning
      this->textBox1->Text = "Port Not Opened";

PaulS

Quote
where it gets interesting.
That snippet of code is what reads from the port, if it is open, in response to a button click.

I can not imagine why reading incoming serial data is dependent on the user having to click a button. I really can not imagine why the author couldn't be bothered to give the button a meaningful name. There isn't a hope in hell of understanding what button 4 is supposed to do.
The art of getting good answers lies in asking good questions.

Dirichlet92

As it is written above, it is the "read button".
This simple piece of code was for me to get a signal from the Arduino if I press the "read"/"button4".
And once the button is clicked the value given from the Arduino is supposed to appear in the text box.


Go Up