I have a problem. I try to open a channel to arduino and PHP talk, the PHP would send a command and the Arduino should answer that. It works, but only if I execute some steps before:

  1. sudo chmod 777 /dev/ttyACM0
  2. sudo arduino
  3. Open the serial monitor in arduino IDE
  4. Close the serial monitor
  5. Now everything is ok, they can talk

The first step is ok, I really need to do this, the 2-4 seems irrelevant, but the communication do not start without it. I put one LCD in arduino to print what he receive, when I send "HEYARD" with PHP to him, the RX led blinks and the TX led also, but nothing is printed on LCD. If I do the 2-4 steps, when PHP send "HEYARD", LCD show HEYARD and arduino answer with "HEYPHP"

Anyone could help? There is some way to open it via Terminal, or, at least, open the Serial Monitor from arduino and close to see if this start

  • 1
    Does the PHP code set the correct baud-rate, parity etc.?
    – Gerben
    Jan 21, 2016 at 10:10
  • Yes, everything seems ok, the baud-rate is right, parity is "none", they can talk normally, but only if I open the serial monitor before. I tried open the screen in terminal, but also do not worked, need to be the serial monitor. Thank you
    – Jomarumu
    Jan 21, 2016 at 13:19
  • Try a proper terminal emulator like Minicom.
    – Majenko
    Jan 21, 2016 at 13:29
  • It could be that Arduino is setting the correct settings for /dev/ttyACM0, so others after it won't have to but should. Could you post the PHP code and screen command?
    – Gerben
    Jan 21, 2016 at 16:01
  • I tried use the minicom, until now, I could not read anything, but I will try make it start the port.
    – Jomarumu
    Jan 21, 2016 at 16:52

2 Answers 2


Here the setup block:

    $serial = new phpSerial();
    $conect = mysql_connect("localhost", "root", "") or print (mysql_error()); 
    mysql_select_db("ANM", $conect) or print(mysql_error()); 

And here the connection block:

    exec("echo 'HEYARD' > /dev/ttyACM0");
    $read = $serial->readPort();

stty -F /dev/ttyACM0 ignpar stty -F /dev/ttyUSB0 ignpar

IGNPAR Ignore framing errors and parity errors.

That is what you need to fix minor framing issues.

Screen switches this by default; but NONE of the serial drivers do. Especially when connecting PIs or BBB to Arduinos

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.