Show Posts
Pages: 1 2 [3] 4
31  Using Arduino / Programming Questions / Re: WebServer With LED Control / Buttons / Status Display / Auto Status Update etc on: February 23, 2012, 01:58:09 pm
Code:
long waitUntil=0;
boolean LED4state = true;



void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      digitalWrite(4, HIGH); // turns on an led every time a connection or command occurs
      if (client.available()) {
        char c = client.read();

The digital write acts like a system status LED - a connection, a refresh or a command and the led flashes for about a sec then goes off.

Code:
/stopping client
          client.stop();
          
          digitalWrite(4, LOW); // turn OFF "connected" LED
          
          //clearing string for next read
         readString="";



The  last digital write (LOW) shuts the led off

With the 2 digital writes i added it now causes a led to flash on for about a sec then off for each connection, a refresh or a command  -  like a connection / activity LED.

This is ok for a status led but if i used an LCD I would only see the Word "connection" displayed for a second-.

-----------------------------------------------
As this test is in preparation for a future LCD, I need the device (led, or LCD to stay on and only off when there is no connection and if not then stay on at least long enough  to see it displayed .

TCP:
I believe a connection is only valid for the amount of time it takes to execute the command, or when a refresh occurs.
 If this is true then the first code using just a digital write (HIGH) at the "while connect" makes sense as to why the led is on.

The next digital write ( LOW) at the client stop area of the code causes the led to go off because the client stop / all commands are done


I inserted   the code below just after the "while connected"  but gave me odd behavour.

I also tried inserting the code just after the client stop but this did not work.



Code:
  //digitalWrite(4, HIGH); // turn on "connected" LED
      // Each time through loop(), set Pin 4 to the same value as the state variable
  // digitalWrite(4, LED4state);
  // Nothing will change until millis() increments by 20000 - 20 seconds
   //if (millis() >= waitUntil) {
   //   LED4state = !(LED4state);        // Toggle the LED's state
    //  waitUntil = millis() + 20000;  // Make sure we wait for another 20000 milliseconds.


Where am I going wrong??


Joe
      
32  Using Arduino / Programming Questions / Re: WebServer With LED Control / Buttons / Status Display / Auto Status Update etc on: February 23, 2012, 11:16:45 am
jfhaugh,


Displaying the connection address is definitely  one to add on.
 
Goal:

1. To display  "CONNECTED" on line 1 of Serial lcd -  this should be  easy, currently have added a led to (test) turn on when this occurs - it works.  The Serial LCD display will be added as soon as it arrives.

2. To display "DIS-CONNECTED" on line 1 of Serial lcd  - when the connection drops - -- looking at the code now to see the best place to detect this and turn off test led
 
3. To display the Connection address (ip)  on line 2 - I am looking at some info that PaulS pointed me to ....




Thanks
Joe
33  Using Arduino / Programming Questions / Re: WebServer With LED Control / Buttons / Status Display / Auto Status Update etc on: February 23, 2012, 08:37:14 am
PaulS,

Thanks for the input.

I must have been sleeping, I know where to put (test if connected)  -- the "connected " was a typo -- oops....

It was the supposed to say "disconnected".. I was looking for the best spot to turn off a led and display "disconnected"


Joe
34  Using Arduino / Programming Questions / Re: WebServer With LED Control / Buttons / Status Display / Auto Status Update etc on: February 22, 2012, 05:21:52 pm
PaulS,

Thanks for the feedback.

I will start testing  each add-on in detail, as  soon as the lcd and pir arrive.

LCD is first on the list

Good point about Displaying - "disconnected"

I am looking at my code to determine exactly at what point in the code a connection can be determined.

Joe
35  Using Arduino / Programming Questions / WebServer With LED Control / Buttons / Status Display / Auto Status Update etc on: February 22, 2012, 02:32:27 pm
I spent the past month learning, trial and error and finally putting it all together.
I still know very little, but I know a lot more than when I started

I have posted  the full code for my  Webserver in the attachment -(It would not fit in the insert code - as it exceeds 9500 characters)


The Server runs with multiple connections - LAN or internet.

8 buttons for turning items on / off - I used colors, and sizing for examples

It Displays the status of each device / auto updates the status

Refreshes the sensor status every 35 secs.
The Sensor  displays if room is light or dark.
++++++++++++++++++++++++++++++++++++++++++++++++



Next on the list to add:


Display "connected" on LCD  when a user connects  - should be easy  - LCD is on order - 2 line serial ---- looking for coding ideas

Display the actual IP - ? hmm

PIR sensor -  should be easy

Very Simple password protection -? ?


I am also open to  coding  improvements to make it more efficient,  if any one is willing to help this project along


--------------------------------------------------------------------------------------------------
The hours of trying to code, trial and error and put it all together was a joint effort, I thank all those who helped!.

Special Thanks to zoomkat for some test code - It made me redo a large portion of my server but , it works much better now!!

Hopefully this will provide a starting point...for others to build from.

Joe smiley-grin

Enjoy
The retired hobbyist
36  Using Arduino / Programming Questions / Re: Webserver unresponsive when more than 1 tcp connection is made on: February 20, 2012, 01:37:22 pm
PaulS,

I removed:
// boolean current_line_is_blank = true; //new


//indexOf("L=")

if (c == '\n') { //if HTTP request has ended // i had this twice,





// HTML Code 

// if (c == '\n' && current_line_is_blank) {   // removed this
 
if (c == '\n') { //if HTTP request has ended - replaced with this

I added this:

client.println(F("<HTML>"));  //
client.print(F("<HEAD>"));  //


So far, I now can use multiple  simultaneous connections.
I am not saying code is still very good and needs more fine tuning, but it appears that this issue is under control...
Trying some more internet connections from different locations...

Joe
37  Using Arduino / Programming Questions / Re: Webserver unresponsive when more than 1 tcp connection is made on: February 19, 2012, 08:46:45 pm
zoomkat,

I compared your code and mine and noticed some differences in the html area and  in a few other areas.
I made several changes on my server.

Have been testing modified server  with 3 LAN connections on different computers turning items on/off  and
so far it has been working Perfectly!!

Next, will do the same from internet connections ---Looking good

If all goes well I will re post the complete working code for others to play with / learn etc.

ThankYou!

-----------------
Thanks again to all who responded to my requests.
Joe
38  Using Arduino / Programming Questions / Re: Webserver unresponsive when more than 1 tcp connection is made on: February 19, 2012, 03:42:01 pm
zoomkat,

Tried your test code, works perfect

loaded 4 browsers on  3 different computers at the same time for about 15 minutes - all web pages are refreshing, and data was changing

This would seem to  appear that my hardware and connectivity are fine but my  coding is at fault....   I was pretty sure that was the issue - but this  confirms it.

Now, what is the best approach to try to isolate my problems.

I posted most of my code but it was to long. So I attached the full code,  Hoping some would look and see what i am doing wrong.

Thanks for your input

Joe
39  Using Arduino / Programming Questions / Re: Webserver unresponsive when more than 1 tcp connection is made on: February 19, 2012, 02:11:01 pm
PaulS,

Quote
Quote
I can implement limited code and have been able to build a basic server  but unfortunately your explanation is not always perfect, so new people who are just learning do miss the simple things.
Adding an ethernet shield to an Arduino is not a beginner project. It really isn't even an intermediate project. I consider it an early advanced project.

I expect that by the time you get to the point where you have added an ethernet shield to the Arduino that you are quite adept at using Serial.print() for debugging, so that a mere suggestion to try printing the value returned by micros() is sufficient.

If that is not the case, then I don't think anything short of "Copy and paste this code" after "this code" will help you.

There are many things that have not been disclosed. How is the Arduino with ethernet shield connected to the network? Does it have a static IP address? Are the other devices on the LAN the ones that are connecting to it? Is there a router involved? Does the router configuration allow multiple connections. Are connections from outside the LAN possible?

Changing the code on the Arduino to deal with multiple connections should not be necessary. Having the Arduino forcibly close an existing connection when a new one occurs is not the solution.

Closing a connection after some period of inactivity might be needed, but how much time is reasonable? Until you can answer that, don't try to close a connection after a period of time.

----
I admit I am ambitious but it works, minus a few issues its almost done.

Serial print was not the issue, only the  micros() command, i had not seen it before and  was not clear on how to implement.  I even did a search and did not come across any examples
------------------------------------------------

The ethernet shield is stacked on the Arduino and is connected hardwired to a 1gig backbone to a router running Tomato firmware.... works exceptionally well.
The Arduino is set for a static ip, and gateway (which is the router ip).
It has been port forwarded and I have had people connect to it successfully from around the country.
I am also  able to connect on my local LAN with numerous computers.
The router also has a 1gig lan side  all switches are also cat6 1gig speed and all allow many many simultaneous connections with no problems.

I agree, forcing timed a termination - seems drastic but it would ensure if a normal disconnect did not occur then after  say 5 minutes and auto disconnect would occur - almost like a tcp connect  watchdog


RECAP:
When Arduino is connected by a 1 client web browser - it works perfect, fast from internal Lan and just as fast from someone on the internet.
Now, when someone else connects (2nd connection) at the same time from Lan or internet --- after operating a few butttons to turn on / off  - one or both of the tcp connections will eventually timeout.
If i terminate one connection, it may comeback but in most cases, i must terminate both browsers.   Of course if someone outside leaves his / her browser connected then I cannot terminate the connect
and the Arduino will not respond..

Locally (LAN), if i terminate both browsers,i must wait for a few minutes before it will respond to a new connection.
In some cases i must drop the power to the Arduino before it will allow a reconnect.

I have several Arduino's and 2 shields - The behavior is the same on both
I also relocated the Ethernet source to another connection - same no change.
--------------------------------------------------------------------------------------------------------------
Joe


-------------------------------------------------------------------
jfhaugh,
Quote
Web browsers should be able to deal with a connection that's been closed even when "keep-alive" is TRUE in the request header.  I force close connections all the time and browsers manage to deal with it.

Given that the Arduino has such a limited connection capability, I'd force close =all= connections, always.  Let the browser create a new one and make it so the Arduino always has as many "free" connections as possible.

Your approach sound reasonable..

How do you force close connections? - manually or via  Arduino code?

I thought these would do that.

client.stop(); //stopping client
client.flush();

Or do i use an Ethernet client (close) command of some sort?

Thanks For all the feed back
Joe
40  Using Arduino / Programming Questions / Re: Webserver unresponsive when more than 1 tcp connection is made on: February 19, 2012, 09:29:48 am
Quote
Quote
I was wondering if you would suggest how to force a connection termination after x time?
If you can't even add three lines of code to print the time, how would you implement a forced closing of the connection?

I can implement limited code and have been able to build a basic server  but unfortunately your explanation is not always perfect, so new people who are just learning do miss the simple things.

Joe
41  Using Arduino / Programming Questions / Re: Webserver unresponsive when more than 1 tcp connection is made on: February 19, 2012, 09:25:17 am
PaulS,

Another thought,

I was wondering if it is possible or easy to add a command which when sent by a web browser would terminate the current TCP connection?

Maybe even add a button on the web page to force an Exit / Close Connection?

Joe
42  Using Arduino / Programming Questions / Re: Webserver unresponsive when more than 1 tcp connection is made on: February 19, 2012, 09:14:31 am
Quote
Quote
Any suggestions?
char inData[30];
does allocate space to hold 30 characters, and no re-allocation needs to be done to add a character to the array. Therefore, no memory fragmentation.

Did some looking around on how to implement or replace my current method using char inData[30];     but a search found nothing

Need your assistance on adding this method

-------
Quote
Quote
Well, I am open to suggestions on how to rework it to make it more efficient, smaller but with the same capabilities
Well, one wonders just how much centering and color and specific font size contribute to the page.

Code:

          client.println(F("<center></center>"));

Needed?

Ok will try to remove extra formatting to reduce overall file size.

------------

Quote
I would try adding a Serial.print() statement to print the value of micros() when starting to send the page back, and another to print the value of micros() when done sending the page back, and see just how long it takes to send the page.

The wiznet chip can support 4 simultaneous connections, but the Arduino can only deal with one at a time. If you are spending a lot of time sending a page, and automatically re-sending the page every 60 seconds, there may not be adequate capacity to handle multiple connections.

Sorry, to be so limited in programming knowledge but not sure how to implement your suggestion  monitor micros()?  ---- i am very new, and learning piece by piece and its  a long learning curve.

An example would be much appreciated
-----------------------

Quote
Does the responsiveness improve if you remove the REFRESH line?

I removed / commented it out - still no change - Server will time out if 2 connections are used at the same time -  - symptoms the same
--------------------
SUMMARY:

If I terminate both connections and restart the browser and try to connect - sometimes it will recover and a connection occurs, but most times it times out the browser

It appears to me, the webserver is not releasing the connection completely, or gets confused when more than 1 connection is active.

I was wondering if you would suggest how to force a connection termination after x time?  -or if certain condition occurs ?

---
Thanks
Joe
43  Using Arduino / Programming Questions / Re: Webserver unresponsive when more than 1 tcp connection is made on: February 18, 2012, 08:32:54 pm
http://xxxxx.radxxx.no-p.com:84/?H=1&A=1&F=1&M=1



Quote
Code:

String  readString = String(30);   // string for fetching data from address

Why are you using the copy constructor to initialize readString to "30"?


To ensure i have a string length long enough to read in the client inputs?

Any suggestions?

-------------------------------------
Quote
Code:

  byte client_ip[4];

A local variable that almost immediately goes out of scope. How useful is that?

old code - removed it   -- no changes, same symptoms


-----------------------------------
Quote
Code:

          delay(2);

Why? This just boggles the mind. You are complaining about unresponsiveness, yet you have this useless delay...

Granted it's not a very long delay, but get rid of it.

Removed it - still no change - same symptoms
----------------------------

Quote
Quote
I have a working Arduino web server which serves an html web page allowing me to see the status and to control devices.
A very large web page.

Well, I am open to suggestions on how to rework it to make it more efficient, smaller but with the same capabilities
 
--------------------

Quote
Code:

          client.println(F("<font color=’green’> </font>"));
          client.println("<center>");{
          client.println(F("<form  method=get name=LED>"));

Why are all strings not in Flash>


If your referring the the client.println("center");   ---oops - I missed one

If not then How would you make it more memory efficient?

---------------------------
Quote
What you get from the client is less than 30 characters, right? Why is the overhead of the String class necessary? It fragments memory pretty badly.

This is the possible max length of a client input but could it  be even longer

http://xxxxx.radxxxx.no-p.com:84/?H=1&A=1&F=1&M=1

Was trying to  ensure i can capture the full length

Any suggestion? to make it work better or without this code

So, far, no change in symptoms withe the new changes

Thanks for the inputs
Joe
44  Using Arduino / Programming Questions / Webserver unresponsive when more than 1 tcp connection is made on: February 18, 2012, 07:11:46 pm
Code:

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0x90, 0xA2, 0xDA, 0x00, 0xCD, 0x3E };  //Set your Ethernet Shield's MAC address
byte ip[] = {  192,168,1,131 };    // Set your shield's  IP address
byte gateway[] = {  192,168,1,1 };   //if you need  a gateway IP
byte subnet[] = { 255,255,255,0 };    // Change  to your subnet address

 
EthernetServer  server(85);                // server port

// declare variables

int     ledPin = 6;                // LED1
int     heatpin = 7;               // ANTENNA
int     aedpin = 5;                // LED3 
int     fedpin = 8;                // fE PWR
int     medpin = 9;                // me - anolog pin 9 for fan control
int     sensorPin = A0;            // analog in 0 forlight sense
int     sensorValue = 0;           // integer for the analog sensor
int     PIRstate = 0;              // variable for PIR sensor status
int     PIR = 2;                   // PIR sensor is connected to digital pin 2
int     motorlevel = 0;                // motor
String  readString = String(30);   // string for fetching data from address
boolean LEDON = false;             // LED1 status flag
boolean HEDON = false;             // ANTENNA status flag 
boolean AEDON = false;             // led3 status AE



 
// SETUP NOW

void setup()
{   
 
  Ethernet.begin(mac, ip, gateway, subnet ); //start Ethernet
  server.begin();  //test
 
 
  pinMode(ledPin, OUTPUT); //Set pin 6 to output
  pinMode(heatpin, OUTPUT); // set pin 7 to output
  pinMode(aedpin, OUTPUT); // set pin 5 to output
  pinMode(fedpin, OUTPUT); // set pin 8 to output
  pinMode(PIR, INPUT); // set pir to input
  pinMode(medpin, OUTPUT); // set pin a3 to output
  byte client_ip[4];
   
  sensorValue = analogRead(sensorPin);
  }

void loop(){
 
  EthernetClient client = server.available();  // Create a client connection
 
  if (client) {
    boolean current_line_is_blank = true; //new
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // send a reply
       
        if (readString.length() < 30) { //read char by char HTTP request
          readString.concat(c);
        } //store characters to string

       
// HTML Code 

if (c == '\n' && current_line_is_blank) {
         
          // HTML Code
          client.println(F("HTTP/1.1 200 OK")); //output HTML data starting with standard header
          client.println(F("Content-Type: text/html"));
          client.println();
          client.print(F("<body style=background-color:BLACK>")); //set background to BLACK
          // Auto refresh webpage every 60 seconds
          client.println(F("<META HTTP-EQUIV=REFRESH CONTENT=60 URL=>"));
          client.println("<center>");
          client.println(F("<font color=’green’><h1>INTERNET -- CONTROL </font></h1>/"));//send first heading
          client.println(F("<hr />"));
          client.println(F("<font color=’#0D8112’ size=’5′> "));
          client.println("</center>");
          motorlevel = 0;
      }       
 
           //indexOf("L=")

        if (c == '\n') { //if HTTP request has ended

          int Le = readString.indexOf("L="); //here is a key component of where
          int He = readString.indexOf("H="); //the status is being read by the arduino
          int Ae = readString.indexOf("A=");
          int Fe = readString.indexOf("F=");
                 
          // Check if anything  should be lighted or turned on
                         
                 
            if (Le > 1){

            if (readString.substring(Le,(Le+3)) == "L=1") { //led has to be turned ON
              digitalWrite(ledPin, HIGH); // set the LED on
             
              LEDON = true;
            }

            if (readString.substring(Le,(Le+3)) == "L=0") {
              //led has to be turned OFF
              digitalWrite(ledPin, LOW); // set the LED OFF
             
              LEDON = false;
            }
          }

          if (Fe > 1){

            if (readString.substring(Fe,(Fe+3)) == "F=1") { //PWR  has to be turned ON
              digitalWrite(fedpin, HIGH); // set the PWR on
             
              FEDON = true;
            }

            if (readString.substring(Fe,(Fe+3)) == "F=0") { //PWR has to be turned OFF
              digitalWrite(fedpin, LOW); // set the PWR OFF
             
              FEDON = false;
            }
          }
                       
          sensorValue = analogRead(sensorPin);

          // detemine / print is room is dark or light
         

          client.print(sensorValue);   //  a test to see the photo sensor value

          if (sensorValue < 550) {
            client.println( F("<center><font color ='deepskyblue' >THE ROOM IS NOW - *DARK* - </font></center>") );
          }
         
          else {
            client.println( F("<center><font color ='gold' >THE ROOM IS NOW  - *BRIGHT* -  </font></center>") );
          }
                 
          client.println(F("<hr />"));
                         
          client.println(F("<center></center>"));
          client.println(F("<font color=’green’> </font>"));
          client.println("<center>");{
          client.println(F("<form  method=get name=LED>"));
          client.println(F("<button name=F value=1 type=submit style=height:100px;width:130px>PWR On</button>"));
          client.println(F("<button name=F value=0 type=submit style=height:100px;width:130px>PWR Off</button>"));
          client.println(F("</form><br />"));
          client.println(F("<hr />"));
          client.println("</center>");
           client.print(F("<form method=get name=LED>"));
           client.print(F("<input type='radio' name='A' value='1'>LED3 ON<br>"));
           client.print(F("<input type='radio' name='A' value='0'>LED3 OFF<br><br>"));
           client.println(F("<input type=submit value=submit></form>"));
           client.println(F("<hr />"));
                                     
           }
          // DETERMINE WHAT STATUS TO PRINT 
         
          client.print(F("<font size=’5′>LED1 status: "));
          if (LEDON == true) {
            client.println(F("<font color='#FF0000' size=’5′>ON</font>")); //red

          }
          else {
            client.println(F("<font color='#0099FF' size=’5′>OFF</font>")); //blue

          }
          client.println(F("<br />"));
         
          //printing ant status
         
          client.print(F("<font color='#00B200'>ANT status: ")); //green
          if (HEDON == true) {
            client.println(F("<font color='#FF0000' size=’5′>ON</font>")); //red
           
          }
          else {
            client.println(F("<font color='#0099FF' size=’5′>OFF")); //blue
           
          }
          client.println(F("<br />"));
         
          //printing AEant status
         
          client.print(F("<font size=’5′ font color='#00B200'>LED3 status: ")); //green
          if (AEDON == true) {
            client.println(F("<font color='#FF0000' size=’5′>ON")); //red
            //  Serial.print("LED3 on");
          }
          else {
            client.println(F("<font color='#0099FF' size=’5′>OFF"));//blue
           
          }
          client.println(F("<br />"));

         
          // WEB PAGE Footer
         
          client.println(F("<hr><center><a href=http://xxxxxx:xxx>WEBPAGE</a><br />"));
          client.println(F("<p><font color=darkcyan>This Page  Will Refresh Every 60 seconds.</font></center>"));
         
         
          client.println(F("<hr />"));
          client.println(F("</body></html>"));


          readString="";
          delay(2);
          client.stop(); //stopping client
          client.flush();
        }
      }
    }
  }
}





I have a working Arduino web server which serves an html web page allowing me to see the status and to control devices.
If I connect from a single PC it works fine.  I can turn devices on and off  and see status changes.

If I now go to another PC and connect, it causes the Arduino Webserver to become non responsive.

if i connect on one pc and forget to close the browser and then decide to go connect from another pc - the server will not answer..
Or if i am connected and someone else connects, within a few seconds the server becomes unresponsive

Any suggestions how to fix the problem?

45  Using Arduino / Programming Questions / Re: Display IP of current TCP connection on: February 18, 2012, 06:32:07 pm
// Web server to turn devices on  / off via a web page

Code:

#include <SPI.h>
#include <Ethernet.h>

// declare network stuff

byte mac[] = {  0x90, 0xA2, 0xDA, 0x00, 0xCD, 0x32 };  //Set your Ethernet Shield's MAC address
byte ip[] = {  192,168,1,121 };    // Set your shield's  IP address
byte gateway[] = {  192,168,1,1 };   //if you need  a gateway IP
byte subnet[] = { 255,255,255,0 };    // Change  to your subnet address
byte client_ip[4];
  
  
EthernetServer  server(8584);                // server port

// declare variables

int     ledPin = 6;                // LED1
int     heatpin = 7;               // ANTENNA
int     aedpin = 5;                // LED3  
int     fedpin = 8;                // fE PWR
int     medpin = 9;                // me - anolog pin 9 for fan control
int     sensorPin = A0;            // analog in 0 forlight sense
int     sensorValue = 0;           // integer for the analog sensor
int     PIRstate = 0;              // variable for PIR sensor status
int     PIR = 2;                   // PIR sensor is connected to digital pin 2
int     motorlevel = 0;                // motor
String  readString = String(30);   // string for fetching data from address
boolean LEDON = false;             // LED1 status flag
boolean HEDON = false;             // ANTENNA status flag  
boolean AEDON = false;             // led3 status AE
boolean FEDON = false;             // power FE pin status
boolean MEDON = false;
boolean MEDON1 = false;            //MED SPEED STATUS ON
boolean PEDON = false;

 
// SETUP NOW

void setup()
{    
  
  Ethernet.begin(mac, ip, gateway, subnet ); //start Ethernet
  server.begin();  //test
  
  
  pinMode(ledPin, OUTPUT); //Set pin 6 to output
  pinMode(heatpin, OUTPUT); // set pin 7 to output
  pinMode(aedpin, OUTPUT); // set pin 5 to output
  pinMode(fedpin, OUTPUT); // set pin 8 to output
  pinMode(PIR, INPUT); // set pir to input
  pinMode(medpin, OUTPUT); // set pin a3 to output
 
  
  sensorValue = analogRead(sensorPin);
  }
// LOOP NOW

void loop(){
  
  EthernetClient client = server.available();  // Create a client connection
  
  if (client) {
    boolean current_line_is_blank = true; //new
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // send a reply
        
        if (readString.length() < 30) { //read char by char HTTP request
          readString.concat(c);
        } //store characters to string

      
// HTML Code  

if (c == '\n' && current_line_is_blank) {
          
          // HTML Code
          client.println(F("HTTP/1.1 200 OK")); //output HTML data starting with standard header
          client.println(F("Content-Type: text/html"));
          client.println();
          client.print(F("<body style=background-color:BLACK>")); //set background to BLACK
          // Auto refresh webpage every 60 seconds
          client.println(F("<META HTTP-EQUIV=REFRESH CONTENT=60 URL=>"));
          client.println("<center>");
          client.println(F("<font color=’green’><h1>INTERNET -- CONTROL </font></h1>/"));//send first heading
          client.println(F("<hr />"));
          client.println(F("<font color=’#0D8112’ size=’5′> "));
          client.println("</center>");
          motorlevel = 0;
      }      
  
           //indexOf("L=")

        if (c == '\n') { //if HTTP request has ended

          int Le = readString.indexOf("L="); //here is a key component of where
          int He = readString.indexOf("H="); //the status is being read by the arduino
          int Ae = readString.indexOf("A=");
          int Fe = readString.indexOf("F=");
          int Me = readString.indexOf("M="); //motor / fan
          int Pe = readString.indexOf("P="); //OFF

          // Check if anything  should be lighted or turned on
        
         if (Me > 1){

            if (readString.substring(Me,(Me+3)) == "M=1") { //motor has to be turned ON
             motorlevel = 255;
              analogWrite(medpin, motorlevel); // set the LED on
            
             MEDON = true; //  USED FOR STATUS
             MEDON1 = false; // USED FOR STATUS
             }

             if (readString.substring(Me,(Me+3)) == "M=0") {
              //motor dim /
              motorlevel = 125;
              analogWrite(medpin,motorlevel); // set the FAN /LED DIM
               MEDON1 = true;
               MEDON = false;
              }
              else if (readString.substring(Me,(Me+3)) == "M=2") {
              //motor OFF /
              motorlevel = 0;
              analogWrite(medpin,motorlevel); // set the / fan /LED OFF
                            
              MEDON = false;
              MEDON1 = false;
            }
          }
                  

   // This is the get ip code i found

 client.IP_address(&client_ip[0]);
          client.println("Your IP is:");
          for (int n = 0; n<=3; n++)
            {
            client.print((int)client_ip[n]);
            client.print(".");
            }
 // ------------------------------------------------------------------
// WEB PAGE Footer
          
          client.println(F("<hr><center><a href=http://RADMAN.NO-IP.COM:8888>WEBPAGE</a><br />"));
          client.println(F("<p><font color=darkcyan>This Page  Will Refresh Every 60 seconds.</font></center>"));
          
        
          client.println(F("<hr />"));
          client.println(F("</body></html>"));


          readString=""; //clearing string for next read
          delay(2); //delay RX DATA
          client.stop(); //stopping client
          client.flush();
        }
      }
    }
  }
}

I tried adding the get ip code but get -  get_ip:5: error: expected constructor, destructor, or type conversion before '.' token
Not sure if it is the code or where i am putting it.
Pages: 1 2 [3] 4