Go Down

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

izzusan

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  

<?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
	
require(
"php_serial.class.php");
	

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

	
//Specify the serial port to use... in this case COM1
	
$serial->deviceSet("COM3");
	

	
//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
	
$serial->deviceOpen();

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

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

	

	

	
//We're done, so close the serial port again
	
$serial->deviceClose();


?>



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:
      Serial.write("ricevuto");
   }

  delay(1000);
}

PaulS

Code: [Select]
$serial->deviceSet("COM3");
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.

izzusan

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-5.3.3.1\www\serial port\Support Files\php_serial.class.php on line 146

GFirefox

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!

Arduino
via Egeo 16
Torino, 10131
Italy