Serial communications

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

  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?

Post your code, use the code tag button </> and paste the code in the box.

So it looks like this

You can use this:
availableforwrite
but it will usually make for a complicated implementation

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

#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!

… 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.

iwrk4dedpres: 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.

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.

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.

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!..

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.

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).

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

iwrk4dedpres: 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?

Robin2: The serial output buffer only blocks when you send data faster than the chosen baud rate can cope with.

Hence my statement,

Stop sending reams of data

aarg: Hence my statement,

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

Robin2: 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.

wvmarle: Does that PLX DAQ thing connect to the USB? Or to the Serial connection of the Arduino?

It just connects to a com port ( you specify which ). You have to format the data sent by the UNO with a keyword like "DATA" so that excel knows it's a data line of pertinent information.

I had just found the module that he's using like 2 weeks ago and was beginning to mess with it to see it's capabilities. It's pretty cool place to start until I figure out how to either connect via WiFi ( have to small boards for it ) or store it on a memory card ( don't have this yet ) then use the WiFi to read the file.

But this is a pretty nifty program. It does, however, have a tendency to crash if you start / stop / debug the code alot. So save often.

Ok guys. Please remember I'm literally on like day 5 of doing something. So I'm just doing to see what I can learn. Haven't done serial communication before so ... exploring.

Don't necessarily want to send Reams of data ....

I truly appreciate all the input here.

.... Also WHEN will I be able to read one thread .... reply ..... read another thread and reply ... w/o getting this 5 min wait thing. It is annoying.

iwrk4dedpres: It just connects to a com port ( you specify which ).

That doesn't explain anything.

You mean it connects over USB to a computer, which then sees it as a COM port, or what? After all computers nowadays don't have an RS232 connection (which is where the COM ports originally connected to), and that in turn is not TTL so still can't be read by an Arduino without extra hardware.

This is not getting us anywhere.

Datasheet & other technical info needed. Without that, forget it.

iwrk4dedpres: Ok guys. Please remember I'm literally on like day 5 of doing some.... Also WHEN will I be able to read one thread .... reply ..... read another thread and reply ... w/o getting this 5 min wait thing. It is annoying.

After your 99th post.

@iwrk4dedpres, just don't use serial monitor when using the uno code that sends data to plx-daq. As I explained earlier, opening the serial port will reset the Uno; this will also happen when you close the serial monitor and ooen it again.

You need to make 100 posts to get rid of the 5 minute delay between posts; this is an anti-spam measure, annoying but I learned to live with it.