Mega2560 with onboard wifi - couldn´t get wifi to run (Timeout)

Hi guys!
I am struggling to get the wifi on my activated. Did follow various instructions, did flashing excatly as described on "DIY Guide - Mega2560 WiFi".
But for some reason, i always get the timeout-message. I also increased the timeout in the file "EspDrv.cpp". All with no effect. Once i got the wifi module connected in direct mode (Pins 5,6,7 ON) to my wifi. But never i got an AT-Command through.
I really would appreaciate any hint! :slight_smile:
Andy

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the Installation & Troubleshooting category.

getting the DIP switches correct is critial - have a look at Programming Wemos Mega + WiFi
R3

are you attempting to use AT commands from the ESP8266 serial monitor (set the dip switches 1-4 and 7-8 OFF and 5-6 ON) or from the MEGA (Setting DIP switches ON ON ON ON OFF OFF OFF)?
if fram the mega upload your program code which transmitted AT commands to the ESP8266 (make sure you use Serial3) using code tags </>

I do not use ESP8266 AT commands but program the ESP8266 directly

I recommend you to update the AT firmware to 1.7.5 (from SDK 3.0.5) and use my WiFiEspAT library

Will try tmrrw n8! :slight_smile:

Well, im kind a frustrated right now. I tried different flashes. I got that far, that i enabled an AP directly from the esp. But i didn´t get it to communicate with my esp-code on the mega. Did some setups already, so i am not pretty new to this. Had the same code on an UNO with an external ESP8266 running before. It did setup the wifi and hosted my site. But the capacity of the uno was not enough for my project. So i changed to the mega, wich i thought was a good idea. Not so sure anymore.
Is there anyone around, who did this before and can support me?
Next step ist, to buy another mega with no onboard-wifi and try to get my old code wich the uno-ESP mounted to run (wich is not working on this mega).

the basic plan
https://github.com/JAndrassy/WiFiEspAT#getting-started

the SDK 3.0.5 contains the AT firmware binaries
https://github.com/espressif/ESP8266_NONOS_SDK/releases

the upload command

esptool.py write_flash --flash_size 2MB-c1 0x0 boot_v1.7.bin 0x01000 at/1024+1024/user1.2048.new.5.bin 0x1fb000 blank.bin 0x1fc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x1fe000 blank.bin

ask if you are stuck

why not move to the ESP32 microcontroller which has on board WiFi, Bluetooth Classic and BLE and can be programmed with the Arduino IDE
it would save all the problems of programming two systems and the communications between them

1 Like

As i see it, there shouldn´t be problems. I did "some" tests in the meantime. The ESP seem to be ok. The mega seems to be ok. And also the com-channel between them seems to be ok (tested with Serial passthrough of examples). But for some reason (i didn´t follw Juraj´s hint yet, but will try tmrrrw morning) i didn´t get my code on the mega to init the esp. Always get timeout.
Well, tmrrw is another day - room for chances! :slight_smile:

Ok, i flashed the ESP - no errors. Then i loaded the example-code for WifiEspAT "Check firmware" on the mega.
I took out the software-serial, changed from serial1 to serial2 & 3, changed baudrates. Of course one by one. Dips 1-4 are ON, the rest is OFF. Serial-switch is on TX/RX3. But no connection. Did i miss something?
Also tried this passthrough-code again - works fine, but seems like the eps is kind of flooding data to the serial...

void setup() {
  Serial.begin(115200);
  Serial3.begin(74880);
}

void loop() {
  if (Serial.available()) {      // If anything comes in Serial (USB),
    Serial3.write(Serial.read());   // read it and send it out Serial1 (pins 0 & 1)
  }

  if (Serial3.available()) {     // If anything comes in Serial1 (pins 0 & 1)
    Serial.write(Serial3.read());   // read it and send it out Serial (USB)
  }
}

With the code running on the mega i get this continiously:
2nd boot version : 1.7(5d6f877)
SPI Speed : 40MHz
SPI Mode : QIO
SPI Flash Size & Map: 16Mbit(512KB+512KB)
jump to run user1 @ 1000

correct flash map
mismatch map 5,spi_size_map 3
system_partition_table_regist fail
V2
Mo
rf_cal[0] !=0x05,is 0xFF

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 2592, room 16
tail 0
chksum 0xf3
load 0x3ffe8000, len 764, room 8
tail 4
chksum 0x92
load 0x3ffe82fc, len 676, room 4
tail 0
chksum 0x22
csum 0x22

the boot log is at 74880 but the AT firmware uses 115200 baud.

I am not getting any further.


that addresses are not right if you don't upload with 2MB setting.
use 2 MB setting or addresses for the 4 MB flash.
the esptool parameters I provided are for 2MB because the AT binaries are build for 2 MB.
the Flash Download Tool will modify the binary for 4 MB before upload.

It runs! For some reason it runs. Also with my old code...
Ok, just give me a few days to finish the website and then i will provide the code!

Ok, here is the code - and the next issue :slight_smile:

To outline my project: It´s a remote controlled platform with three independend axles. All-wheel-drive/steering. Meant to be used for wildlife-observation. So it´s not very fast, but it can crawl very quiet and extremely slow. Two cams with ir on board. Just to give you an idea.

The code works fine so far, but for some reason it struggles with publishing the website if if activate the rest of the code of page 3 (see code line 378-398).
To illustrate the differences a will post two picts to show the problem. Maybe someone can do kind of a quick check, may be in the structure of my code is a problem.
Besides activating the mentioned lines everything works, as it should.
The complete code uses just 10% of the availiable space and about 65% of the global vars. I "slimmed" the code, but before it was working with app. 80% of used global vars.


fter#include <WiFiEsp.h>
#include <WiFiEspClient.h>
#include <WiFiEspServer.h>
#include <WiFiEspUdp.h>


/*
 WiFiEsp example: WebServerAP

 A simple web server that shows the value of the analog input 
 pins via a web page using an ESP8266 module.
 This sketch will start an access point and print the IP address of your
 ESP8266 module to the Serial monitor. From there, you can open
 that address in a web browser to display the web page.
 The web page will be automatically refreshed each 20 seconds.

 For more details see: http://yaab-arduino.blogspot.com/p/wifiesp.html
*/
//Ausgänge Verbraucher
//licht
#define drain_20 20 
#define drain_21 21 // light cabin
#define drain_22 22 // light front
#define drain_23 23 // light left
#define drain_24 24 // light right
#define drain_25 25 // light rear
#define drain_26 26 // light cam front
#define drain_27 27 // light cam pod
#define drain_28 28 // light cam front ir
#define drain_29 29 // light cam pod ir
#define drain_30 30 // light robot
#define drain_31 31
#define drain_32 32
#define drain_33 33
#define drain_34 34
#define drain_35 35
#define drain_36 36
#define drain_37 37
#define drain_38 38
#define drain_39 39
#define drain_40 40
#define drain_41 41
#define drain_42 42
#define drain_43 43
#define drain_44 44
#define drain_45 45


int page_refresh = 0;
int page_refresh_low = 20;
int page_refresh_high = 5;
int page_selection = 1;

//buttons
String button_menu_standard = "<button style='width:75px; height:50px' class=\'button\'>";
String button_menu_highlight = "<button style='width:75px; height:50px; background-color:green; color:white' class=\'button\'>";
String button_menu_red = "<button style='width:75px; height:50px; background-color:red; color:white' class=\'button\'>";
String button_switch_standard = "<button style='width:392px; height:40px' class=\'button\'>";
String button_switch_highlight = "<button style='width:392px; height:40px; background-color:green; color:white' class=\'button\'>";
String button_switch_red = "<button style='width:392px; height:40px; background-color:red; color:white' class=\'button\'>";
String button_switch_reduced_standard = "<button style='width:193px; height:40px' class=\'button\'>";
String button_switch_reduced_highlight = "<button style='width:193px; height:40px; background-color:green; color:white' class=\'button\'>";
String button_switch_reduced_red = "<button style='width:193px; height:40px; background-color:red; color:white' class=\'button\'>";
String button2_menu_standard = "<button style='width:75px; height:50px' class=\'button button2\'>";
String button2_menu_highlight = "<button style='width:75px; height:50px; background-color:green; color:white' class=\'button button2\'>";
String button2_menu_red = "<button style='width:75px; height:50px; background-color:red; color:white' class=\'button button2\'>";
String button2_switch_standard = "<button style='width:392px; height:40px' class=\'button button2\'>";
String button2_switch_highlight = "<button style='width:392px; height:40px; background-color:green; color:white' class=\'button button2\'>";
String button2_switch_red = "<button style='width:392px; height:40px; background-color:red; color:white' class=\'button button2\'>";
String button2_switch_reduced_standard = "<button style='width:193px; height:40px' class=\'button button2\'>";
String button2_switch_reduced_highlight = "<button style='width:193px; height:40px; background-color:green; color:white' class=\'button button2\'>";
String button2_switch_reduced_red = "<button style='width:193px; height:40px; background-color:red; color:white' class=\'button button2\'>";


//Pin-Status
String drain_20_state = "off";
String drain_21_state = "off";
String drain_22_state = "off";
String drain_23_state = "off";
String drain_24_state = "off";
String drain_25_state = "off";
String drain_26_state = "off";
String drain_27_state = "off";
String drain_28_state = "off";
String drain_29_state = "off";
String drain_30_state = "off";
String drain_31_state = "off";
String drain_32_state = "off";
String drain_33_state = "off";
String drain_34_state = "off";
String drain_35_state = "off";
String drain_36_state = "off";
String drain_37_state = "off";
String drain_38_state = "off";
String drain_39_state = "off";
String drain_40_state = "off";
String drain_41_state = "off";
String drain_42_state = "off";
String drain_43_state = "off";
String drain_44_state = "off";
String drain_45_state = "off";

String control_state = "1";
String track_state = "0";
String steering_state = "1";
String direction_state = "0";
int angle_state = 0;
int speed_state = 0;

char ssid[] = "Prowler_OBM";         // your network SSID (name)
char pass[] = "12345678";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int reqCount = 0;                // number of requests received

// Variable to store the HTTP request
String header;

//WiFiServer server(80);
WiFiEspServer server(80);

// use a ring buffer to increase speed and reduce memory allocation
RingBuffer buf(8);

void setup()
{
  //Verbraucher
  pinMode(drain_21, OUTPUT);  digitalWrite(drain_21, LOW);
  pinMode(drain_22, OUTPUT);  digitalWrite(drain_22, LOW);
  pinMode(drain_22, OUTPUT);  digitalWrite(drain_22, LOW);
  pinMode(drain_23, OUTPUT);  digitalWrite(drain_23, LOW);
  pinMode(drain_24, OUTPUT);  digitalWrite(drain_24, LOW);
  pinMode(drain_25, OUTPUT);  digitalWrite(drain_25, LOW);
  pinMode(drain_26, OUTPUT);  digitalWrite(drain_26, LOW);
  pinMode(drain_27, OUTPUT);  digitalWrite(drain_27, LOW);
  pinMode(drain_28, OUTPUT);  digitalWrite(drain_28, LOW);
  pinMode(drain_29, OUTPUT);  digitalWrite(drain_29, LOW);
  pinMode(drain_30, OUTPUT);  digitalWrite(drain_30, LOW);
  pinMode(drain_31, OUTPUT);  digitalWrite(drain_31, LOW);
  pinMode(drain_32, OUTPUT);  digitalWrite(drain_32, LOW);
  pinMode(drain_33, OUTPUT);  digitalWrite(drain_33, LOW);
  pinMode(drain_34, OUTPUT);  digitalWrite(drain_34, LOW);
  pinMode(drain_35, OUTPUT);  digitalWrite(drain_35, LOW);
  pinMode(drain_36, OUTPUT);  digitalWrite(drain_36, LOW);
  pinMode(drain_37, OUTPUT);  digitalWrite(drain_37, LOW);
  pinMode(drain_38, OUTPUT);  digitalWrite(drain_38, LOW);
  pinMode(drain_39, OUTPUT);  digitalWrite(drain_39, LOW);
  pinMode(drain_40, OUTPUT);  digitalWrite(drain_40, LOW);
  pinMode(drain_41, OUTPUT);  digitalWrite(drain_41, LOW);
  pinMode(drain_42, OUTPUT);  digitalWrite(drain_42, LOW);
  pinMode(drain_43, OUTPUT);  digitalWrite(drain_43, LOW);
  pinMode(drain_44, OUTPUT);  digitalWrite(drain_44, LOW);
  pinMode(drain_45, OUTPUT);  digitalWrite(drain_45, LOW);
  //Verbraucher off

  
  Serial.begin(115200);   // initialize serial for debugging
  Serial3.begin(115200);    // initialize serial for ESP module
  WiFi.init(&Serial3);    // initialize ESP module
//  pinMode(feed_POWER, OUTPUT);
  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while (true); // don't continue
  }
//  digitalWrite(feed_POWER, HIGH);
  Serial.print("Attempting to start AP ");
  Serial.println(ssid);

  // uncomment these two lines if you want to set the IP address of the AP
  //IPAddress localIp(192, 168, 111, 111);
  //WiFi.configAP(localIp);
  
  // start access point
  status = WiFi.beginAP(ssid, 10, pass, ENC_TYPE_WPA2_PSK);

  Serial.println("Access point started");
  printWifiStatus();
  //page_selector();
  
  // start the web server on port 80
  server.begin();
  Serial.println("Server started");
}


void loop()
{
  WiFiEspClient client = server.available();  // listen for incoming clients

  if (client) {                               // if you get a client,
    Serial.println("New client");             // print a message out the serial port
    buf.init();                               // initialize the circular buffer
    while (client.connected()) {              // loop while the client's connected
      if (client.available()) {               // if there's bytes to read from the client,
        char c = client.read();               // read a byte, then
        buf.push(c);                          // push it to the ring buffer
        header += c;
        // you got two newline characters in a row
        // that's the end of the HTTP request, so send a response
        if (buf.endsWith("\r\n\r\n")) {
          sendHttpResponse(client);
          break;
        }
      }
    }
    
    // give the web browser time to receive the data
    delay(500);
    // Clear the header variable
    header = "";
    // close the connection
    client.stop();
    Serial.println("Client disconnected");

  }
}

void sendHttpResponse(WiFiEspClient client)
{
  client.print(
    "HTTP/1.1 200 OK\r\n"
    "Content-Type: text/html\r\n"
 //   "Connection: close\r\n"  // the connection will be closed after completion of the response
    "Connection: open\r\n"  // the connection will be closed after completion of the response
    "Refresh: "); client.print(page_refresh); client.print("\r\n"        // refresh the page automatically every 20 sec
    "\r\n");
    
//navigate through pages
            if (header.indexOf("GET /go/navi") >= 0) {
              Serial.println("Navigation zur Steuerung");
              page_selection = 1;
            } else if (header.indexOf("GET /go/light") >= 0) {
              Serial.println("Navigation zu Beleuchtung");
              page_selection = 2;
            } else if (header.indexOf("GET /go/drain") >= 0) {
              Serial.println("Navigation zu Verbrauchern");
              page_selection = 3;
            } else if (header.indexOf("GET /go/state") >= 0) {
              Serial.println("Navigation zum System-Status");
              page_selection = 4;
            } else if (header.indexOf("GET /go/wayp") >= 0) {
              Serial.println("Navigation zu Waypoints");
              page_selection = 5;
            }
            


    
client.print("<!DOCTYPE html>");
client.print("<html lang='en'>");
client.print("  <head>");
//client.print("    <meta name='viewport' content='width=device-width,initial-scale=1'>");
//client.print("    <meta charset='utf-8'>");
//client.print("    <meta name='generator' content='CoffeeCup HTML Editor (www.coffeecup.com)'>");
//client.print("    <meta name='dcterms.created' content='Di, 20 Sep 2022 18:12:17 GMT'>");
//client.print("    <meta name='description' content=''>");
//client.print("    <meta name='keywords' content=''>");
client.print("    <title>ATV-Onboard</title>");
client.print("    <!--[if IE]>");
client.print("    <script src='http://html5shim.googlecode.com/svn/trunk/html5.js'></script>");
client.print("    <![endif]-->");
client.print("  </head>");
client.print("<body>");


if (page_selection==1){header_reply_1(client); create_page_1(client);}
else if (page_selection==2){header_reply_2(client); create_page_2(client);}
else if (page_selection==3){header_reply_3(client); create_page_3(client);}
else if (page_selection==4){create_page_4(client);}
else if (page_selection==5){create_page_5(client);}

client.print("</body>");
client.print("</html>");
}





void printWifiStatus()
{
  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print where to go in the browser
  Serial.println();
  Serial.print("To see this page in action, connect to ");
  Serial.print(ssid);
  Serial.print(" and open a browser to http://");
  Serial.println(ip);
  Serial.println();
}

void create_page_1(WiFiEspClient client){
    page_refresh = 20;
    client.println("<a href=\'/go/navi\'>" + button_menu_highlight + "Navi</button></a>");client.println("<a href=\'/go/light\'>" + button_menu_standard + "Licht</button></a>");client.println("<a href=\'/go/drain\'>" + button_menu_standard + "Verbr.</button></a>");client.println("<a href=\'/go/state\'>" + button_menu_standard + "Status</button></a>");client.println("<a href=\'/go/wayp\'>" + button_menu_standard + "WPs</button></a></br></br>");
    client.println("<B>Navigation</B></p>");
    if (control_state=="2") {
    client.println("<a href=\'/nav/gpson\'>" + button_switch_reduced_standard + "GPS</button></a>");} else {client.println("<a href=\'/nav/gpsoff\'>" + button2_switch_reduced_highlight + "GPS</button></a>");}
    if (control_state=="1") {
    client.println("<a href=\'/nav/manon\'>" + button_switch_reduced_standard + "Manuelle Steuerung</button></a></p>");} else {client.println("<a href=\'/nav/manoff\'>" + button2_switch_reduced_highlight + "Manuelle Steuerung</button></a></p>");}
    
    //gps-control
    if (control_state=="1") {
    if (track_state=="0") {
    client.println("<a href=\'/nav/trackstart\'>" + button_switch_reduced_standard + "Starte GPS-Track</button></a></p>");}else {client.println("<a href=\'/nav/trackstop\'>" + button2_switch_reduced_highlight + "Track gestartet</button></a></p>");}
    }
    //manual control
    if (control_state=="2") {
    if (direction_state=="1") {client.println("<a href=\'/nav/reverse\'>" + button_switch_reduced_highlight + "Vorwaerts</button></a>");} else{client.println("<a href=\'/nav/forward\'>" + button2_switch_reduced_standard + "Vorwaerts</button></a>");} 
    if (direction_state=="2") {client.println("<a href=\'/nav/forward\'>" + button_switch_reduced_highlight + "Rueckwaerts</button></a></p>");} else {client.println("<a href=\'/nav/reverse\'>" + button2_switch_reduced_standard + "Rueckwaerts</button></a></p>");}
    client.println("<a href=\'/nav/acc\'>" + button_switch_standard + "Schneller (" + speed_state + "%)</button></a></p>");
    client.println("<a href=\'/nav/left\'>" + button_switch_reduced_standard + "Links (" + angle_state + "%)</button></a>"); client.println("<a href=\'/nav/right\'>" + button_switch_reduced_standard + "Rechts (" + angle_state + "%)</button></a></p>");
    client.println("<a href=\'/nav/dec\'>" + button_switch_standard + "Langsamer (" + speed_state + "%)</button></a></p>");
    client.println("<a href=\'/nav/stop\'>" + button_switch_red + "Stop</button></a></p>");
    }
    
    client.println("</p></p><B>Lenkung</B></p>");
    if (steering_state=="1") {
    client.println("" + button_switch_reduced_highlight + "Front+Mitte</button>");}else {client.println("<a href=\'/nav/stefm\'>" + button2_switch_reduced_standard + "Front+Mitte</button></a>");}
    if (steering_state=="2") {
    client.println("" + button_switch_reduced_highlight + "Heck+Mitte</button></p>");}else {client.println("<a href=\'/nav/stehm\'>" + button2_switch_reduced_standard + "Heck+Mitte</button></a></p>");}
    if (steering_state=="3") {
    client.println("" + button_switch_reduced_highlight + "Front+Heck</button>");}else {client.println("<a href=\'/nav/stefh\'>" + button2_switch_reduced_standard + "Front+Heck</button></a>");}
    if (steering_state=="4") {
    client.println("" + button_switch_reduced_highlight + "Synchron</button></p>");}else {client.println("<a href=\'/nav/stesy\'>" + button2_switch_reduced_standard + "Sychron</button></a></p>");}
  }

void create_page_2(WiFiEspClient client){
    page_refresh = 20;
    client.println("<a href=\'/go/navi\'>" + button_menu_standard + "Navi</button></a>");client.println("<a href=\'/go/light\'>" + button_menu_highlight + "Licht</button></a>");client.println("<a href=\'/go/drain\'>" + button_menu_standard + "Verbr.</button></a>");client.println("<a href=\'/go/state\'>" + button_menu_standard + "Status</button></a>");client.println("<a href=\'/go/wayp\'>" + button_menu_standard + "WPs</button></a></br></br>");
    if (drain_21_state=="off") {
    client.println("<a href=\'/21/on\'>" + button_switch_standard + "Kabine</button></a></p>");
    } else {client.println("<a href=\'/21/off\'>" + button2_switch_highlight + "Kabine</button></a></p>");}
    if (drain_22_state=="off") {
    client.println("<a href=\'/22/on\'>" + button_switch_standard + "Front</button></a></p>");
    } else {client.println("<a href=\'/22/off\'>" + button2_switch_highlight + "Front</button></a></p>");}
    if (drain_23_state=="off") {
    client.println("<a href=\'/23/on\'>" + button_switch_standard + "Links</button></a></p>");
    } else {client.println("<a href=\'/23/off\'>" + button2_switch_highlight + "Links</button></a></p>");}
    if (drain_24_state=="off") {
    client.println("<a href=\'/24/on\'>" + button_switch_standard + "Rechts</button></a></p>");
    } else {client.println("<a href=\'/24/off\'>" + button2_switch_highlight + "Rechts</button></a></p>");}
    if (drain_25_state=="off") {
    client.println("<a href=\'/25/on\'>" + button_switch_standard + "Hinten</button></a></p>");
    } else {client.println("<a href=\'/25/off\'>" + button2_switch_highlight + "Hinten</button></a></p>");}
    if (drain_26_state=="off") {
    client.println("<a href=\'/26/on\'>" + button_switch_standard + "Kamera Front</button></a></p>");
    } else {client.println("<a href=\'/26/off\'>" + button2_switch_highlight + "Kamera Front</button></a></p>");}
    if (drain_27_state=="off") {
    client.println("<a href=\'/27/on\'>" + button_switch_standard + "Kamera POD</button></a></p>");
    } else {client.println("<a href=\'/27/off\'>" + button2_switch_highlight + "Kamera POD</button></a></p>");}
    if (drain_28_state=="off") {
    client.println("<a href=\'/28/on\'>" + button_switch_standard + "Kamera Front IR</button></a></p>");
    } else {client.println("<a href=\'/28/off\'>" + button2_switch_highlight + "Kamera Front IR</button></a></p>");}
    if (drain_29_state=="off") {
    client.println("<a href=\'/29/on\'>" + button_switch_standard + "Kamera POD IR</button></a></p>");
    } else {client.println("<a href=\'/29/off\'>" + button2_switch_highlight + "Kamera POD IR</button></a></p>");}
    if (drain_30_state=="off") {
    client.println("<a href=\'/30/on\'>" + button_switch_standard + "Ausleger</button></a></p>");
    } else {client.println("<a href=\'/30/off\'>" + button2_switch_highlight + "Ausleger</button></a></p>");}
  }

void create_page_3(WiFiEspClient client){
    page_refresh = 20;
    client.println("<a href=\'/go/navi\'>" + button_menu_standard + "Navi</button></a>");client.println("<a href=\'/go/light\'>" + button_menu_standard + "Licht</button></a>");client.println("<a href=\'/go/drain\'>" + button_menu_highlight + "Verbr.</button></a>");client.println("<a href=\'/go/state\'>" + button_menu_standard + "Status</button></a>");client.println("<a href=\'/go/wayp\'>" + button_menu_standard + "WPs</button></a></br></br>");
    if (drain_36_state=="off") {
    client.println("<a href=\'/36/on\'>" + button_switch_standard + "Kamera Front</button></a></p>");
    } else {client.println("<a href=\'/36/off\'>" + button2_switch_highlight + "Kamera Front</button></a></p>");}
    if (drain_37_state=="off") {
    client.println("<a href=\'/37/on\'>" + button_switch_standard + "Kamera POD</button></a></p>");
    } else {client.println("<a href=\'/37/off\'>" + button2_switch_highlight + "Kamera POD</button></a></p>");}
    if (drain_38_state=="off") {
    client.println("<a href=\'/38/on\'>" + button_switch_standard + "nicht_belegt</button></a></p>");
    } else {client.println("<a href=\'/38/off\'>" + button2_switch_highlight + "nicht_belegt</button></a></p>");}
//    if (drain_39_state=="off") {
//    client.println("<a href=\'/39/on\'>" + button_switch_standard + "nicht_belegt</button></a></p>");
//    } else {client.println("<a href=\'/39/off\'>" + button2_switch_highlight + "nicht_belegt</button></a></p>");}
//    if (drain_40_state=="off") {
//    client.println("<a href=\'/40/on\'>" + button_switch_standard + "nicht_belegt</button></a></p>");
//    } else {client.println("<a href=\'/40/off\'>" + button2_switch_highlight + "nicht_belegt</button></a></p>");}
//    if (drain_41_state=="off") {
//    client.println("<a href=\'/41/on\'>" + button_switch_standard + "nicht_belegt</button></a></p>");
//    } else {client.println("<a href=\'/41/off\'>" + button2_switch_highlight + "nicht_belegt</button></a></p>");}
//    if (drain_42_state=="off") {
//    client.println("<a href=\'/42/on\'>" + button_switch_standard + "nicht_belegt</button></a></p>");
//    } else {client.println("<a href=\'/42/off\'>" + button2_switch_highlight + "nicht_belegt</button></a></p>");}
//    if (drain_43_state=="off") {
//    client.println("<a href=\'/43/on\'>" + button_switch_standard + "nicht_belegt</button></a></p>");
//    } else {client.println("<a href=\'/43/off\'>" + button2_switch_highlight + "nicht_belegt</button></a></p>");}
//    if (drain_44_state=="off") {
//    client.println("<a href=\'/44/on\'>" + button_switch_standard + "nicht_belegt</button></a></p>");
//    } else {client.println("<a href=\'/44/off\'>" + button2_switch_highlight + "nicht_belegt</button></a></p>");}
//    if (drain_44_state=="off") {
//    client.println("<a href=\'/45/on\'>" + button_switch_standard + "Ausleger</button></a></p>");
//    } else {client.println("<a href=\'/45/off\'>" + button2_switch_highlight + "Ausleger</button></a></p>");}
  }

void create_page_4(WiFiEspClient client){
    page_refresh = 5;
    client.println("<a href=\'/go/navi\'>" + button_menu_standard + "Navi</button></a>");client.println("<a href=\'/go/light\'>" + button_menu_standard + "Licht</button></a>");client.println("<a href=\'/go/drain\'>" + button_menu_standard + "Verbr.</button></a>");client.println("<a href=\'/go/state\'>" + button_menu_highlight + "Status</button></a>");client.println("<a href=\'/go/wayp\'>" + button_menu_standard + "WPs</button></a></br></br>");
  }

void create_page_5(WiFiEspClient client){
    //page_refresh = 20;
    client.println("<a href=\'/go/navi\'>" + button_menu_standard + "Navi</button></a>");client.println("<a href=\'/go/light\'>" + button_menu_standard + "Licht</button></a>");client.println("<a href=\'/go/drain\'>" + button_menu_standard + "Verbr.</button></a>");client.println("<a href=\'/go/state\'>" + button_menu_standard + "Status</button></a>");client.println("<a href=\'/go/wayp\'>" + button_menu_highlight + "WPs</button></a></br></br>");
  }

void header_reply_1(WiFiEspClient client){
  if (header.indexOf("GET /nav/gpson") >= 0) { control_state = "1";}
  else if (header.indexOf("GET /nav/gpsoff") >= 0) { control_state = "2";}
  else if (header.indexOf("GET /nav/manon") >= 0) { control_state = "2";}
  else if (header.indexOf("GET /nav/manoff") >= 0) { control_state = "1";}
  else if (header.indexOf("GET /nav/stefm") >= 0) { steering_state = "1";}
  else if (header.indexOf("GET /nav/stehm") >= 0) { steering_state = "2";}
  else if (header.indexOf("GET /nav/stefh") >= 0) { steering_state = "3";}
  else if (header.indexOf("GET /nav/stesy") >= 0) { steering_state = "4";}
  else if (header.indexOf("GET /nav/trackstart") >= 0) { track_state = "1";}
  else if (header.indexOf("GET /nav/trackstop") >= 0) { track_state = "0";}
  else if (header.indexOf("GET /nav/forward") >= 0) { direction_state = "1";}
  else if (header.indexOf("GET /nav/reverse") >= 0) { direction_state = "2";}
  else if (header.indexOf("GET /nav/acc") >= 0) { if (speed_state <= 100) {speed_state = (speed_state + 5);}}
  else if (header.indexOf("GET /nav/dec") >= 0) { if (speed_state >= 5) {speed_state = (speed_state - 5);}}
  else if (header.indexOf("GET /nav/left") >= 0) { if (angle_state <= 100) {angle_state = (angle_state + 5);}}
  else if (header.indexOf("GET /nav/right") >= 0) { if (speed_state >= -100) {angle_state = (angle_state - 5);}}
  else if (header.indexOf("GET /nav/stop") >= 0) { direction_state = "0"; speed_state = 0; angle_state = 0;} 
}

void header_reply_2(WiFiEspClient client){
  if (header.indexOf("GET /21/on") >= 0) {drain_21_state = "on";digitalWrite(drain_21, HIGH);}
  else if (header.indexOf("GET /21/off") >= 0) { drain_21_state = "off"; digitalWrite(drain_21, LOW);}
  else if (header.indexOf("GET /22/on") >= 0) { drain_22_state = "on"; digitalWrite(drain_22, HIGH);}
  else if (header.indexOf("GET /22/off") >= 0) { drain_22_state = "off"; digitalWrite(drain_22, LOW);}
  else if (header.indexOf("GET /23/on") >= 0) { drain_23_state = "on"; digitalWrite(drain_23, HIGH);}
  else if (header.indexOf("GET /23/off") >= 0) { drain_23_state = "off"; digitalWrite(drain_23, LOW);}
  else if (header.indexOf("GET /24/on") >= 0) { drain_24_state = "on"; digitalWrite(drain_24, HIGH);}
  else if (header.indexOf("GET /24/off") >= 0) { drain_24_state = "off"; digitalWrite(drain_24, LOW);}
  else if (header.indexOf("GET /25/on") >= 0) { drain_25_state = "on"; digitalWrite(drain_25, HIGH);}
  else if (header.indexOf("GET /25/off") >= 0) { drain_25_state = "off"; digitalWrite(drain_25, LOW);}
  else if (header.indexOf("GET /26/on") >= 0) { drain_28_state = "off"; digitalWrite(drain_28, LOW); drain_26_state = "on"; digitalWrite(drain_26, HIGH);}
  else if (header.indexOf("GET /26/off") >= 0) { drain_26_state = "off"; digitalWrite(drain_26, LOW);}
  else if (header.indexOf("GET /27/on") >= 0) { drain_29_state = "off"; digitalWrite(drain_29, LOW); drain_27_state = "on"; digitalWrite(drain_27, HIGH);}
  else if (header.indexOf("GET /27/off") >= 0) { drain_27_state = "off"; digitalWrite(drain_27, LOW);}
  else if (header.indexOf("GET /28/on") >= 0) { drain_26_state = "off"; digitalWrite(drain_26, LOW); drain_28_state = "on"; digitalWrite(drain_28, HIGH);}
  else if (header.indexOf("GET /28/off") >= 0) { drain_28_state = "off"; digitalWrite(drain_28, LOW);}
  else if (header.indexOf("GET /29/on") >= 0) { drain_27_state = "off"; digitalWrite(drain_27, LOW); drain_29_state = "on"; digitalWrite(drain_29, HIGH);}
  else if (header.indexOf("GET /29/off") >= 0) { drain_29_state = "off"; digitalWrite(drain_29, LOW);}
  else if (header.indexOf("GET /30/on") >= 0) { drain_30_state = "on"; digitalWrite(drain_30, HIGH);}
  else if (header.indexOf("GET /30/off") >= 0) { drain_30_state = "off"; digitalWrite(drain_30, LOW);}
}

void header_reply_3(WiFiEspClient client){
  if (header.indexOf("GET /36/on") >= 0) {drain_36_state = "on";digitalWrite(drain_36, HIGH);}
  else if (header.indexOf("GET /36/off") >= 0) { drain_36_state = "off"; digitalWrite(drain_36, LOW);}
  else if (header.indexOf("GET /37/on") >= 0) { drain_37_state = "on"; digitalWrite(drain_37, HIGH);}
  else if (header.indexOf("GET /37/off") >= 0) { drain_37_state = "off"; digitalWrite(drain_37, LOW);}
  else if (header.indexOf("GET /38/on") >= 0) { drain_38_state = "on"; digitalWrite(drain_38, HIGH);}
  else if (header.indexOf("GET /38/off") >= 0) { drain_38_state = "off"; digitalWrite(drain_38, LOW);}
//  else if (header.indexOf("GET /39/on") >= 0) { drain_39_state = "on"; digitalWrite(drain_39, HIGH);}
//  else if (header.indexOf("GET /39/off") >= 0) { drain_39_state = "off"; digitalWrite(drain_39, LOW);}
//  else if (header.indexOf("GET /40/on") >= 0) { drain_40_state = "on"; digitalWrite(drain_40, HIGH);}
//  else if (header.indexOf("GET /40/off") >= 0) { drain_40_state = "off"; digitalWrite(drain_40, LOW);}
//  else if (header.indexOf("GET /41/on") >= 0) { drain_41_state = "off"; digitalWrite(drain_41, HIGH);}
//  else if (header.indexOf("GET /41/off") >= 0) { drain_41_state = "off"; digitalWrite(drain_41, LOW);}
//  else if (header.indexOf("GET /42/on") >= 0) { drain_42_state = "off"; digitalWrite(drain_42, HIGH);}
//  else if (header.indexOf("GET /42/off") >= 0) { drain_42_state = "off"; digitalWrite(drain_42, LOW);}
//  else if (header.indexOf("GET /43/on") >= 0) { drain_43_state = "off"; digitalWrite(drain_43, HIGH);}
//  else if (header.indexOf("GET /43/off") >= 0) { drain_43_state = "off"; digitalWrite(drain_43, LOW);}
//  else if (header.indexOf("GET /44/on") >= 0) { drain_44_state = "off"; digitalWrite(drain_44, HIGH);}
//  else if (header.indexOf("GET /44/off") >= 0) { drain_44_state = "off"; digitalWrite(drain_44, LOW);}
//  else if (header.indexOf("GET /45/on") >= 0) { drain_45_state = "on"; digitalWrite(drain_45, HIGH);}
//  else if (header.indexOf("GET /45/off") >= 0) { drain_45_state = "off"; digitalWrite(drain_45, LOW);}
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.