Wemos D1 esp8266 board no serial output, not running

I have uploaded a sketch which works on another board, same make and release. (V2015-08).
It compiles ok and appears to upload with no errors. However there is no serial output and I think the program is not running on the board.

Here is the compile and upload log:

Sketch uses 331909 bytes (31%) of program storage space. Maximum is 1044464 bytes.
Global variables use 30280 bytes (36%) of dynamic memory, leaving 51640 bytes for local variables. Maximum is 81920 bytes.
C:\Users\rich.KG.000\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1/python3 -I C:\Users\rich.KG.000\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2/tools/upload.py --chip esp8266 --port COM3 --baud 921600 --before default_reset --after hard_reset write_flash 0x0 C:\Users\RICHKG~1.000\AppData\Local\Temp\arduino_build_593555/web02.ino.bin
esptool.py v3.0
Serial port COM3
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: dc:4f:22:54:c1:cf
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 336064 bytes to 242505...
Writing at 0x00000000... (6 %)
Writing at 0x00004000... (13 %)
Writing at 0x00008000... (20 %)
Writing at 0x0000c000... (26 %)
Writing at 0x00010000... (33 %)
Writing at 0x00014000... (40 %)
Writing at 0x00018000... (46 %)
Writing at 0x0001c000... (53 %)
Writing at 0x00020000... (60 %)
Writing at 0x00024000... (66 %)
Writing at 0x00028000... (73 %)
Writing at 0x0002c000... (80 %)
Writing at 0x00030000... (86 %)
Writing at 0x00034000... (93 %)
Writing at 0x00038000... (100 %)
Wrote 336064 bytes (242505 compressed) at 0x00000000 in 5.5 seconds (effective 489.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Here is the sketch: (I have blanked out username and password for network)

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


#define UTC_OFFSET +1

const char *ssid = "";
const char *password = "";
int sensorValue = 0;
float volts = 0;
float cel = 0;
long temphist[40];
int t = 0;
char cIP[50];
IPAddress arduino_ip (192, 168, 1, 45);
IPAddress dns_ip     ( 192, 168,  1,  121);
IPAddress dns_ip_2     ( 8, 8,  8,  8);
IPAddress gateway_ip ( 192,  168,   1,   1);
IPAddress subnet_mask(255, 255, 255,   0);

char sTime [50];


ESP8266WebServer server ( 8182 );

const int led = 13;

void handleRoot() {
	digitalWrite ( led, 1 );
	char temp[450];
	int sec = millis() / 1000;
	int min = sec / 60;
	int hr = min / 60;

  sensorValue = analogRead(A0);
  volts = (sensorValue / 1023.0) * 5000;
  cel = volts * 0.1;
  //long nTemp = long(cel) -13;   // fudge, as esp gets it wrong
  long nTemp = long(cel) - 6;   // should be correct
  temphist[t] = nTemp;
  t++;
  if (t > 39) {
    t = 0;
  }

	snprintf ( temp, 450,

"<html>\
  <head>\
    <meta http-equiv='refresh' content='10'/>\
    <title>ESP8266 Demo</title>\
    <style>\
      body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\
    </style>\
  </head>\
  <body>\
    <h1>Richard's ESP8266 temperature monitor</h1>\
    <p>on ip: %s</p>\
    <p><b>Temp degC: %d at %s</b></p>\
    <p><img src=\"/test.svg\" /></p>\
  </body>\
</html>",

		cIP, nTemp, sTime
	);
	server.send ( 200, "text/html", temp );
	digitalWrite ( led, 0 );
}

void handleNotFound() {
	digitalWrite ( led, 1 );
	String message = "File Not Found\n\n";
	message += "URI: ";
	message += server.uri();
	message += "\nMethod: ";
	message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
	message += "\nArguments: ";
	message += server.args();
	message += "\n";

	for ( uint8_t i = 0; i < server.args(); i++ ) {
		message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n";
	}

	server.send ( 404, "text/plain", message );
	digitalWrite ( led, 0 );
}

void setup ( void ) {
	pinMode ( led, OUTPUT );
	digitalWrite ( led, 0 );
	Serial.begin ( 115200 );
	WiFi.mode ( WIFI_STA );
  WiFi.config(arduino_ip, gateway_ip, subnet_mask);
  // WiFi.setDNS(dns_ip); // not supported
	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() );
  String sIP = WiFi.localIP().toString();
  int cc= 0;
  for (cc = 0; cc<sIP.length(); cc++)
  {
    cIP[cc] = sIP[cc];
  }
  cIP[cc] = 0;

	if ( MDNS.begin ( "esp8266" ) ) {
		Serial.println ( "MDNS responder started" );
	}

  configTime(UTC_OFFSET * 3600, 0,"216.239.35.4", "uk.pool.ntp.org", "1.europe.pool.ntp.org");  // first one is time.google.com

  Serial.println("\nWaiting for time");
  while (!time(nullptr)) {
    Serial.print("t");
    delay(1000);
  }
  Serial.println("");

	server.on ( "/", handleRoot );
	server.on ( "/test.svg", drawGraph );
	server.on ( "/inline", []() {
		server.send ( 200, "text/plain", "this works as well" );
	} );
	server.onNotFound ( handleNotFound );
	server.begin();
	Serial.println ( "HTTP server started" );

  sensorValue = analogRead(A0);
  volts = (sensorValue / 1023.0) * 5000;
  cel = volts * 0.1;

  Serial.print("temp = ");
  Serial.println(cel);
 
}

void loop ( void ) {

  time_t now = time(nullptr);
   // Serial.println(ctime(&now));
  sprintf(sTime, ctime(&now));  // incorrect time
  
	server.handleClient();
}

void drawGraph() {
	String out = "";
	char temp[100];
  
  
 
	out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"400\" height=\"150\">\n";
 	out += "<rect width=\"400\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";
 	out += "<g stroke=\"red\">\n";
 	int y = temphist[0];
  int x1 = 0;
 	for (int x = 10; x < 390; x+= 10) {
 		if (x1 < (t-1))
     {
      y = temphist[x1];
   		int y2 = temphist[x1+1];
   		sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"2\" />\n", x, 120 - y, x + 10, 120 - y2);
   		out += temp;
     }
     x1++;
 	}
	out += "</g>\n</svg>\n";

	server.send ( 200, "image/svg+xml", out);
}

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

Have you tried a very simple program that simply opens the serial port and prints a message? Does that work? Less complicated to debug without all the other things going on...

Have you changed this address ?

Hi All,
I've tried another board, and the program is running ok except for the web server. I think therefore it might be a hardware/firmware issue, and not the program.

Try to erase all flash content (just once) when uploading the sketch.
Tools > Erase Flash > All Flash Content.
Set the IDE back to "Only Sketch" when done.
Leo..

I find it useful to blink a LED in the main program loop
this shows the hardware/software is running and if the program is hanging up, e.g. in a polling loop waiting for IO etc

Thanks Horace, that's a good suggestion. Anyway all is well now, the program including the web server is running fine now.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.