Arduino Serial Communication with Web GUI Via PHP

This project is very inspiring! It is an Arduino project that has two LEDs on green and one red that are controlled via a local web server (AKA my Mac’s Apache Server). The web server is hosting a PHP script that has a user interface. When I click a link it sends a command to the Arduino board to turn on or off each LED. The Arduino board must be connected to the computer that has the web server on it for this to work. The PHP code is open source as well as the library/class that I have used. The class that I used was created for linux/windows but was changed to work with the Mac. This project does not need the network shield to work. This is just a simple project. You could expand on this to control moters, RGB LEDs, sound, and much more. I am using an Arduino Mega in this video. If you would like the source code, send me a message! You must subscribe to my channel in order to receive the source code. This helps me give support if needed as well as allows me to post bug fixes/updats ect. Please enjoy and as always, Rate, Comment, Subscribe! Thanks for watching!

Duration : 0:2:50


Related Reading:

Uncategorized

Be Sociable, Share!

Technorati Tags: arduino, control, free, gui, interface, LED, Mac, Mega, network, online, Open, php, project, real, serial, Server, source, User, web, World

25 thoughts on “Arduino Serial Communication with Web GUI Via PHP

  1. @bhyltng In this …
    @bhyltng In this case yes it does. Now if you were to hook up an ethernet shield it would not need to be directly connected to the computer. But that is a completely different project too.

  2. great. hi im new to …
    great. hi im new to this i have a question does the circuit needs to be connected to the computer?

  3. @Zenophilia – Hello …
    @Zenophilia – Hello. I have the source code posted in .zip files on my blog site. Visit:
    missionduke(DOT)com/arduino-projects/

  4. @Winsucker – Yeah I …
    @Winsucker – Yeah I found that adding the +4v on the reset pin helps a lot with it trying to reset.

  5. Please can you send …
    Please can you send me the source code for the project. Thank you. I will be using a Linux box (running Ubuntu Karmic Koala) with a built in serial port and Apache web server… I hope that this hardware/OS functions with you software!

  6. Please can you send …
    Please can you send me the source code for the project. Thank you. I will be using a Linux box (running Ubuntu Karmic Koala) with a built in serial port and Apache web server… I hope that this hardware/OS functions with you software!

  7. @Winsucker i have …
    @Winsucker i have found a “fix”:
    replace:
    if (incomingByte == ‘1’) {
    in Arduino with
    if (incomingByte == ‘f’) {

    and in php:
    $serial->sendMessage(“1/r”);
    with
    $serial->sendMessage(“f”);
    (also delete /r from other ones)

    for “green” LED i have use “9” for ON state and “e” for “OFF” state.
    that should work with +5V on RESET pin.

  8. Hi!

    First-thanks …
    Hi!

    First-thanks for the code!
    For everyone that have “strange” url when they click on command, or < in the links-you need to enable “short open tag” in php.ini or replace short php tags in the code.
    For me-code is working perfect by Serial Monitor, but it has problems with WEB GUI. (13pin LED is blinking on every command).
    After adding 5V fix, LED just turn on and stay on, on every GUI command. Any ideas?

    Tnx again for sharing.

  9. @djrock9000 I have …
    @djrock9000 I have a possible fix coming for your problem. Its a short video.

  10. @KINDanon I have a …
    @KINDanon I have a possible fix coming here in a few minutes. I have a short video on it.

  11. @djrock9000 Strange …
    @djrock9000 Strange… Sending commands through the Arduino terminal works perfectly. Sending the exact same commands through the PHP script doesn’t work. I checked with a serial sniffer. jbcse.com/screenshots/phpvsarduino.png

  12. @djrock9000 I first …
    @djrock9000 I first tried on PC and then Tried on on a friend’s Mac, but still no luck.

  13. @KINDanon Have you …
    @KINDanon Have you modified any of the PHP code other than the port settings in your PHP code? If not, and you have the correct port settings in the PHP code it should be working. I have noticed that I need to keep the Arduino’s serial monitor running in order for everything to continue to work. Are you on PC or Mac? Also, have you modified the Arduino Sketch? The PHP code works by sending a string of one character and a new line each time through the serial port. You can view by using terminal.

  14. @georgeflacker Are …
    @georgeflacker Are you using a Mac or PC with windows or linux/unix? Then I can help a little better. 🙂

  15. @georgeflacker …
    @georgeflacker Sorry I didn’t get back to you sooner. The COM port in the PHP script is the one I used in my setup and would only work in my situation. So in your case, to find which port your Arduino is on, open your Arduino coding software and in the menu Tools -> Serial Port there will be a list of ports copy exactly the name of the port you use and input it into the PHP code where it says

    /dev/tty.usbserial-A7006QCP

    You may have to try all of the items.

    Let me know if this works.

  16. The arduino alone …
    The arduino alone works with the sketch. However, I haven’t been successful at sending signal from the PHP page. I was wondering if you could help me to set up com ports (Mac or Windows) on the PHP script to make it work.

    Thanks in advance!

  17. @djrock9000 I just …
    @djrock9000 I just loaded the sketch to the arduino. It works like a champ.

    0 -> LED13 ON
    1 -> LED 13 OFF
    2 -> LED 12 ON
    3 -> LED 12 OFF

    I am running on windows. Looked at the PHP code and the COM port is setup for Mac. Any ideas?

  18. @djrock9000 Right. …
    @djrock9000 Right. Let me fire it up and see what happens. BTW I’m running XAMPP on Windows XP

  19. @georgeflacker – …
    @georgeflacker – Are you using OSX, Linux, or Windows? Try connecting the Arduino and opening the Arduino coding software with the project loaded and using the “Serial Monitor” send the commands manually to the Arduino that way and let me know if they make it to the Arduino.

  20. How yo doing man. I …
    How yo doing man. I set up XAMPP localhost on my computer to give this a try. However when I click on GREEN LED ON or any other link I get this as a response.

    Is there something I am missing in the XAMPP settings?:

    Access forbidden!

    You don’t have permission to access the requested object. It is either read-protected or not readable by the server.

    If you think this is a server error, please contact the webmaster.
    Error 403
    127.0.0.1

  21. Are you using a USB …
    Are you using a USB to Serial device or anything similar. Are you using a Mac or PC. The code should work with both. I have not tried the code on a PC though. Just on a Mac.

Leave a Reply