Power Supply Diagram

The ESP needs a blank sketch on the Uno to allow it to be flashed. Other way of doing is grounding the rest pin. Once the ESP code is flashed I will load the actual Uno code.

I say all this like I know what I am doing. Cannot get the sodding esp to accept the flash

What's the Uno for?
You plug the Wemos into the USB port on your PC, then use the EspHome Flasher to flash the binary. After that you can just use OTA.

I've been round in circles. Started with the ESP, tried the Wemos, went back to the ESP. Turns out all the problems are with the documentation and not the boards.

So currently back with the ESP board. Probably should switch back to the Wemos, was saving them of some other ideas that need a single pin.

I need the Uno because I need 5 pins that support PWM to drive the MOSFETs on the lights. 1 each for RGBW and 1 for the uplights.

Which ESP board? The Wemos is an ESP board, as is the NodeMCU.

All digital pins on the ESP may send PWM. The NodeMCU has, after dismissing the serial I/O and GPIO0 still has eight I/O pins. So does the Wemos D1 Mini.

So, why do you need the Uno?

I had switched back to a Makerfocus EPS-01s board which only has the two GPIO boards. This was because I was having issues with the client certificates when building for the Wemos board in code However, it turns out it was the code, or the documentation, that was wrong and so wouldnt build for the EPS-01 either.

I have now sorted that, so will switch back to the Wemos and save the Uno for something else, That will be much nicer as I wont have to bugger about with serial interfaces between the Uno and ESP

ESP-01 has four available GPIO. Two are nominally allocated to serial TX and RX, but unless you define them as such in the code, they are just GPIO. You do have to ensure GPIO0 and GPIO2 are not pulled down at boot.

Regardless 4 isn't enough and I would still need to the Rx and Tx for serial comms back to the other board.

Use a port expander. Two GPIO ports becomes 16 i/o ports with one chip.

Im having a spot of bother with the Wemos D1 board. I can get the code to upload, but it keeps erroring and resetting the board. the Exception is 0 - Illegal instruction.

I have tried uploading a basic sketch that just attempts a Wifi connection

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     #include <ESP8266WiFi.h>

char* ssid = "--";
char* password = "--";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  
  Serial.print("WiFi Connecting..");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(1000);
    Serial.print(".");
  }

  rst_info* rinfo = ESP.getResetInfoPtr();
  Serial.println(rinfo->reason);


}

void loop()
{


}

I wondered if it was due to current draw when it attempts to connect to Wifi so I have connected a 5v supply to the 5v pin to take the load off the USB.

Still same problem. I have decoded the reset output and that doesnt give much else beyond the Exception.

Any ideas?

Is this the complete sketch?

Where are you seeing the error? Are you uploading from the IDE?
Try running the blink sketch on the Wemos D1 Mini examples.

The error is in the serial monitor. Yes the blink sketch works fine. It's the minute I call a method on the WiFi class is resets.

That is the complete sketch I uploaded to the chip today. I was breaking it down to minor steps to find the fault

I couldn't get your code to compile.
I rewrote it here. Try this:

#include "ESP8266WiFi.h"

#define MYSSID "YourSSID"
#define MYPASSWORD "YourPassword"

const char ssid[] = MYSSID;
const char password[] = MYPASSWORD;

void setup() {
  Serial.begin(115200);
  while (!Serial);            //Wait for serial to be ready
  delay(500);

  Serial.println("...");
  Serial.println(F("WiFi_Test.ino"));
  Serial.print(F("WiFi Connecting to: "));
  Serial.print(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(WiFi.status()); Serial.print(F(" "));
  }
  Serial.println("");
  Serial.print(F("ResetReason= "));
  Serial.println(ESP.getResetReason());
}

void loop()
{
}

Thanks. I had missed the header includes I think, which is why mine wouldn't compile.

I loaded yours. Same result:

Exception 0: Illegal instruction
PC: 0xff3ddeff
EXCVADDR: 0x00000000

Decoding stack results
0x401002a5: millis() at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_wiring.cpp line 193
0x4010075f: umm_free_core(umm_heap_context_t*, void*) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 549
0x4010093e: free(void*) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 595
0x40100334: vPortFree(void*, char const*, int) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\heap.cpp line 322
0x40100190: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 181
0x4020137c: ESP8266WiFiSTAClass::status() at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 527
0x4020157d: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 208
0x4020155a: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 198
0x40201583: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 208
0x40100968: malloc(size_t) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 821
0x40100bd6: calloc(size_t, size_t) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 1181
0x40100bc8: calloc(size_t, size_t) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 1176
0x40100190: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 181
0x40202204: __esp_yield() at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/core_esp8266_features.h line 65
0x40202906: __delay(unsigned long) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_wiring.cpp line 54
0x402010b6: setup() at C:\Users\ianja\OneDrive\Documents\Arduino\sketch_jul19a/sketch_jul19a.ino line 24
0x4020232c: loop_wrapper() at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 198

Just get a constant loop of it resetting and that error. Tried it another board. Same Exception, slightly different stack trace:

Exception 0: Illegal instruction
PC: 0x402303b3
EXCVADDR: 0x402303bf

Decoding stack results
0x40100190: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 181
0x4020137c: ESP8266WiFiSTAClass::status() at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 527
0x4020157d: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 208
0x4020155a: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 198
0x40201583: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 208
0x40100968: malloc(size_t) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 821
0x40100bd6: calloc(size_t, size_t) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 1181
0x40100bc8: calloc(size_t, size_t) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 1176
0x40100190: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 181
0x40202204: __esp_yield() at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/core_esp8266_features.h line 65
0x40202906: __delay(unsigned long) at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_wiring.cpp line 54
0x402010b6: setup() at C:\Users\ianja\OneDrive\Documents\Arduino\sketch_jul19a/sketch_jul19a.ino line 24
0x4020232c: loop_wrapper() at C:\Users\ianja\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 198

Ok so I tried a 3rd board and that one actually works. So looks like two of the boards are goosed.

Thanks for the help.

This is odd. Very odd. The errors are saying that there is a problem with the core esp libraries. That you can run "blink.ino" on the 'failing' boards says that the boards are likely good. That my sketch runs on the third board says the libraries are OK.

I have purchased around 25 Wemos D1 Minis, mostly from Banggood, and not experienced a single bad board. I've fried a couple, but never DOA.

I know this sounds strange, but the only thing I can think of is the USB cable. Activating the WiFi transmitter on the ESP draws a few more mA than otherwise quiescent, so a marginal cable could let the voltage on the USB cable dip low. Are you going through a USB hub or directly to the USB port on the PC? If a hub, is it a powered hub? (I.E. the hub has its own power wart. Unpowered hubs have to share the 5V, 500mA from the PC with everything plugged into the hub.)

If the sketch uploads OK over USB, can you try powering the Wemos with a good 5V supply into the 5V pin?

Yes. thanks for help..

Yeah I thought about the power issue and I tried both the other boards with a stable 5v input, same problem. USB cable is a quality cable directly connected to the PC. I tried deleting an reloading the libraries as well and no good.

Possibly I have corrupted the flash, I might try using the ESPTool to wipe the flash completely and try again. I have a bunch of them so not too concerned at the minute.

I have a board working which is start. That's now crashing with a different error when I try to connect to MQTT :pensive:

This is screaming "power issues".

Have you tried another USB cable, or better yet a 5V, 1A (or better) power supply into the 5V pin?

Just because a USB cable is gold plated and costs $25, doesn't make it "quality cable" for delivering power. If your phone charges at a 100mAh rate, the cable doesn't have to deliver any more than 100mA. The USB spec says "up to 500mA", not that every USB component is guaranteed to deliver 500mA.

This is odd. I have connected it to a 5v 3A power supply. With the external power selected it wont even connect to the WiFi, it resets - no stack dump. Disconnect the power and it works fine for WiFi but bombs out connecting to MQTT. The power supply is a from a buck converter 12v -> 5v

Trying to find a half decent other USB cable to try. Most I have are for chargers and dont have data cables.

Correction - when connected to the USB and 5V it doesnt work. If disconnect the USB and leave the 5V in place then it does connect to the WiFi - confirmed on the router

You can't connect the 5V and the USB at the same time.