I am trying to get an arduino uno to work with PHP through the serial port using the USB cable of Arduino.
I have used the codes that are available in internet that allow you to make this communication between PHP and Arduino without having to install any additional software, library or whatever.
Well, I don't understand this witchery very well, but it looks like the matter is that the first file doesn't do it's job well.
To make it to work I had to start the port COM1 from the Arduino's IDE. And looks like not all ports work, I didn't try it but I found somewhere that just port COM1 to COM4 can be used.
So if you have to change the number of the port because you got something like port COM6 you may change it to COM1 or COM2, COM3, COM4 with the "device manager".
there has to be any other better way using just PHP and Windows for sure.
if you know it please let me know if you got the same problem I may try to help you as soon as I can.
Well i think i've seen this done before by someone using IOT core arduino c++in visual studio IDE... this code was communicating to a IP based device... i'm not extreemly familiar w/ network IP hardware systems communicating to interfaces but i'm sure this was communicating directly to a dynamic remote server for two way communication which had the .exe... i think i have the link w/ the IOT core just keep in mind windows group policy local/remote or user hosts restricts this type of behavior... so this is strictly for appliances running on a server somewhere w/ full administrative access....
I'm not clear what it is you are even trying to do, to be honest.
Are you trying to READ FROM Arduino serial data using PHP? or SEND serial data TO an Arduino using PHP?
From what I recall (and where I left off at).. that you can NOT use PHP to read from an Arduio on Windows.. (Linux/Mac do not have this issue)..
sending data TO an Arudino using PHP is possible though...
Also.. you can loading a completely new php file.. you want to do some COM port stuff.. but you never initiate the connection... file 1 does nothing by itself..
Hello, I have the same problem, I try send commands (Serial port) to arduino using PHP, but first I need open the SerialMonitor of IDE Arduino. what the solution for this?
If you using PHP, on a Windows platform.. you will only be able to WRITE to the serial port natively.
If you want to READ... you will need to use another OS... or use some sort of man-in-the-middle PROXY
$port = fopen("COM6", "w+");
if ($_POST['estado']=="Amarelo")
{
echo "Ligou o Amarelo";
fwrite($port, "a");
}
this work in my windows, but just when open and close the SerialMonitor, I think when execute the serialmonitor, it's execute a process that permite the arduino receive commands in the serial port.
I solved my problem, I needed execute this command in the prompt command: "mode COM6: baud=9600 parity=N data 8 dtr=on xon=off odsr=off octs=off rts=on idsr=off".
Hi guys, I am sorry for my late reincorporation to this world, it's been a crazy working life!!!
Thank you all for your answers and efforts to try to solve the issue.
The goal was to send Arduino the values of the form. Thus, Arduino may process internaly the order the computer has sent via PHP.
The problem was that the port comX couldn't be set up.
It seems to be that the PHP code doesn't work propperly, although it is written everywhere that it works like that. And the solution was to set up the port comunnication manually, via cmd.exe as well as via Arduino IDE.
@xl97: thank you for your contribution. I have seen a little difference in your code respect to mine. I will try to do it like you have done it, to see if it works for me too.
@lewis-H: thank you for your contribution, I have tried to install Linux on all my computers and it seems to be that none of them support any version of LINUX ¿?¿?¿?¿? the version that doesn't flicker shows the screen up side down if it shows it. = D so the attempt is to solve this issue without buying a new computer that supports Linux.