Go Down

Topic: problem with arduini and php (Read 2686 times) previous topic - next topic


hi! im new!

so i need help... i use the php_serial.class.php for read and write in the serial port and comunication with arduini....

but my script don't read from arduinoo why????

this is my script php  


/* Simple serial relay script for turning my sprinkler system on and off from the web!

Utilizes the PHP Serial class by Rémy Sanchez <thenux@gmail.com> (Thanks you rule!!)
to communicate with the QK108/CK1610 serial relay board!


//check the GET action var to see if an action is to be performed
//Action required

//Load the serial port class

//Initialize the class
$serial = new phpSerial();

//Specify the serial port to use... in this case COM1

//Set the serial port parameters. The documentation says 9600 8-N-1, so
$serial->confBaudRate(9600); //Baud rate: 9600
$serial->confParity("none");  //Parity (this is the "N" in "8-N-1")
$serial->confCharacterLength(8); //Character length (this is the "8" in "8-N-1")
$serial->confStopBits(1);  //Stop bits (this is the "1" in "8-N-1")
$serial->confFlowControl("none"); //Device does not support flow control of any kind, so set it to none.

//Now we "open" the serial port so we can write to it

//Issue the appropriate command according to the serial relay board documentation

//to turn relay number 1 on, we issue the command 
// Or to read from
$read $serial->readPort();



//We're done, so close the serial port again


but $read = $serial->readPort(); don't print nothing...

this is the arduino code

void loop() {
if (Serial.available() > 0) {
      // read the incoming byte:
      incomingByte = Serial.read();

      // say what you got:



Code: [Select]
COM3 - that's a Windows thing.

Code: [Select]
$read = $serial->readPort();
The PHP serial class has some known limitations on Windows. One of them is that readPort doesn't work. Upgrade to Linux or use a different language.
The art of getting good answers lies in asking good questions.


yes i use win and now tell me this:

Warning: You must close your device before to set an other one in C:\Programmi\EasyPHP-\www\serial port\Support Files\php_serial.class.php on line 146


you can't use the same com port for more than one activity..

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131