Electronic – Arduino: Only reads serial input when Serial Monitor is open. Fails when it’s closed

arduinoserialtroubleshooting

I feel like maybe I'm having a brainfart, but I've been searching around a lot.

Setup:

  • I have a Python script using pySerial that connects to the device and writes a line to the serial port @ 4800.
  • I tried using "while (Serial.available())" both in serialEvent and directly in the loop.

What should happen:

  • When the devices receives any kind of serial input, an LED should light up.

Problem:

  • When I have the Serial Monitor open, everything works as expected. The LED lights up and I see the content printed out.
  • When I have the Serial Monitor CLOSED, nothing works. The LED doesn't light up.

Something I recently noticed: When Serial Monitor is open, I get 1 TX blink followed by 1 RX (yellow) blink. But when it's closed, I get 1 TX blink followed by 2 PIN 13 (blue) blinks. Supposedly the PIN 13 blinks mean something about troubleshooting, but I don't know where to look.

The event that happens has been simplified to a very basic LED light which works in every other instance (button press, serial monitor open while receiving data from python, or just sitting in the loop).

So my questions:

  • Why doesn't the device receive the serial writing when the Serial Monitor is closed?
  • What are the differences in these RX, TX, PIN13 blinks telling me?
  • How do I troubleshoot that?

Best Answer

Answer:

This was a big rookie mistake on my part.

When I established the connection with Python, it rebooted the device. So it never received the data I sent. The Serial Monitor apparently opens the device so the immediately serial write from Python worked correctly; which was throwing me off the trail.

I had to connect, wait for word from my device, then start writing. Rookie, rookie, rookie.