Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Networking, Protocols, and Devices / Re: WEB SERVER - How To Read An HTML Form Button on: November 21, 2012, 08:45:29 pm
PaulS,

I have a working arduino web server with several buttons, temperature, button status, lcd  etc etc, using the html code P(FORMOPEN) = "<form  method=get name=LED>"; and it has been working well for many months.
My current arduino web server uses readString.indexOf to get the input from the buttons for this server.



I would like to add a web login feature, so i tried using the webaduino example.  (the code i posted)
I am trying to incorporate this type of function, unfortunately,  the webadaduino uses another method to read button inputs, which i am not able to figure out, nor could i find any examples!

Joe

2  Using Arduino / Networking, Protocols, and Devices / WEB SERVER - How To Read An HTML Form Button on: November 21, 2012, 02:32:28 pm
I compiled this sketch and have no errors.
The web buttons appear on the web page and when clicked they do send a code but I cannot figure how to link
the button to the action
I am requesting some basic code /help on how to read the button form displayed on the web server page to turn on digitalwrite pin
Once someone shows me how to do one button , i can work from there....

Thanks,

Joe





Code:
/* jb modified - Web_Authentication.ino - */


/* you can change the authentication realm by defining
 * WEBDUINO_AUTH_REALM before including WebServer.h */
#define WEBDUINO_AUTH_REALM "Weduino Authentication Example"

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




static uint8_t mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

static uint8_t ip[] = {
  192, 168, 1, 136 };



String readString;  
boolean tog1 = false; //rf1 on
boolean tog2 = true; //rf2 off

//-----------------------------------------------------------------------

/* This creates an instance of the webserver.  By specifying a prefix
 * of "", all pages will be at the root of the server. */
#define PREFIX ""
WebServer webserver(PREFIX, 98);

void defaultCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
  server.httpSuccess();
  if (type != WebServer::HEAD)
  {
    P(helloMsg) = "<h1>First entry page -Hello, World!</h1><a href=\"private.html\">ACCESS ADMIN CONTROL page</a>";
    server.printP(helloMsg);
  }
}

void privateCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
  /* if the user has requested this page using the following credentials
   * username = admin
   * password = joe
   * display a page saying "Hello User"
   *
   * the credentials have to be concatenated with a colon like
   * username:password
   * and encoded using Base64 - this should be done outside of your Arduino
   * to be easy on your resources
   *
   * in other words: "dXNlcjp1c2Vy" is the Base64 representation of "admin:joe"
   *
   * if you need to change the username/password dynamically please search
   * the web for a Base64 library */
  if (server.checkCredentials("YWRtaW46am9l"))
  {
    server.httpSuccess();
    
    if (type != WebServer::HEAD)
    {
      Serial.println(readString);
  

// HTML FORM  BUTTONS TO TURN ON / OFF  ITEM

      P(background) = "<body style=background-color:BLACK>"; //set background to BLACK
      P(helloMsg) = "<center><font color=’green’> <h1>HOME - INTERNET -- CONTROL </h1></font></center>";
      P(FORMOPEN) = "<form  method=get name=LED>";
      P(button1) = "<center><button name=tog1 value=1 type=submit style=font-weight:bold;color:GREEN;height:70px;width:145px>AC POWER RF FAN  On</button>";
      P(button2) = "<button name=tog2 value=1 type=submit style=font-weight:bold;color:red;height:70px;width:145px>AC POWER RF FAN Off</button>";
      P(FORMCLOSE) = "</form>";
      
      // DISPLAY layout - print items to web page:

      server.printP(background);

      server.printP(helloMsg);
      server.printP(FORMOPEN);
      server.printP(button1);
      server.printP(button2);
    
    }
  }

  else
  {
    // send a 401 error back causing the web browser to prompt the user for credentials
    server.httpUnauthorized();
  }
}


void setup()
{
  Ethernet.begin(mac, ip);
  webserver.setDefaultCommand(&defaultCmd);
  webserver.addCommand("index.html", &defaultCmd); // FIRST PAGE
  webserver.addCommand("private.html", &privateCmd); // ADMIN CONTROL - REQUIRES ACCESS
  webserver.begin();


  
  pinMode(5, OUTPUT); //pin selected to control pwr1 ON
  pinMode(6, OUTPUT); //pin selected to control pwr1 off
  
}
  

void loop()
{
  char buff[64];
  int len = 64;
  
  // ===============================================================================================
  
  
  // - PROBLEM AREA - HOW DO GET TOG1 / TOG 2 - TO BE READ - WHEN A WEB PAGE BUTTON IS CLICKED / SELECTED ????
  //-----------------------------------------------------------------------------------------------------------------------------------------

          if(readString.indexOf("tog1") >0)// on   for PWR MODULE ID 1 control
          {

            digitalWrite(5, HIGH);
            tog1 = true;
            delay(500);
            digitalWrite(5, LOW);

          }

          if(readString.indexOf("tog2") >0)// off   PWR MODULE ID 1 control
          {
            digitalWrite(6, HIGH);
            delay(500);
            digitalWrite(6, LOW);
            tog1 = false;

          }
//=====================================================================================================


 // process incoming connections one at a time forever /
  webserver.processConnection(buff, &len);

      

}
3  Topics / Home Automation and Networked Objects / Re: Arduino Controller android app - Help on: November 15, 2012, 05:37:55 pm
Marque,

I saw your sketch and it looked like it would be great for my android tablet. nexus 7

I have downloaded your latest arduino sketch from the arduino forum. (relay version)

I entered the default ip 192.168.1.69 and port 80 in the android tablet - saved the settings

I also uploaded the sketch to the aurduino
it compiled fine.

Problem:

1.  on android the top part displays webpage not found.

2. When i look at the serial monitor, i keep getting  this:

Getting IP......
My IP address: 255.255.255.255
Gateway IP address is 255.255.255.255
DNS IP address is 0.0.0.0

I have done a port forward 192.168.1.69 port 80
i am running arduino 1.02 but tried it with 1.00 with the same problem

Any suggestions how to get this working?

I use the arduino uno r3 with an ethernet 5100 shield - and it works fine with other web arduino software

Thanks
Joe
4  Using Arduino / Programming Questions / Re: Timer Is stopping all other activty - Help Request (solved) on: April 30, 2012, 12:57:32 pm
Thanks for the replies

johnwasser,

Changed the code as per  your suggestion / info 
Works!



Code:
 
  if (rffan == HIGH) // if temp2 went high then rffan is high  over temp occurred - start  counting
 {
    digitalWrite(9,HIGH); // Turn ON HIGH TEMP ALARM
    //record start time)..
    //start_time = millis();
    current_time = millis();
    elapsed_time = current_time - start_time;
    Serial.println("counting");
    Serial.println(elapsed_time);
   
 }

if ((rffan == HIGH) && (elapsed_time >= 60000)) // fan on and 1 minute check reached?
{
Serial.println("A3FAN OFF");
Serial.println(elapsed_time);
digitalWrite(A3, LOW);  // Turn off A3  temp2 fan

rffan =LOW; // reset temp2 status to normal temperature condition
}
5  Using Arduino / Programming Questions / Timer Is stopping all other activty - Help Request (Solved) on: April 30, 2012, 10:46:08 am
I am trying to create a timer that will keep a fan on and leave it on until a 1 minute period has passed, then turn it off.
Once the fan has turn on ,it must stay on for a fixed time of 1 minute before shutting off


I just posted the timer portion, as the full sketch is to large.

The code below works but, while the fan is on and the timer is counting, nothing else is responsive.

What am i doing wrong?

Any help would be appreciated
Thanks
Joe

Code:
//*************TIMER CHECK**********************************
//If conditions are true turn on the A3 fan until 1 minute has past then shutoff of A3  are true...

if(rffan == HIGH) // status for temperature sensor 2  (temp2)
{
  
  //record start time...
  start_time = millis();
  Serial.println("start_time");
  Serial.println(start_time);

  //turn on A3 fan, turn normal temp led off and high temp led on

  // digitalWrite(A3, HIGH);  // this is the temp2 fan
  digitalWrite(A2,LOW); // BLUE LED off- NORMAL temp
  digitalWrite(9,HIGH); // HIGH TEMP LED

  //Continuosly check for finish time...
  do
  {

    current_time = millis();
    elapsed_time = current_time - start_time;
    Serial.println("counting");
    Serial.println(elapsed_time);
  }
  while(elapsed_time < 60000); // (1min) * (60s/min) * (1000ms/s)  

}
//turn OFF A3 fan if the count has been met
if (elapsed_time > 60000)
{
  digitalWrite(A3, LOW);  // Turn off A3  temp2 fan
}
Serial.println("time complete");
Serial.println(elapsed_time);



// ===========end ===TIMER=================================

6  Using Arduino / Networking, Protocols, and Devices / Re: W5200 ETHERNET SHIELD compatibily problems on: April 25, 2012, 02:37:48 pm
SurferTim,

Thanks for the followup!..

Joe
7  Using Arduino / Networking, Protocols, and Devices / Re: W5200 ETHERNET SHIELD compatibily problems on: April 25, 2012, 10:26:00 am
SurferTim,

When i try to compile with the new files, i get this:

C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp: In member function 'int EthernetClass::maintain()':
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:88: error: 'DHCP_CHECK_NONE' was not declared in this scope
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:91: error: 'class DhcpClass' has no member named 'checkLease'
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:93: error: 'DHCP_CHECK_NONE' cannot appear in a constant-expression
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:96: error: 'DHCP_CHECK_RENEW_OK' was not declared in this scope
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:97:


Had to put back my original back ethernet to compile.

joe
8  Using Arduino / Networking, Protocols, and Devices / Re: W5200 ETHERNET SHIELD compatibily problems on: April 24, 2012, 05:59:12 pm
SurferTim,

All working well - your files for the 5100 work fine and your files for the 5200 also work.

I found i had to copy over the files, depending if i am using a w5100 or w5200.

The idea of creating a new full complete copy of the Ethernet library dir ,adding your new 5200 files to it  and then renaming it to ethernet5200 did not work.
--------------------------------
Ethernet         - original
Ethernet5200  - a copy of the original but with your modified files for the w5200
Odd, as I was sure it was an easy work around.

A bit of a pain to copy the 5200 and 5100 files back and forth, and trying to remember which one is installed........ but at least i can use either ethernetshield

After searching around the net, yours still are the only ones that worked for me!
Not even the ones sent by the company worked..


Thanks
Joe


9  Using Arduino / Networking, Protocols, and Devices / Re: W5200 ETHERNET SHIELD compatibily problems on: April 24, 2012, 02:04:53 pm
SurferTim,


Will give it a try and get back to you

Thanks for the update

Joe
10  Using Arduino / Networking, Protocols, and Devices / Re: W5200 ETHERNET SHIELD compatibily problems on: April 21, 2012, 12:58:22 pm
SurferTim,

Ah, ok  - So seems that i could make a copy of the current original complete ethernet lib and rename the directory to ethernet5200

that way my libraries would  both show --- ethernet (original) and ethernet5200 which i would select when working with a 5200)

Thanks very much for your inputs /effort!!

Joe

11  Using Arduino / Networking, Protocols, and Devices / Re: W5200 ETHERNET SHIELD compatibily problems on: April 21, 2012, 12:36:16 pm
SurferTim,

W5200 ETHERNET SHIELD: GOOD!

Compiles  - my code perfectly
W5200 - is communicating  - good responses

--------------------------------------------------
W5100 ETHERNET SHIELD: NOT GOOD

When i now put my W5100 Ethernet shield on, it compiles but does not communicate
If i put the original 5100 libs back then it complies and communicates.

It is almost there.....

Thanks
Joe
12  Using Arduino / Networking, Protocols, and Devices / Re: W5200 ETHERNET SHIELD compatibily problems on: April 21, 2012, 11:15:21 am
SurferTim,

Sorry about that...

New files attached

Joe

13  Using Arduino / Networking, Protocols, and Devices / Re: W5200 ETHERNET SHIELD compatibily problems on: April 21, 2012, 10:33:33 am
SurferTim,

See attachment - the 2 files were supplied with the w5200.

Thanks
Joe
14  Using Arduino / Networking, Protocols, and Devices / Re: W5200 ETHERNET SHIELD compatibily problems on: April 21, 2012, 09:02:58 am
PaulS,

Yes the ?? makes it stick out more..... thanks for asking
Joe


---------------------------
These are the Compile errors i get when i put in the new 5100.cpp and 5100.h files in the dir utility

C:\ARDUINO\arduino-1.0\libraries\Ethernet\utility\socket.cpp: In function 'uint16_t bufferData(SOCKET, uint16_t, const uint8_t*, uint16_t)':
C:\ARDUINO\arduino-1.0\libraries\Ethernet\utility\socket.cpp:357: error: 'class W5100Class' has no member named 'send_data_processing_offset'

----------------------
The errors occur on my code or any other of several example sketches.
As soon as I put back the original 5100.cpp and 5100.h files -  it compiles but w5200 will not communicate





Below is one of the example codes which produces the compile errors indicated above.

Code:
/*
  Web Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 4 Sep 2010
 by Tom Igoe
 
 */

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 139);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(90);

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("<br />");
          }
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}
15  Using Arduino / Networking, Protocols, and Devices / W5200 ETHERNET SHIELD compatibily problems on: April 20, 2012, 10:10:06 pm
I purchased a w5200 Ethernet shield by ekitszone    - i am using an UNO ver R3 and ide.10


They indicated it is 100 percent compatible with current W5100 shield Ethernet library

When i compile with the current original ethernet library using the w5100 shield - all works fine - compiles and Ethernet allows a connection.
When i install the W5200,it compiles but Ethernet does not work.

I was told to replace the 2 files in the arduino Ethernet library utility dir with 2 new files w5100.h and w5100.cpp - when i do this my pgm no longer compiles.

Anyone have any ideas to a solution??

Thanks
Joe
Pages: [1] 2 3 4