I have Wemos Mega-ESP8266 board. I have uploaded a simple WebSocket server on the ESP...
#include <ESP8266WiFi.h>
#include <WebSocketsServer.h>
const char* ssid = "SKYNET";
const char* password = "yourdogsfavouriteauntysmaidenname";
WebSocketsServer webSocket = WebSocketsServer(81);
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) {
//Serial.printf("[%u] get Message: %s\r\n", num, payload);
switch(type) {
case WStype_DISCONNECTED:
break;
case WStype_CONNECTED:
{
IPAddress ip = webSocket.remoteIP(num);
Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\r\n", num, ip[0], ip[1], ip[2], ip[3], payload);
}
break;
case WStype_TEXT:
{
String _payload = String((char *) &payload[0]);
Serial.print(_payload);
}
break;
case WStype_BIN:
{
hexdump(payload, lenght);
}
// echo data back to browser
webSocket.sendBIN(num, payload, lenght);
break;
}
}
void setup() {
// Set up serial comms
Serial.begin(115200);
// Set up WiFi
WiFi.begin(ssid, password);
while(WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(200);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
delay(500);
// Set up web socket
Serial.println("Start Websocket Server");
webSocket.begin();
webSocket.onEvent(webSocketEvent);
}
void loop() {
webSocket.loop();
}
I upload via the Arduino IDE & everything looks fine except the ESP doesnt send any information back through the serial monitor (yes I have the DIP switches correct for serial <> ESP comms).
I tried to see if was sending anything through the Mega via Serial3, the mega code (DIP switches set accordingly & ESP serial switch set to RX3). Mega code...
// Input buffer from ESP8266
String temp;
void setup() {
// Set up serial comms
Serial.begin(115200); // Debug to Serial Monitor
Serial3.begin(115200); // From ESP8266
}
void loop() {
while (Serial3.available()) {
Serial.println(".......");
Serial.println("In from ESP8266");
temp = Serial3.readString();
Serial.println(temp);
Serial.println(".......");
}
}
So now I get 2 one time messages to the serial monitor..
.......
In from ESP8266
[WS-Server] Server Started.
.......
.......
In from ESP8266
pm open,type:2 0
.......
I have no idea where these messages are being generated or why the ESP isnt sending the serial messages on set up eg the IP address for the ESP etc.
Any idea what's going on here?
Edit 1: Addition info asked for in comments (or at leat I think this is what was asked for)
Edit 2:
DIP switch settings for flashing the ESP - OFF, OFF, OFF, OFF, ON, ON, ON
DIP switch settings ESP> serial monitor - OFF, OFF, OFF, OFF, ON, ON, OFF (RX switch to TX0)
DIP switch settings for ESP> Mega> serial monitor - ON, ON, ON, ON, OFF, OFF, OFF (RX switch to TX3)
Edit 3 I have to press the red reset button after flashing the ESP8266 & it works BUT as soon as I unplug & restart nothing again! The client connects, sends the same data but it doesnt get echoed back via the serial comms. The only way to get to work again is to reflash the ESP8266 and hit the reset button.
Edit 4 Swapped out the board & now nothing works again. Uploads look fine but no serial comms at all from the ESP8266.
-
@Juraj have added (I think) the information you requested to the OPDrBwts– DrBwts2019年05月22日 11:08:15 +00:00Commented May 22, 2019 at 11:08
-
sorry. I read then the question again and it is not about logging. (but set "Debug port" to None and don't use "Wemos D1 R1". use "Generic esp8266")Juraj– Juraj ♦2019年05月22日 11:23:05 +00:00Commented May 22, 2019 at 11:23
-
@Juraj just reflashed using "Generic esp8266" & no debug port & got a string of gibberish but nothing else. Flash mode set to DOUT (compatible)DrBwts– DrBwts2019年05月22日 11:29:59 +00:00Commented May 22, 2019 at 11:29
-
ahh right OFF, OFF, OFF, OFF, ON, ON, ON to flash the ESPDrBwts– DrBwts2019年05月22日 11:34:46 +00:00Commented May 22, 2019 at 11:34
-
@Juraj DIP switch info added to OPDrBwts– DrBwts2019年05月22日 11:55:50 +00:00Commented May 22, 2019 at 11:55
1 Answer 1
The esptool auto-reset feature by default sets io 0 LOW over the RST line and then makes a reset over the DTR line to put the esp8266 into flashing mode. After the upload the esptool resets the board over the DTR line.
On this board Mega+WiFi, only the DTR line is wired like for AVR MCU. For flashing the io 0 pin is put LOW with the pin 7 of the DIP switch manually. So the reset after upload sets the esp8266 back to flashing mode.
The esp8266 arduino package changed from version 2.5.0 the upload tool to the python version of the esptool which makes this reset after upload. This reset can be turned off by changing the command line of the esptool in platform.txt (--after no_reset
in tools.esptool.upload.pattern
before write_flash
)
-
1if you don't like the DIP switches, you can upload to esp8266 over the ATMega forum.arduino.cc/index.php?topic=519181.02019年05月23日 06:44:45 +00:00Commented May 23, 2019 at 6:44
Explore related questions
See similar questions with these tags.