Pages: [1]   Go Down
Author Topic: problem with arduini and php  (Read 2033 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
$serial->deviceSet("COM3");
COM3 - that's a Windows thing.

Code:
$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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: