Show Posts
Pages: [1]
1  Topics / Home Automation and Networked Objects / Re: How to control LED using Arduino as a webclient? on: January 10, 2013, 05:07:50 pm
YESSSSSS !!  smiley-draw

llukkari  You're the man!!

Thank you everybody for all your help. practice a little more.

P.S.: draythomp  thanks also for your suggestions.   smiley
2  Topics / Home Automation and Networked Objects / Re: How to control LED using Arduino as a webclient? on: January 10, 2013, 11:10:47 am
 smiley-red Sorry for the late response. smiley-red

Illukkari from your posts and comments, you're right on the point of where I would like to get at.  Thank you very much for the code.  I will try the code and come back with some comments.

Jantje that's another neat approach I've read about.  However, my idea is to automate my house as much as possible, so it won't be so easy to make the serial connection.

draythomp My idea is that the server and client(s) con communicate with each other, being the internet server the one who controls the arduino wifi clients.  As Illukkari mentioned the best approach is using websockets.  From what I've read polling causes an increase of the use of bandwidth which could affect other users, and it's not in real time so, it is still an option but not the best.  As for hijacking the thread, don't worry, it is a constructive discussion, from were we all learn.  I am new to Arduino and HTML programming so it has been very interesting for me.

Cheers!  smiley-lol
3  Topics / Home Automation and Networked Objects / Re: How to control LED using Arduino as a webclient? on: January 07, 2013, 12:01:00 pm
Thanks again for your response zoomkat. I guess I'll have to investigate a little more, I thought that's how it worked.

draythomp, the functionality I'm looking for is exactly the same, but the approach is different, as I don't want the Arduino to act as a webserver, only as a client and depending on what the webserver sends it respond accordingly.

billroy, that's how I thought it could work (using the traditional approach you mention).  I want the Wi-fi Shield to be an HTTP client who just listens until a there's a POST update from the webserver when somebody clicks on the button that's on the webpage, and of course the Arduino turns on or off a LED and POST a message back to the webserver server letting it know it turned on or off the LED.  The issues you mention regarding IP addressing and firewall I already had encountered them, and had done some IP Forwarding, but my ISP has the ports blocked, I tried using a DNS service but had the same results.  That's why I am dealing with a free web hosting service and taking the approach that the wifi shield only acts an HTTP client and not a webserver.  I had already made a program to do what I want in my LAN and it worked fine, but I want this to be part of the WAN, so I can access it on the road and know the status of the LEDs and later on from analog sensors  smiley-lol.  I'll dig some info on the "telnet" stuff.

Kong, I am looking at the link right now, it looks very interesting, but it uses the Arduino as a webserver.

Thanks everybody for all your feedback and suggestions.  It seems that I am not really seeing the big picture  smiley-red or am confused about some stuff and I am just complicating my life.

Again, all suggestions/comments are more than welcome .   smiley-wink
4  Topics / Home Automation and Networked Objects / Re: How to control LED using Arduino as a webclient? on: January 06, 2013, 02:10:53 pm
Thanks a lot for your reply zoomkat. I tried your code and it worked by receiving the HTTP header information, but I still don't understand how to interact with the variable in the webserver, and that is where my real problem is. smiley-sad
So, the idea is that the wifi Shield connects to the webserver(which it does), and just waits until someone presses the button on the website which is hosted in the webserver.  At that moment, the value of the variable changes.  Since the wifi shield is permanently connected and waiting for incoming data, it receives the variable name and a value for that variable.  According to this, the Arduino turns on or off a LED, and replies back to the webserver information, so that in case somebody else goes to the website knows the status of the LED.
Therefore, I think my rpoblem is I don't know how to write the commands for this to work out.  I have used the GET and POST commands trying to access the variable created in the PHP segmente that takes cares of, but I get nothing, and the same goes on how to send information to the webserver in order to change the value of the variable.
Again, any help will be greatly appreciated!  smiley
5  Topics / Home Automation and Networked Objects / How to control LED using Arduino as a webclient? [solved] on: January 05, 2013, 03:31:00 pm
Hello,  I have been trying for more than a week now, to figure out how to send and get data as secure as possible to a remote server using a WiFi Shield.
I am able to connect to the server and receive the HTTP response, but so far I have not been able to read a variable from a webserver and change the HTML page with information from the Arduino to reflect any changes (LED On/Off).  I have seen many examples here on the forum and on the web, but all of the ones I have seen use the Arduino as a webserver, in my case is just a web client.  I am attaching the web page code and the arduino code (obviating everything before the connection to the server, since this works fine).
I have been looking at HTML coding and PHP but cannot figure out how to use it with Arduino, besides having a thick skull smiley, so any help will be greatly appreciated.  

BTW: The idea is to use HTML and PHP, without javascript, etc.  So it is more secure and the website can be accessed by the simplest of smartphones.

$counter = isset($_POST['counter']) ? $_POST['counter'] : 0;
   if($_POST['submit'] == true) {
         switch ($counter) {
               case 0:
               case 1:
               $counter=0; }

<!DOCTYPE html>
<title>Light On/Off Switch</title>
<H1>Light Switch Example</H1>
<form name="LED" method="POST" action="#">
<input type="hidden" name="counter" value="<?php print $counter; ?>" />
<input type="submit" name="submit" style="height: 100px; width: 100px" value="LED Switch">
<br />
<?php echo "Counter: " . $counter; ?>

-------------------------------------- END OF WEBSITE CODE  -----------------------------------------------------

boolean currentLineIsBlank = true;
boolean DoPage=true; //

    while (client.connected())  {
        if (client.available()) {
            char c =;

  client.println("<?php echo $_GET['counter']; ?>");
  Serial.println("The value for counter is: ");

  // if the server's disconnected, stop the client:
             if (!client.connected()) {
                  Serial.println("disconnecting from server.");

    // do nothing forevermore:

---------------------------------------------   END OF ARDUINO CODE ---------------------------------------------
Pages: [1]