Go Down

Topic: Having issue with serial COM port Arduino Uno (Read 827 times) previous topic - next topic

SOSPleaseHelp

Mar 14, 2018, 04:59 pm Last Edit: Mar 14, 2018, 05:07 pm by SOSPleaseHelp
hi guys, so i am working on my project related to IoT monitoring of LM35 temperature sensor, i will have to display the temperature value to Blynk app via serial USB of arduino uno..

now i tried the most basic for serial USB example which is controlling a LED thru blynk app, it's of course successful. Before connecting to Blynk for IoT, i can see the serial output at serial monitor at arduino IDE
but now after combining my code with the basic Blynk LED control example in the Blynk libraries, my overall code is as shown below ( it can be succesfully compiled but not uploaded)

Code: [Select]

#include <SoftwareSerial.h>
SoftwareSerial DebugSerial (0, 1); //RX , TX
#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleStream.h>

char auth [] = "My auth token";
Declare the variables
int temp;
int temppin = 5;
int led1 = 7;
int led2 = 6;

void setup ()
{
  DebugSerial.begin(9600);
  Serial.begin(9600);
  Blynk.begin(auth, Serial);



  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
}

  void loop()
{
  temp = analogRead(temppin);
  float t = (temp / 1024.0) * 5000;
  float celsius = t / 10; //Celsius Temperature
  Serial.print("Temperature =");
  Serial.print(celsius);
  Serial.print("°C");
  Serial.println();
  delay(1000);
  if (celsius > 30)
  {
    digitalWrite(led2, HIGH);
    digitalWrite(led1, LOW);
  }
  else
  {
    digitalWrite(led2, LOW);
    digitalWrite(led1, HIGH);
  }
  if (celsius < 30)
  {
    digitalWrite(led1, HIGH);
    digitalWrite(led2, LOW);
  }
  else
  {
    digitalWrite(led2, HIGH);
    digitalWrite(led1, LOW);
  }

  {
    Blynk.run();
  }

}


i keep on getting error like when i tried to open serial monitor

Error opening serial port 'COM5'. (Port busy)

and when i tried to change baud rate at serial monitor it give

processing.app.SerialException: Error opening serial port 'COM5'.

i am not able to get the output display at Blynk app.

is it multiple serial usb not allowed? how should i solve it  :o  :(

Can anyone help me?

pert

Typically that error means some other program or process has the COM port open. In some cases that could even include Serial Monitor. Make sure to close any programs that might have COM5 open.

SOSPleaseHelp

Typically that error means some other program or process has the COM port open. In some cases that could even include Serial Monitor. Make sure to close any programs that might have COM5 open.
hmm...i am really confused right now,

is it 2 things are fighting over for com5?

my idea is to get the temperature sensor to be send to Blynk and show it in Blynk app...

sterretje

Not the cause of your problem (that's at the PC side) but this is sooooooo wrong
Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial (0, 1); //RX , TX

You do not use software serial on the hardware serial port. It's totally useless and in your code software serial and hardware serial will be fighting over the same two pins. The result is that, even once you have your COM problem sorted, it will not work.
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.

Go Up