Hallo in die Runde,
seit kurzem habe ich Probleme mit einer Konfiguration, die bis dato immer ohne Probleme lief. Ich verwende ein ESP32-board an der Arduino IDE 1.8.4 unter MAC OS 10.10.5 (Yosemite).
Hier der letzte Sketch aus den Beispielen
/*
ESP32 mDNS responder sample
This is an example of an HTTP server that is accessible
via http://esp32.local URL thanks to mDNS responder.
Instructions:
- Update WiFi SSID and password as necessary.
- Flash the sketch to the ESP32 board
- Install host software:
- For Linux, install Avahi (http://avahi.org/).
- For Windows, install Bonjour (http://www.apple.com/support/bonjour/).
- For Mac OSX and iOS support is built in through Bonjour already.
- Point your browser to http://esp32.local, you should see a response.
*/
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiClient.h>
const char* ssid = "***";
const char* password = "***";
// TCP server at port 80 will respond to HTTP requests
WiFiServer server(80);
void setup(void)
{
Serial.begin(115200);
// Connect to WiFi network
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
// Set up mDNS responder:
// - first argument is the domain name, in this example
// the fully-qualified domain name is "esp8266.local"
// - second argument is the IP address to advertise
// we send our IP address on the WiFi network
if (!MDNS.begin("esp32")) {
Serial.println("Error setting up MDNS responder!");
while(1) {
delay(1000);
}
}
Serial.println("mDNS responder started");
// Start TCP (HTTP) server
server.begin();
Serial.println("TCP server started");
// Add service to MDNS-SD
MDNS.addService("http", "tcp", 80);
}
void loop(void)
{
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
Serial.println("");
Serial.println("New client");
// Wait for data from client to become available
while(client.connected() && !client.available()){
delay(1);
}
// Read the first line of HTTP request
String req = client.readStringUntil('\r');
// First line of HTTP request looks like "GET /path HTTP/1.1"
// Retrieve the "/path" part by finding the spaces
int addr_start = req.indexOf(' ');
int addr_end = req.indexOf(' ', addr_start + 1);
if (addr_start == -1 || addr_end == -1) {
Serial.print("Invalid request: ");
Serial.println(req);
return;
}
req = req.substring(addr_start + 1, addr_end);
Serial.print("Request: ");
Serial.println(req);
client.flush();
String s;
if (req == "/")
{
IPAddress ip = WiFi.localIP();
String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ESP32 at ";
s += ipStr;
s += "</html>\r\n\r\n";
Serial.println("Sending 200");
}
else
{
s = "HTTP/1.1 404 Not Found\r\n\r\n";
Serial.println("Sending 404");
}
client.print(s);
Serial.println("Done with client");
}
Nach dem Start der Arduino-IDE scheint der Upload einmal zu funktionieren, obwohl sich dann die Seite http://esp32.local nicht auflösen lässt.
Alle weiteren Versuche scheitern so:
Arduino: 1.8.4 (Mac OS X), Board: "DOIT ESP32 DEVKIT V1, 80MHz, 921600, None"
Archiving built core (caching) in: /var/folders/71/5csrzsms2ql656c5g1brxsyc0000gn/T/arduino_cache_652882/core/core_espressif_esp32_esp32doit-devkit-v1_FlashFreq_80,UploadSpeed_921600,DebugLevel_none_81022c23036f627a596faae2df69ec69.a
Der Sketch verwendet 491899 Bytes (37%) des Programmspeicherplatzes. Das Maximum sind 1310720 Bytes.
Globale Variablen verwenden 40368 Bytes (13%) des dynamischen Speichers, 254544 Bytes für lokale Variablen verbleiben. Das Maximum sind 294912 Bytes.
esptool.py v2.1
Traceback (most recent call last):
File "esptool.py", line 2524, in <module>
File "esptool.py", line 2517, in _main
File "esptool.py", line 2246, in main
File "esptool.py", line 177, in __init__
File "serial/__init__.py", line 88, in serial_for_url
File "serial/serialposix.py", line 268, in open
serial.serialutil.SerialException:[b] [Errno 16] could not open port /dev/cu.SLAB_USBtoUART: [Errno 16] Resource busy: '/dev/cu.SLAB_USBtoUART'
Failed to execute script esptool
Beim Hochladen des Sketches ist ein Fehler aufgetreten
processing.app.SerialException: Fehler beim Öffnen des seriellen Ports "/dev/cu.SLAB_USBtoUART".
at processing.app.Serial.<init>(Serial.java:147)
at processing.app.Serial.<init>(Serial.java:82)
at processing.app.SerialMonitor$4.<init>(SerialMonitor.java:101)
at processing.app.SerialMonitor.open(SerialMonitor.java:101)
at processing.app.AbstractMonitor.resume(AbstractMonitor.java:104)
at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2218)
at processing.app.Editor.access$2200(Editor.java:79)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2196)
at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - /dev/cu.SLAB_USBtoUART; Method name - openPort(); Exception type - Port busy.
at jssc.SerialPort.openPort(SerialPort.java:164)
at processing.app.Serial.<init>(Serial.java:136)
... 8 more
Fehler beim Öffnen des seriellen Ports "/dev/cu.SLAB_USBtoUART".
Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre.
Ich denke der Fehler liegt an dem "busy Port", aber woran liegt das auf einmal (wie gesagt, bislang keine Probleme mit der Konfiguration.
Durch Google bin ich bereits auf dies Seite https://www.baldengineer.com/arduino-fixing-serial-port-in-use.html aufmerksam geworden und habe die Anleitung durchlaufen, ohne Erfolg. Habt Ihr noch Ideen?
Danke
Michael