PHP: read / write to / from Arduino - Genaral Steps - please free complete it


good afternoon, purpose of understand , use php arduino.
so, following steps know necessary work php , arduino, please free complete missed in order have 1 topic necessary work it. have seen several topic on forum  and think have 1 resume that.

software needed:(of course depend os using)

- windows xp --> apache server correctly installed , configured
- ubuntu --> lamp correctly installed , configured
- mac --> mamp --> correctly install configured

- php_serial.class.php


well can proceed php code send data arduino:

code: [select]
<html>
<body>
<h1>works php</h1>
<p>first page in php</p>



<?php
require("php_serial.class.php"); 

$serial = new phpserial();
$serial->deviceset("/dev/ttyacm0");
$serial->confbaudrate(9600);
$serial->deviceopen();
$serial->sendmessage("c");
       
$serial->deviceclose();

?>


<p>sent data arduino should see blik led on arduino </p>

</body>
</html>


well can proceed receive data arduino should use simple instruction

code: [select]

$read = $serial->readport();





so now, reading several post on forum it's clear arduino when open communication php reset , need time realign php code.

if not understand bad have ways proceed:

   a) put sleep() function inside php code after port opening

   b) remove auto-reset arduino following guide : http://arduino.cc/playground/main/disablingautoresetonserialconnection

what tried option a) without success, im not able answer arduino variable read void. i've used code:



code: [select]
int incomingbyte = 0;   // incoming serial data

void setup() {
       serial.begin(9600);     // opens serial port, sets data rate 9600 bps
pinmode(13,output);     // used see if arduino received data php
}

void loop() {

       // send data when receive data:
       if (serial.available() > 0) {
               // read incoming byte:
               incomingbyte = serial.read();
               // got:
               serial.print("i received: ");
               serial.println(incomingbyte, dec);
serial.write("test");   // write on serial "test"
       }
}



please there can add working php , arduino skecth working read data arduino ?

i think basilar thing necessary managed php , arduino,

thanks collaboration,

gnusso







wow that's interesting...i didn't know use serial ports directly php. guess can made can have real web server @ home instead of ethernet shield can handle 4 tcp connections @ once.


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > PHP: read / write to / from Arduino - Genaral Steps - please free complete it


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial