Pages: [1]   Go Down
Author Topic: php arduino please help  (Read 2696 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i may sound a little dumb but please answer ...

1. I learnt about php serial and found that it could be used to communicate with arduino via serial port but i can't seem to figure out whether it is rs232 or usb port ... (please clarify )

2. i downloaded these  two php files from phpserial class website

php_serial.class.php and example.php

my question is are they standalone like just modifying example.php with the function we would need it to perform would allow communication to arduino?  

please reply..

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html

a little info i downloaded the above two files ( prev post ) from here..

please help guys
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46128
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I learnt about php serial and found that it could be used to communicate with arduino via serial port but i can't seem to figure out whether it is rs232 or usb port
The php serial class communicates with the serial port. Whether that serial port is a real RS232 serial port or a serial-to-USB conversion, only you can answer, as you are the one with the hardware.

Quote
my question is are they standalone
The example.php file uses stuff from the php_serial.class.php file.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks a lot for the reply i understood the example.php and php_serialclass.php from your explanation but one thing still is not clear...

let me put it this way to communicate with arduino using the serial class need i have to buy a rs232 converter to connect arduino to rs232 serial port in my computer or is the usb interface enough...


one more too
 i found this link in google code where a guy has written code for read function in php serial class does this work?

the link is : http://code.google.com/p/php-serial/issues/detail?id=1#c0

thank you
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46128
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How are you connecting your Arduino to the PC? Are you using a USB cable? If so, you can send serial data to the Arduino using the same cable (just like avrdude does).

Quote
does this work?
Ready? Set? Jump!

There's no better way to know than by trying.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thank you ! but i am collecting this information for my final year project so that i could go ahead and purchase stuff only after confirming that those works...

anyway  thank you..
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46128
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PHP was originally developed on linux, and ported to windows. There are some features that work better on linux than on windows. Hardware access, like access to the serial port, is one of them.

You would be much better off, in my opinion, using a program language on the PC that works well with the operating system on the PC.

Now, I'm a big fan of PHP, and regularly use it. Just not for talking to my Arduino. For that, I use C#, because it is very simple to read from and write to the serial port, talk to databases, draw pretty pictures, etc. all in one language.

Don't let PHP's ability, or lack thereof, to communicate bi-directionally with the serial port, on your operating system, without any experience on your part, influence your project.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

k, i understood one thing ... from your reply

my idea was to implement a rfid +arduino + webpage ( using php ) to implement a targeted advertisement....

but now i am clear that web page need not necessarily be written in php but i could use flash which which too could be interfaced with arduino easily... thank you

going with flash for website design...
Logged

'round the world...
Online Online
Faraday Member
**
Karma: 41
Posts: 3112
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
going with flash for website design...

It's not gonna run on an iPad. smiley-sad LOL
Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

k i found one thing for sure php serial class is NOT BI DIRECTIONAL for windows............................ ( for until now atleast)

you can send data to arduino with EASE

but the reverse is not possible ( again until now)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Cinnamon.
I had the same problem but after 4 days of trouble i find the solution.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1294421939
i translate with my bad English.

I'll try the same php class but it's not useful form me and an allert tellt that is unbidirectional.
I find the solution for me.
I use webserver with php on win pc and i use Serproxy for connect with com port.
And i write a script that send signal to COM. This method it's bidirectional.
Here the method to put signals with fopen using fsockopen.
Before start php script you must start serproxy.

I use this serproxy for connect to my serial http://code.google.com/p/as3glue/ (this project is useful for connecting Flash)
This is the PHP code:

Code:
<?php

function invia_seriale($messaggio)&#123;
$serproxy=true;
if (
$serproxy)
&
#123;
 
$fp fsockopen ("localhost"5331$errno$errstr30);
 if (!
$fp)
      &
#123;
            
echo "$errstr ($errno)";
      &
#125;
 
else
      &
#123;
            
$string $messaggio;
            echo 
$string;
            
fputs ($fp$string );
            
fclose ($fp);
      &
#125;

&#125;
&#125;

//catch the variable by lik get example xxx.php?stato=value

$stato=$_GET["stato"];

//execute function
invia_seriale ($stato);

?>


And this is arduino code:

Code:
int in = 0;
int ledPin = 13;
int st=LOW;
int sensorPin=A0;
int sensorValue=0;

void setup() {
Serial.begin(9600);      // opens serial port, sets data rate to 9600 bps
pinMode(ledPin,OUTPUT);
}

void loop() {
  delay(100);
 sensorValue = analogRead(sensorPin);
 Serial.println(sensorValue, DEC);
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
in = Serial.read();
if(in==49){
st=LOW;
}
if(in==50){
st=HIGH;
}

// say what you got:
//      Serial.print("I received: ");
//      Serial.println(incomingByte, DEC);
}
digitalWrite(ledPin,st);
}

For GUI i use this ajax script very beautiful.
http://papermashup.com/jquery-iphone-style-ajax-switch/ and change page on.html and off.html with myPhpToCom.php?stato="Value".

Now i'm searching method to read all string that Arduino put on serial because for example when i read analog in trigger 10K i read sometimes all value and sometimes value is truncate, i'm programming a function that take the serial value that pass on COM.

I think that use php to control Arduino can be intresting because u can use all web service and app that can be interfacing with php (Twitter, Google Calendar, reading and send email ecc..), and it can be possible use mysql db.

I hope thi is useful.
Good Work
 8-) 8-) 8-)
Logged

Pages: [1]   Go Up
Jump to: