Avatar von Lukas Turcza
  • Lukas Turcza

1 Beitrag seit 18.01.2021

ESP8285

Guten Tag,
ich verwende:

https://wiki.seeedstudio.com/Seeeduino_v4.2/
https://wiki.seeedstudio.com/Grove-UART_Wifi_V2/
https://www.amazon.de/Arduino-PC-Seeed-Studio-Base-Schild-V1-3/dp/B00MFFFKXA

Das WiFi Modul habe an Port D2 angeschlossen. Ich versuche über WiFi Modul mit meine Router sich zu verbinden. Ich benutze Code:

[#include "WiFiEsp.h"

#include <SoftwareSerial.h>

//#ifndef HAVE_HWSERIAL1

SoftwareSerial wifiSerial(2, 3); // RX, TX for ESP8266

bool DEBUG = true; //show more logs
int responseTime = 100; //communication timeout

WiFiEspServer server(80);
int reqCount = 0; // number of requests received

void setup()

{
pinMode(13,OUTPUT); //set build in led as output
// Open serial communications and wait for port to open esp8266:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
wifiSerial.begin(9600);
while (!wifiSerial) {
; // wait for serial port to connect. Needed for Leonardo only
}

sendToWifi("AT+CWMODE=1",responseTime,DEBUG); // configure as access point
sendToWifi("AT+CWJAP=\"WLAN-L6A2NY\",\"9535818077078473\"",responseTime,DEBUG);
//sendToWifi("AT+CWJAP=\"UPC2A2EA83\",\"TSfrbv5jkpuf\"",responseTime,DEBUG);
sendToWifi("AT+CWJAP?",responseTime,DEBUG);
//sendToWifi("AT+CIFSR",responseTime,DEBUG); // get ip address
//sendToWifi("AT+CIPMUX=1",responseTime,DEBUG); // configure for multiple connections
//sendToWifi("AT+CIPSERVER=1,80",responseTime,DEBUG); // turn on server on port 80

sendToUno("Wifi connection is running!",responseTime,DEBUG);

delay(2000);
//Serial.println("server is at ");
//Serial.println(wifiSerial.localIP());
// start the web server on port 80
server.begin();

delay(1000);

}

void loop()
{]

[/code]


Ich komme nicht in Loop-Schleife, jede Sekunde Zeigt nur "Wifi connection is running!". Wieso? Hat sich aber verbunden.

Wenn ich zweiter Code:

[/*
WiFiEsp example: WebServer

A simple web server that shows the value of the analog input
pins via a web page using an ESP8266 module.
This sketch will print the IP address of your ESP8266 module (once connected)
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
*/

#include "WiFiEsp.h"

#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(2, 3); // RX, TX
#endif

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

WiFiEspServer server(80);

void setup()
{
// initialize serial for debugging
Serial.begin(115200);
// initialize serial for ESP module
Serial1.begin(9600);
// initialize ESP module
WiFi.init(&Serial1);

// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue
while (true);
}

// attempt to connect to WiFi network
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network
status = WiFi.begin(ssid, pass);
}

Serial.println("You're connected to the network");
printWifiStatus();

// start the web server on port 80
server.begin();
}

void loop()
{
// listen for incoming clients
WiFiEspClient client = server.available();
if (client) {
Serial.println("New client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// 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) {
Serial.println("Sending response");

// send a standard http response header
// use \r\n instead of many println statements to speedup data send
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
"Refresh: 20\r\n" // refresh the page automatically every 20 sec
"\r\n");
client.print("<!DOCTYPE HTML>\r\n");
client.print("<html>\r\n");
client.print("<h1>Hello World!</h1>\r\n");
client.print("Requests received: ");
client.print(++reqCount);
client.print("<br>\r\n");
client.print("Analog input A0: ");
client.print(analogRead(0));
client.print("<br>\r\n");
client.print("</html>\r\n");
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(10);

// close the connection:
client.stop();
Serial.println("Client disconnected");
}
}

void printWifiStatus()
{
// print the SSID of the network you're attached to
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// 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, open a browser to http://");
Serial.println(ip);
Serial.println();
}
]

verwende dann bekomme ich das:

[10:04:36.338 -> [Wlizing ESP module
10:04:36.338 -> [WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Initializing ESP module
10:05:09.840 -> [WiFiEsp] >>> TIMEOUT >>>
10:05:11.822 -> [WiFiEsp] >>> TIMEOUT >>>
10:05:13.845 -> [WiFiEsp] >>> TIMEOUT >>>
10:05:15.824 -> [WiFiEsp] >>> TIMEOUT >>>
10:05:17.849 -> [WiFiEsp] >>> TIMEOUT >>>
10:05:18.834 -> [WiFiEsp] Cannot initialize ESP module
10:05:24.842 -> [WiFiEsp] >>> TIMEOUT >>>
10:05:24.842 -> [WiFiEsp] No tag found
10:05:24.889 -> WiFi shield not present]

Wie komme ich weiter? Was mache ich falsch?

Das Posting wurde vom Benutzer editiert (18.01.2021 11:23).

Bewerten
- +