ESP8266 verbinden sich nicht/ senden von UDP

Hallo an alle,

ich würde gerne zum senden von Daten über UDP zwei ESP8266 miteinander verbinden.
Einer soll als Acess Point arbeiten und der zweite als Client (später dann mehrere Clients).

Mein erstes Problem ist, dass der Client ewig benötigt um sich am Acess Point anzumelden.
Und er bekommt irgendeine komische IP zugewiesen.
Sollten die IP vom Client nicht ähnlich zur Acess Point IPsein, soweit ich das weiß?
(Bin erst Anfänger)

Acess Point Seriell Monitor ausgabe:

Connected
LocalIP:169.254.103.164
MAC:C4:5B:BE:55:A4:66
Gateway:(IP unset)
AP MAC:C6:5B:BE:54:DB:95
Initializing I2C devices...
Testing device connections...
MPU6050 connection failed
Initializing DMP...
Checking hardware revision...
Revision @ user[16][6] = 0
Resetting memory bank selection to 0...
DMP Initialization failed (code 1)

Client Seriell Monitor ausgabe:

Verbindung wurde erfolgreich aufgebaut!192.168.4.1Starting UDP
Local port: 8888

Vlt wäre jemand so nett, mir damit zu helfen.

Danke

Code vom Acess point (von Jeff Rowberg umgebaut um auch Credits zu geben :grin:) :


// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"

#include "MPU6050_6Axis_MotionApps20.h"
//#include "MPU6050.h" // not necessary if using MotionApps include file

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include "Wire.h"
#endif
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

WiFiUDP Udp;
const IPAddress outIp(192,168,4,1);        // remote IP (not needed for receive)
const unsigned int outPort = 9999;          // remote port (not needed for receive)
const unsigned int localPort = 8888;        // local port to listen for UDP packets (here's where we send the packets)
WiFiClient client;

char ssid[] = "AcessPoint1";           // SSID of your AP
char pass[] = "Wasserrate";         // password of your AP
// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 mpu;
//MPU6050 mpu(0x69); // <-- use for AD0 high
/*===================================================================== */

// uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual
// quaternion components in a [w, x, y, z] format (not best for parsing
// on a remote host such as Processing or something though)
#define OUTPUT_READABLE_QUATERNION

// uncomment "OUTPUT_READABLE_EULER" if you want to see Euler angles
// (in degrees) calculated from the quaternions coming from the FIFO.
// Note that Euler angles suffer from gimbal lock (for more info, see
// http://en.wikipedia.org/wiki/Gimbal_lock)
//#define OUTPUT_READABLE_EULER

// uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/
// pitch/roll angles (in degrees) calculated from the quaternions coming
// from the FIFO. Note this also requires gravity vector calculations.
// Also note that yaw/pitch/roll angles suffer from gimbal lock (for
// more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)
//#define OUTPUT_READABLE_YAWPITCHROLL

// uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration
// components with gravity removed. This acceleration reference frame is
// not compensated for orientation, so +X is always +X according to the
// sensor, just without the effects of gravity. If you want acceleration
// compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead.
//#define OUTPUT_READABLE_REALACCEL

// uncomment "OUTPUT_READABLE_WORLDACCEL" if you want to see acceleration
// components with gravity removed and adjusted for the world frame of
// reference (yaw is relative to initial orientation, since no magnetometer
// is present in this case). Could be quite handy in some cases.
//#define OUTPUT_READABLE_WORLDACCEL

// uncomment "OUTPUT_TEAPOT" if you want output that matches the
// format used for the InvenSense teapot demo
//#define OUTPUT_TEAPOT



#define INTERRUPT_PIN 2  // use pin 2 on Arduino Uno & most boards
#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
bool blinkState = false;

// MPU control/status vars
bool dmpReady = false;  // set true if DMP init was successful
uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;     // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars
Quaternion q;           // [w, x, y, z]         quaternion container
VectorInt16 aa;         // [x, y, z]            accel sensor measurements
VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
VectorFloat gravity;    // [x, y, z]            gravity vector
float euler[3];         // [psi, theta, phi]    Euler angle container
float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector

// packet structure for InvenSense teapot demo
uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' };



// ================================================================
// ===               INTERRUPT DETECTION ROUTINE                ===
// ================================================================

volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high
void dmpDataReady() {
    mpuInterrupt = true;
}



// ================================================================
// ===                      INITIAL SETUP                       ===
// ================================================================

void setup() {

 Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);           // connects to the WiFi AP
  Serial.println();
  Serial.println("Connection to the AP");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.println("Connected");
  Serial.print("LocalIP:"); Serial.println(WiFi.localIP());
  Serial.println("MAC:" + WiFi.macAddress());
  Serial.print("Gateway:"); Serial.println(WiFi.gatewayIP());
  Serial.print("AP MAC:"); Serial.println(WiFi.BSSIDstr());


  
    // join I2C bus (I2Cdev library doesn't do this automatically)
    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
        Wire.begin();
        Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties
    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
        Fastwire::setup(400, true);
    #endif

    // initialize serial communication
    // (115200 chosen because it is required for Teapot Demo output, but it's
    // really up to you depending on your project)
    //Serial.begin(115200);
    while (!Serial); // wait for Leonardo enumeration, others continue immediately

    // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3V or Arduino
    // Pro Mini running at 3.3V, cannot handle this baud rate reliably due to
    // the baud timing being too misaligned with processor ticks. You must use
    // 38400 or slower in these cases, or use some kind of external separate
    // crystal solution for the UART timer.

    // initialize device
    Serial.println(F("Initializing I2C devices..."));
    mpu.initialize();
    pinMode(INTERRUPT_PIN, INPUT);

    // verify connection
    Serial.println(F("Testing device connections..."));
    Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));

    // wait for ready
    //Serial.println(F("\nSend any character to begin DMP programming and demo: "));
    //while (Serial.available() && Serial.read()); // empty buffer
    //while (!Serial.available());                 // wait for data
    //while (Serial.available() && Serial.read()); // empty buffer again

    // load and configure the DMP
    Serial.println(F("Initializing DMP..."));
    devStatus = mpu.dmpInitialize();

    // supply your own gyro offsets here, scaled for min sensitivity
    mpu.setXGyroOffset(220);
    mpu.setYGyroOffset(76);
    mpu.setZGyroOffset(-85);
    mpu.setZAccelOffset(1788); // 1688 factory default for my test chip

    // make sure it worked (returns 0 if so)
    if (devStatus == 0) {
        // Calibration Time: generate offsets and calibrate our MPU6050
        mpu.CalibrateAccel(6);
        mpu.CalibrateGyro(6);
        mpu.PrintActiveOffsets();
        // turn on the DMP, now that it's ready
        Serial.println(F("Enabling DMP..."));
        mpu.setDMPEnabled(true);

        // enable Arduino interrupt detection
        Serial.print(F("Enabling interrupt detection (Arduino external interrupt "));
        Serial.print(digitalPinToInterrupt(INTERRUPT_PIN));
        Serial.println(F(")..."));
        attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), dmpDataReady, RISING);
        mpuIntStatus = mpu.getIntStatus();

        // set our DMP Ready flag so the main loop() function knows it's okay to use it
        Serial.println(F("DMP ready! Waiting for first interrupt..."));
        dmpReady = true;

        // get expected DMP packet size for later comparison
        packetSize = mpu.dmpGetFIFOPacketSize();
    } else {
        // ERROR!
        // 1 = initial memory load failed
        // 2 = DMP configuration updates failed
        // (if it's going to break, usually the code will be 1)
        Serial.print(F("DMP Initialization failed (code "));
        Serial.print(devStatus);
        Serial.println(F(")"));
    }

    // configure LED for output
    pinMode(LED_PIN, OUTPUT);

     Serial.println("Starting UDP");
     Udp.begin(localPort);
     Serial.printf("Now listening at IP %s, UDP port %d\n", WiFi.localIP().toString().c_str(), localPort);
}



// ================================================================
// ===                    MAIN PROGRAM LOOP                     ===
// ================================================================

void loop() {
    // if programming failed, don't try to do anything
    if (!dmpReady) return;
    // read a packet from FIFO
    if (mpu.dmpGetCurrentFIFOPacket(fifoBuffer)) { // Get the Latest packet 
        #ifdef OUTPUT_READABLE_QUATERNION
            // display quaternion values in easy matrix form: w x y z
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            Serial.print("quat\t");
            Serial.print(q.w);
            Serial.print("\t");
            Serial.print(q.x);
            Serial.print("\t");
            Serial.print(q.y);
            Serial.print("\t");
            Serial.println(q.z);
        #endif

        #ifdef OUTPUT_READABLE_EULER
            // display Euler angles in degrees
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetEuler(euler, &q);
            Serial.print("euler\t");
            Serial.print(euler[0] * 180/M_PI);
            Serial.print("\t");
            Serial.print(euler[1] * 180/M_PI);
            Serial.print("\t");
            Serial.println(euler[2] * 180/M_PI);
        #endif

        #ifdef OUTPUT_READABLE_YAWPITCHROLL
            // display Euler angles in degrees
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
            Serial.print("ypr\t");
            Serial.print(ypr[0] * 180/M_PI);
            Serial.print("\t");
            Serial.print(ypr[1] * 180/M_PI);
            Serial.print("\t");
            Serial.println(ypr[2] * 180/M_PI);
        #endif

        #ifdef OUTPUT_READABLE_REALACCEL
            // display real acceleration, adjusted to remove gravity
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetAccel(&aa, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
            Serial.print("areal\t");
            Serial.print(aaReal.x);
            Serial.print("\t");
            Serial.print(aaReal.y);
            Serial.print("\t");
            Serial.println(aaReal.z);
        #endif

        #ifdef OUTPUT_READABLE_WORLDACCEL
            // display initial world-frame acceleration, adjusted to remove gravity
            // and rotated based on known orientation from quaternion
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetAccel(&aa, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
            mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q);
            Serial.print("aworld\t");
            Serial.print(aaWorld.x);
            Serial.print("\t");
            Serial.print(aaWorld.y);
            Serial.print("\t");
            Serial.println(aaWorld.z);
        #endif
    
        #ifdef OUTPUT_TEAPOT
            // display quaternion values in InvenSense Teapot demo format:
            teapotPacket[2] = fifoBuffer[0];
            teapotPacket[3] = fifoBuffer[1];
            teapotPacket[4] = fifoBuffer[4];
            teapotPacket[5] = fifoBuffer[5];
            teapotPacket[6] = fifoBuffer[8];
            teapotPacket[7] = fifoBuffer[9];
            teapotPacket[8] = fifoBuffer[12];
            teapotPacket[9] = fifoBuffer[13];
            Serial.write(teapotPacket, 14);
            teapotPacket[11]++; // packetCount, loops at 0xFF on purpose
        #endif

        // blink LED to indicate activity
        blinkState = !blinkState;
        digitalWrite(LED_PIN, blinkState);

    }

  int packetSize = Udp.parsePacket();
  if (packetSize)
  {
        // send back a reply, to the IP address and port we got the packet from
    char  replyPacket[] = "Hi there! Got the message :-)";  // a reply string to send back
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(replyPacket);
    Udp.endPacket();
  }
}

Code vom Client (irgendwo aus dem Internet oder aus einem Bsp und dann umgebaut):

#include <ESP8266WiFi.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <WiFiUdp.h>
#include <OSCMessage.h>
#include <OSCBundle.h>
#include <OSCData.h>

WiFiUDP Udp;
const IPAddress outIp(192,168,4,1);        // remote IP (not needed for receive)
const unsigned int outPort = 9999;          // remote port (not needed for receive)
const unsigned int localPort = 8888;        // local port to listen for UDP packets (here's where we send the packets)
char incomingPacket[255];  // buffer for incoming packets

OSCErrorCode error;

void setup(){
  Serial.begin(115200);
  Serial.println();
  Serial.print("Konfiguriere soft-AP ... ");
  boolean result = WiFi.softAP("AcessPoint1", "Wasserrate");
  
  Serial.print("Verbindung wurde ");
  if(result == false){
    Serial.println("NICHT ");
  }
  Serial.print("erfolgreich aufgebaut!");
  Serial.print(WiFi.softAPIP());

  Serial.println("Starting UDP");
  Udp.begin(localPort);
  Serial.print("Local port: ");
#ifdef ESP32
  Serial.println(localPort);
#else
  Serial.println(Udp.localPort());
#endif

}
void loop(){
  Serial.printf("Anzahl der Verbundenen Geräte= %d\n", WiFi.softAPgetStationNum());
  delay(3000);

    int packetSize = Udp.parsePacket();
  if (packetSize)
  {
    // receive incoming UDP packets
    Serial.printf("Received %d bytes from %s, port %d\n", packetSize, Udp.remoteIP().toString().c_str(), Udp.remotePort());
    int len = Udp.read(incomingPacket, 255);
    if (len > 0)
    {
      incomingPacket[len] = 0;
    }
    Serial.printf("UDP packet contents: %s\n", incomingPacket);
  }
}

Falls euch Fehler beim senden vom UDP oder andere im Code auffalen sollten, ich wäre über jeden Tip dankbar.

Und wenn Ihr Tipps hab wie ich das ganze dann schaffe um Daten von mehreren ESP8266 zum Acess Point senden, wäre ich auch sehr verbunden.
oder kann ich einfach den Code vom Client auf mehrere ESP8266 spielen und es funktioniert von alleine oder irgendwie zu timen oder andere Sachen am Code zu verändern?

Ich weiß ich habe viele Fragen, leider bin ich Anfänger und kann nur so iwie lernen und weiterkommen.

Also schon mal danke im Vorraus, schönen Abend/Tag...

mfg

Niemand eine Idee wo ich starten könnte um den fehler zu beheben?? Wäre wirklich für jede Hilfe dankbar!!!!!

Ein guter Startpunkt sind die Beispiele der IDE (z.B. zum Accesspoint und zu UDP).
Mit denen erst mal die Grundfunktionen testen.
Ansonsten ist die Seite von Fips immer einen Besuch wert.

Gruß Tommy

Hallo, danke für deine Antwort.
Also ich habe mit den Grundbeispielen begonnen, leider funktionieren die auch nicht.
Also ich bekomme keine Verbindung zwischen dem Acess point und dem Client.

hast du einen Tipp für mich, wäre wirklich nett.

mfg

Und für alle, ja ich weis ich habe im englischen Forum auch den Post gemacht, aber da mir hier niemand geantwortet hat und ich hoffte das dort vlt jemand zeit hätte sich dem thema anzunehmen.
Hatte da auch die Antwort von Tommy66 noch nicht.

Seht mir da bitte nach.
Es ist am Anfang nicht einfach da reinzukommen.

lg

Da ich nicht auf Deinen Tisch sehen kann, ist das kaum möglich.
Wenn z.B. das einfache Beispiel zum AP nicht läuft, dann könnten die Ausgaben auf dem seriellen Monitor helfen. Ansonsten würde ich wohl annehmen, dass das Ding defekt ist.
Wie versorgst Du es?

Gruß Tommy

Ich versuch den code und alles schnell auf die ESP zu spielen und poste es dann hier, damit du dich besser auskennst.
Bitte etwas gedult, danke

versorgnung ist über usb port vom pc

lg

Hallo
Versuche doch erst mal das Beispiel zum AP und schau dann nach ob du das WiFi Netz des ESP z.b mit dem PC oder dem Handy findest und dich damit verbinden kannst.

Mir ist auch dein Aufbau noch nicht klar, du hast mehrere Messstellen die irgend etwas messen und willst die Messwerte dann zu einem Server senden . Das kann mit UDP Konflikte geben wenn was gleichzeitig gesendet wird.

Oder soll der " Server " nacheinander die Messstellen abfragen , dann sollten eigendlich erst mal die Messstellen als Server betrieben werden .

Du kannst die IP des Clients abfragen oder in den gesendeten Daten eine Nummer für die Messstelle mit senden um die Daten zuordnen zu können

Also meine ESP8266 sind über USB mit dem PC verbunden.
Auf dem acess Point läuft jetzt der Code aus dem ESP8266Wifi Bsp:

/*
   Copyright (c) 2015, Majenko Technologies
   All rights reserved.

   Redistribution and use in source and binary forms, with or without modification,
   are permitted provided that the following conditions are met:

 * * Redistributions of source code must retain the above copyright notice, this
     list of conditions and the following disclaimer.

 * * Redistributions in binary form must reproduce the above copyright notice, this
     list of conditions and the following disclaimer in the documentation and/or
     other materials provided with the distribution.

 * * Neither the name of Majenko Technologies nor the names of its
     contributors may be used to endorse or promote products derived from
     this software without specific prior written permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/* Create a WiFi access point and provide a web server on it. */

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

#ifndef APSSID
#define APSSID "ESPap"
#define APPSK  "thereisnospoon"
#endif

/* Set these to your desired credentials. */
const char *ssid = APSSID;
const char *password = APPSK;

ESP8266WebServer server(80);

/* Just a little test message.  Go to http://192.168.4.1 in a web browser
   connected to this access point to see it.
*/
void handleRoot() {
  server.send(200, "text/html", "<h1>You are connected</h1>");
}

void setup() {
  delay(1000);
  Serial.begin(115200);
  Serial.println();
  Serial.print("Configuring access point...");
  /* You can remove the password parameter if you want the AP to be open. */
  WiFi.softAP(ssid, password);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.on("/", handleRoot);
  server.begin();
  Serial.println("HTTP server started");
}

void loop() {
  server.handleClient();
}

Und auf dem Client dieser code aus dem ESP8266 Bsp:

/*
    This sketch establishes a TCP connection to a "quote of the day" service.
    It sends a "hello" message, and then prints received data.
*/

#include <ESP8266WiFi.h>

#ifndef STASSID
#define STASSID "ESPap"
#define STAPSK  "thereisnospoon"
#endif

const char* ssid     = STASSID;
const char* password = STAPSK;

const char* host = "djxmmx.net";
const uint16_t port = 17;

void setup() {
  Serial.begin(115200);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  /* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default,
     would try to act as both a client and an access-point and could cause
     network-issues with your other WiFi-devices on your WiFi-network. */
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  static bool wait = false;

  Serial.print("connecting to ");
  Serial.print(host);
  Serial.print(':');
  Serial.println(port);

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  if (!client.connect(host, port)) {
    Serial.println("connection failed");
    delay(5000);
    return;
  }

  // This will send a string to the server
  Serial.println("sending data to server");
  if (client.connected()) {
    client.println("hello from ESP8266");
  }

  // wait for data to be available
  unsigned long timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout > 5000) {
      Serial.println(">>> Client Timeout !");
      client.stop();
      delay(60000);
      return;
    }
  }

  // Read all the lines of the reply from server and print them to Serial
  Serial.println("receiving from remote server");
  // not testing 'client.connected()' since we do not need to send data here
  while (client.available()) {
    char ch = static_cast<char>(client.read());
    Serial.print(ch);
  }

  // Close the connection
  Serial.println();
  Serial.println("closing connection");
  client.stop();

  if (wait) {
    delay(300000); // execute once every 5 minutes, don't flood remote service
  }
  wait = true;
}

Der Seriell Monitor vom Server gibt das aus:

Configuring access point...AP IP address: 192.168.4.1
HTTP server started

der Seriell Monitor vom Client gibt das aus:

Connecting to ESPap
.............................
WiFi connected
IP address:
169.254.103.164
connecting to djxmmx.net:17
connection failed

und die Punkte beim Client laufen zuerst ewig lange
und dann bekomm ich eben diese seltsame IP die mit dem Acess Point nicht zusammen passt, auser ich versthe da was falsch, dann bitte ich um eine Erklärung wenn jemand so nett wäre.

Brauchst du noch Infos.
Keine Ahnung ob man mit den Infos was anfangen kann, wenn nicht dann sag einfach was du noch bräuchtest.

Danke mal soweit

lg

Hallo, als erstes danke für die antwort!

Also mein Plan ist es eigendlich Daten von mehreren Messstellen gleichzeitig an einen Acess Point zu senden.
Leider bin ich anfänger und habe nicht gewusst wie ich es besser machen soll als mit UDP.

Hättest du einen besseren Vorschlag um das umzusetzten?

Mein PC findet den Acess Point und der Ping ergibt das:

Ping wird ausgeführt für 192.168.4.1 mit 32 Bytes Daten:
Antwort von 192.168.4.1: Bytes=32 Zeit=1ms TTL=255
Antwort von 192.168.4.1: Bytes=32 Zeit=2ms TTL=255
Antwort von 192.168.4.1: Bytes=32 Zeit=4ms TTL=255
Antwort von 192.168.4.1: Bytes=32 Zeit=1ms TTL=255
Ping-Statistik für 192.168.4.1:
Pakete: Gesendet = 4, Empfangen = 4, Verloren = 0
(0% Verlust),
Ca. Zeitangaben in Millisek.:
Minimum = 1ms, Maximum = 4ms, Mittelwert = 2ms

Nur mein Client verbindet sich nicht mit dem Acess Point (siehe andere Antwort für Code und Seriell monitor augabe)

lg

Die 169.* ist doch falsch.
Der Client hat keine zugewiesene IP-Adresse sondern macht ein link-local.

Wenn der AP 192.168.4.1 hat, gib mal der Client im setup:

  IPAddress ip(192, 168, 4, 5);
  IPAddress dns(192, 168, 4, 1);
  IPAddress gateway(192, 168, 4, 1);
  IPAddress subnet(255, 255, 255, 0);
  WiFi.config(ip, dns, gateway, subnet);

Vollständig:

void setup() {
  Serial.begin(115200);

  // We start by connecting to a WiFi network
  IPAddress ip(192, 168, 4, 5);
  IPAddress dns(192, 168, 4, 1);
  IPAddress gateway(192, 168, 4, 1);
  IPAddress subnet(255, 255, 255, 0);
  WiFi.config(ip, dns, gateway, subnet);
  
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  /* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default,
     would try to act as both a client and an access-point and could cause
     network-issues with your other WiFi-devices on your WiFi-network. */
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

Variable host "192.168.4.1"
Als Port nicht 17.
Der Server läuft auf 80.

const char* host = "192.168.4.1";
const uint16_t port = 80;

Dann sollte nach dem Connect irgendwas kommen.

Wie soll der client ein http://djxmmx.net finden?
Der soll doch wohl den Server auf 192.168.4.1 finden. Wenn er sich nicht in dessen Netz einbuchen kann, wird das nichts.

Mehr kann ich von hier nicht sehen, sorry. Bei meinen ersten Versuchen mit den ESP8266 hat das damals problemlos funktioniert. Das Beispiel ist aber leider in dem derzeit nicht aktivem Forum.

Gruß Tommy

Hallo
Wo die 169... IP her kommt ist mir auch nicht ganz klar .

Hast du denn kein WiFi Heimnetz um erst Mal zu testen ob sich das Ding damit verbindet. Du kannst doch erst Mal alles im Heimnetz betreiben und dann wenn alles läuft auf AP umstellen.
deine beiden Beispiele passen auch nicht so Recht zusammen . Der Server läuft als Webserver und gibt eine HTML Seiten aus . Dein Client will TCP .

Es gibt da ein PC Programm Paketsender , damit kannst du die ESP dann einzeln testen mir hilft das bei sowas immer .

Die Bsp hab ich einfach aus dern BSp von der Libary so hergenommen weil ihr meintet ich soll mal grundsätzlich die connection testen.

Ok ich werd da nochmal nachschaun.

Trotzdem nochmals die Frage, vlt wärst du so nett, wie würdest du dann von mehren Clients daten an einen AcessPoint senden?

Hättest du einen Tipp?
Wär dir sehr dankbar.

Ja, dann musst Du das aber auch auf Dich zuschneiden.
Wie es gehen kann habe ich oben beschrieben.

danke für deine tolle beschreibung, ich bin gerade dabei das zu versuchen.

Vlt hättest du noch einen Tipp:
Ich würde ja gerne von mehreren Clients daten an einen Acess point übertragen, wie mache ich das dann am besten?
Per UDP oder TCp oder noch anders?
Hab damit keine Erfahrung und bin für jeden Tip und Hilfe dankbar.

lg

Mach erstmal eins fertig.

Und dann denke ich drüber nach.
Das klingt für mich sehr nach dem:

also Verbindung steht jetzt, danke für die Hilfe.

Ja den post kenn ich :rofl:, hab das auch kopiert was dort versucht worden ist.
Hab aber auch 100 andere bsp versucht und mega viel nachgelesen.
Denk bevor man in ein forum nachfragen geht, googlet man und probert alles was man findet.

So durfte jetzt 19h keine Antwort schreiben da es zuvor zuviel auf einmal war für einen Anfänger.
Find ich aber doof, denn dann war man gerade im gespräch und es lief und dann wird man für 19h blockiert.
Aber ok, wird schon einen Sinn haben.

Danke nochmal Verbindung steht.

Hab jetzt aber irgend ein größeres Problem

Danke an alle für die Mühe