5.4.17

ESP8266 programmieren





Von: https://de.aliexpress.com/store/product/USB-to-ESP8266-Serial-Wireless-Wifi-Module-Developent-Board-8266-Wifi-Module/612195_32729552106.html




ESP8266 programmieren
3.3 V => 3.3V + CH_PD
GND => GND+GPIO0 (neben RX)
RX=> TX
TX=> RX
Zum Ausführen GPIO wieder von GND nehmen.


Von hier 


Interne LED: GPIO16
An:
digitalWrite(2, LOW);




Unter Datei - Voreinstellungen - Boardverwalter URL:
http://arduino.esp8266.com/stable/package_esp8266com_index.json

Werkzeuge - Board - Boardverwalter

 NodeMCU 1.0

Oder mit Wemos D1 mini.

Sketch:
/*
 *  This sketch sends a message to a TCP server
 *
 */

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti WiFiMulti;

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

    // We start by connecting to a WiFi network
    WiFiMulti.addAP("SSID", "password");

    Serial.println();
    Serial.println();
    Serial.print("Wait for WiFi... ");

    while(WiFiMulti.run() != WL_CONNECTED) {
        Serial.print(".");
        delay(500);
    }

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

    delay(500);
}


void loop() {
    const uint16_t port = 80;
    const char * host = "192.168.178.4"; // ip or dns

   
   
    Serial.print("connecting to ");
    Serial.println(host);

    // Use WiFiClient class to create TCP connections
    WiFiClient client;

    if (!client.connect(host, port)) {
        Serial.println("connection failed");
        Serial.println("wait 5 sec...");
        delay(5000);
        return;
    }

    // This will send the request to the server
    client.print("Send this data to server");

    //read back one line from server
    String line = client.readStringUntil('\r');
    client.println(line);

    Serial.println("closing connection");
    client.stop();
   
    Serial.println("wait 5 sec...");
    delay(5000);
}


Keine Kommentare:

Kommentar veröffentlichen

Openhab und Ecoflow Max - API Anbindung

 Ich wollte die neu erworbene Powerstation in Openhab einbinden, um den aktuellen Status (Ladestand etc.) über Openhab auswerten zu können. ...