My Arduino Uno will not work without the Serial Monitor opened. I have a PHP script to send data to the board. When I send the data, the TX and L LEDs light up, but the action is not executed. It is only executed when the Serial Monitor is opened. Can you please help me?

Code in Arduino:

int const RED = 2;

int status = 0, temp =0;

void setup() {
  pinMode(RED, OUTPUT);

void loop() {

  if(Serial.available() > 0) {
    temp = Serial.read();
    if(temp != -1)
      status = temp - '0';

    Serial.print("status: ");

    if(status == 1)
      digitalWrite(RED, HIGH);
      digitalWrite(RED, LOW);



PHP script:

<!DOCTYPE html>
        <form action="#" method="post">
            <input type="submit" name="alarme" value="ON">

        <form action="#" method="post">
            <input type="submit" name="alarme" value="OFF">


$port = fopen("/dev/ttyUSB0", "w");
fwrite($port, ($_POST['alarme'] == 'ON') ? 1 : 0);

My circuit is simple, it only consists of one LED and a 220 ohm resistor.

  • Hello and welcome to Arduino SE! I'm going to close this question because it lacks a clear example of the problem (code and any applicable circuit) that we need to help you fix your issue. Once you have a clear, minimal example of the problem's code and wiring, feel free to edit your question and it may be reopened. Thanks! – Anonymous Penguin Jul 18 '17 at 4:25
  • @AnonymousPenguin I added details – Leonardo Vilarinho Jul 18 '17 at 21:59
  • 2
    On many (most ?) systems, you can't open the port and immediately write to it, as that will result in a time consuming auto-reset. You need to hold the port open and configured in general, and write when you need something. – Chris Stratton Jul 19 '17 at 0:50
  • I fixed, see my answer – Leonardo Vilarinho Jul 19 '17 at 21:35

The problem was the auto-reset of the Arduino, I disabled it.

To disable, I connected a 10uf capacitor on the GND and RES. As in the image below:

enter image description here

  • Interesting! I have a few sketches I remember have failed until I open the Serial Monitor. I had a heck of a time with one writing between a rpi and a bluno nano, so Ill go check that out later. But more recently, I have a sketch that writes data from the bluno nano to an iOS app and sometimes Ill plug in the bluno nano to a usb battery and open up the iOS app BlunoTerminal and Ill get (null) (null) (null)...I plug the bluno nano into the laptop and check BlunoTerminal and still (null) (null) (null)...but I open up the Serial Monitor and voila, values start pouring in! – marciokoko Feb 6 '18 at 21:56
  • Signed in to thank you very much. After tons of frustration this made my day! Had the same problem as described, and diagnosing it was incredibly hard. – Valentin Radu Apr 12 '18 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.