COM data only visible in Arduino IDE Serial Monitor

Hello,

I have a problem when using other terminals/programs than the built-in Serial Monitor of the Arduino IDE.
My program is the following:

void setup() {
  Serial.begin(9600);
  sensors.begin();
  sensors.getAddress(sensorAddress, 1);
  sensors.setResolution(sensorAddress, TEMPERATURE_PRECISION);
}

void loop() {
  sensors.requestTemperatures();
  Serial.println(sensors.getTempC(sensorAddress));  
  delay(500);
}

It does what it should, but only when using the Serial Monitor.
I've used hterm, another COM sniffer and my own C# program to try to get the values but didn't succeed. Settings were correct.

Using Windows 10, latest updates.

Any opinions? Driver settings?

Best,
Tobias

If it works with the Serial Monitor then you must have incorrect settings in the other programs.

You need to select the correct COM port and the serial settings should be 8 bits, no parity and 1 stop bit (8N1). And, of course the correct baud rate.

If you need more help please post your complete Arduino program.

...R

Hi Tobias,

To be honest if you can see the data in the serial monitor then any terminal program should do exactly the same as long as you are opening the same port.

Make sure you close the serial monitor.!!

It maybe one of the control lines holding the device in reset or slipping it into program mode.
I forget if it was DTR or RTS.

Just make sure the port is opening, and that you are not sending char(0) too much.
Does the device respond to outgoing serial commands even if you can't see any incoming data.
You can also just short RX and TX on the board to see if a simple loopback test works.

Robin2:
If it works with the Serial Monitor then you must have incorrect settings in the other programs.

You need to select the correct COM port and the serial settings should be 8 bits, no parity and 1 stop bit (8N1). And, of course the correct baud rate.

If you need more help please post your complete Arduino program.

...R

If I hadn't double, triple, quadruple checked all you just said, I wouldn't be posting.
As I said, I suppose the program works correctly, as I get results in the IDE, so posting "all of it" wouldn't make any difference. But it is in attachment.

Hiddenvision:
Hi Tobias,

To be honest if you can see the data in the serial monitor then any terminal program should do exactly the same as long as you are opening the same port.

Make sure you close the serial monitor.!!

It maybe one of the control lines holding the device in reset or slipping it into program mode.
I forget if it was DTR or RTS.

Just make sure the port is opening, and that you are not sending char(0) too much.
Does the device respond to outgoing serial commands even if you can't see any incoming data.
You can also just short RX and TX on the board to see if a simple loopback test works.

I know, that's exactly why I'm asking. It is a really odd and weird behaviour.

Is the code of the Serial Monitor open source, so I can reverse engineer this?

arduino.ino (978 Bytes)

tscheipel:
Is the code of the Serial Monitor open source, so I can reverse engineer this?

It is. But it would be a complete waste of your time studying it.

There is nothing in your program that would prevent it working with any other Terminal program.

I don't have your sensors. You might like to try this simple program which works with minicom on my Linux PC.

void setup() {
  // put your setup code here, to run once:

  // Serial port
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:

  Serial.println("Hello World");

  delay(1000);
}

I can only conclude that there is something wrong with your Terminal settings. Or maybe you don't have some Operating System permission?

...R

Ya, no. But thanks for your effort. Also works when mapping the device in a VirtualBox and using Linux.
Seems to be a Windows issue, but no idea what it is. I'll keep you updated, if I find something.

tscheipel:
Seems to be a Windows issue, but no idea what it is.

Just switch permanently to Linux :slight_smile:

...R

Robin2:
Just switch permanently to Linux :slight_smile:

...R

Would like to, not possible due to policies :wink:

You didn't show the C# code you tried but here is one of the options I would use as an interface, it's simply a form that contains a rich text box control and the baud and com should be configured to match your arduino.

using System;
using System.Windows.Forms;
using System.IO.Ports;

namespace ArduinoMonitor
{
    public partial class Form1 : Form
    {
        SerialPort myport = new SerialPort();
        public delegate void StringDelegate(string sData);
        

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            myport.PortName = "COM7";
            myport.BaudRate = 9600;
            myport.NewLine = "\r\n";
            myport.DtrEnable = true;
            myport.Open();
            myport.ReadExisting();
            myport.DataReceived += new SerialDataReceivedEventHandler(myport_DataReceived);
           
        }


        private void myport_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)

        {

            myport.ReadTimeout = 50;

            try
            {
                string str = myport.ReadLine();
                this.BeginInvoke((new StringDelegate(StringDebug)), str);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

            private void StringDebug(string sData)
            {
                richTextBox1.AppendText(sData + "\n");
            }

    }
}

sumguy:
You didn't show the C# code you tried but here is one of the options I would use as an interface, it's simply a form that contains a rich text box control and the baud and com should be configured to match your arduino.

using System;

using System.Windows.Forms;
using System.IO.Ports;

namespace ArduinoMonitor
{
    public partial class Form1 : Form
    {
        SerialPort myport = new SerialPort();
        public delegate void StringDelegate(string sData);

public Form1()
        {
            InitializeComponent();
        }

private void Form1_Load(object sender, EventArgs e)
        {
            myport.PortName = "COM7";
            myport.BaudRate = 9600;
            myport.NewLine = "\r\n";
            myport.DtrEnable = true;
            myport.Open();
            myport.ReadExisting();
            myport.DataReceived += new SerialDataReceivedEventHandler(myport_DataReceived);
         
        }

private void myport_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)

{

myport.ReadTimeout = 50;

try
            {
                string str = myport.ReadLine();
                this.BeginInvoke((new StringDelegate(StringDebug)), str);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

}

private void StringDebug(string sData)
            {
                richTextBox1.AppendText(sData + "\n");
            }

}
}

That was the lead. It is simply the DTR you need to enable.
Thanks everyone.

tscheipel:
That was the lead. It is simply the DTR you need to enable.

That was in Reply #2

...R

I thought usb cables had only 2x data and 2x power wires. Where does dtr fit into the scheme of things?

meltDown:
I thought usb cables had only 2x data and 2x power wires. Where does dtr fit into the scheme of things?

It's done in software behind the scenes.

...R

The extra DTR and RTS signals are generated on the USB ic on the external board.
Arduinos and others use those pins to either reset or reset into flash mode.

Some USB devices do not offer the pins to external headers so don't be angry if your USB convertor does not have them. The Chip will.!!
Some being CP201x or CH340 IC's
There is a post in the Hacking section I think that shows how to mod one of the popular converters if desired.

Ah I saw the phrase "was the lead" and thought that was "lead" as in "cable" doh.

I thought it meant the lead as in cable was duff.

Thanks.

lead as in Pointer I think.

Hiddenvision:
lead as in Pointer I think.

Yes I twigged to that eventually, lead as in clue.

(But not *this kind of pointer....)