Go Down

Topic: Serial communications (Read 388 times) previous topic - next topic

iwrk4dedpres

I'm playing with simple sensors on Arduino uno.  Using the serial communications to see results on my computer.  Great!

However, when I disconnect the Arduino Serial Monitor the LED's stop blinking ( TX ) and stay on steady.

1.  Is the sketch on the uno stopping?
2.  How do I make it so that if nothing is connected it continues to run.

3.  Is it possible to have more than one listener ( aka have the PLX DAQ    AND    Serial Montitor ) running at the same time?  ( realize this is a USB not Arduino issue.


Appreciate any help received!
Barry

aarg

#1
Jan 13, 2018, 11:01 pm Last Edit: Jan 13, 2018, 11:05 pm by aarg
1. Yes, if the serial transmit buffer fills up before it has a chance to be sent.
2. Stop sending reams of data that you don't use, to the serial port.
3. What is a PLX DAC?
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

CrossRoads

Post your code, use the code tag button </> and paste the code in the box.
Code: [Select]
So it looks like this
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

aarg

You can use this:
availableforwrite
but it will usually make for a complicated implementation
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

iwrk4dedpres

Ok ... this is the code but it's just code supplied from project kit I bought with modifications that I've been playing with.

Code: [Select]

#include <SimpleDHT.h>

// for DHT11,
//      VCC: 5V or 3V
//      GND: GND
//      DATA: 2
int pinDHT11 = 2;
SimpleDHT11 dht11;
int loopCounter = 0;

void setup() {
 Serial.begin(9600);
}

void loop() {
 // start working...
//  Serial.print(loopCounter);
//  Serial.print(" ");
//  Serial.print(millis());
//  Serial.println("=================================");
//  Serial.println("Sample DHT11...");
 
 // read with raw sample data.
 byte temperature = 0;
 byte humidity = 0;
 byte data[40] = {0};
 if (dht11.read(pinDHT11, &temperature, &humidity, data)) {
   Serial.print("Read DHT11 failed");
   delay(2000);
   return;
 }
 
//  Serial.print("Sample RAW Bits: ");
//  for (int i = 0; i < 40; i++) {
//    Serial.print((int)data[i]);
//    if (i > 0 && ((i + 1) % 4) == 0) {
//      Serial.print(' ');
//    }
//  }
//  Serial.println("");
 Serial.print("DATA,DATETIME,ElegooDHT111,");
 Serial.print(millis());
 Serial.print(",");
 for (int i = 0; i < 40; i++) {
   Serial.print((int)data[i]);
   if (i > 0 && ((i + 1) % 4) == 0) {
     Serial.print(',');
   }
 }
 Serial.println("");
 
 Serial.print("Sample OK: ");
 Serial.print((int)temperature); Serial.print(" *C, ");
 Serial.print((long)temperature*(1.8)+32); Serial.print(" *F, ");
 Serial.print((int)humidity); Serial.println(" %");
 
 // DHT11 sampling rate is 1HZ.
 delay(6000);
 loopCounter++;
}



I will look into the availablewrite information.   What I found and the PLX DAQ is from this link  CLICK HERE!

iwrk4dedpres

... also


When I have the sketch running and it's sending to say the serial monitor and I stop that to start up the PLX-DAQ when I get it connected it restarts the board ( or something ) the index that I stuck in and the millis that I'm showing reset back to 0.


Let say that I'm some uber project maker, how would you make it so that it's always ready to send and just waiting for someone to jack in.  Without resetting.  Say like a repair tech that wants to see what ever info the board maybe producing.


aarg

Let say that I'm some uber project maker, how would you make it so that it's always ready to send and just waiting for someone to jack in.  Without resetting.  Say like a repair tech that wants to see what ever info the board maybe producing.
Wait for a recognizable input before sending anything.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

aarg

#7
Jan 14, 2018, 12:04 am Last Edit: Jan 14, 2018, 12:18 am by aarg
... also
When I have the sketch running and it's sending to say the serial monitor and I stop that to start up the PLX-DAQ when I get it connected it restarts the board ( or something ) the index that I stuck in and the millis that I'm showing reset back to 0.
In the majority of cases, this indicates some kind of power supply or device load problem. Something gets turned on which causes the Arduino supply voltage to dip, which causes a hardware reset.
Edit - or a huge voltage spike. As caused by an inductive load with no flyback diode.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

iwrk4dedpres

Thanks for the info aarg.


Haven't played YET with the sending info to the arduino over serial yet .... That was coming soon to a sketch near me!..



sterretje

... also


When I have the sketch running and it's sending to say the serial monitor and I stop that to start up the PLX-DAQ when I get it connected it restarts the board ( or something ) the index that I stuck in and the millis that I'm showing reset back to 0.
An Uno resets when you open the serial port on the computer; this is normal behaviour. This is e.g. when you open a terminal program like Serial Monitor or Excel with PLX-DAQ (I assume that that is what you're talking about).

You can apply a hardware modification to the Uno or use e.g. a Arduino Leonardo or Arduino Micro (both based on the 32U4 microcontroller).
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.

Robin2

When you send data using Serial.print() or Serial.write() it gets sent whether or not there is anything listening. There is no need to stop sending data just because you have disconnected from your PC. The serial output buffer only blocks when you send data faster than the chosen baud rate can cope with.

Of course if you have an interactive Arduino program that relies on data received from the PC that is a completely different matter.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

wvmarle

3.  Is it possible to have more than one listener ( aka have the PLX DAQ    AND    Serial Montitor ) running at the same time?  ( realize this is a USB not Arduino issue.
Does that PLX DAQ thing connect to the USB? Or to the Serial connection of the Arduino?

Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

aarg

The serial output buffer only blocks when you send data faster than the chosen baud rate can cope with.
Hence my statement,
Quote
Stop sending reams of data
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Robin2

Hence my statement,
Quote
Stop sending reams of data
If the OP has no problem sending "reams of data" when the PC is listening then the same data can just as easily be sent when it is not listening.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

aarg

If the OP has no problem sending "reams of data" when the PC is listening then the same data can just as easily be sent when it is not listening.

...R
True. It will have the same problem. That is why I suggested looking at input to gain some control over what is sent. For example, diagnostic commands.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Go Up