Sketch on ESP8266 of ATmega328P+ESP8266 combo doesn't work

I have a .UNO+WiFi R3 ATmega328P+ESP8266, 32Mb flash, USB-TTL CH340G, Micro-USB clone.

The most simple sketch, flashing a led doesn’t work on the ESP8266

#define LED 12 // D6, GPIO12
 
void setup() {
  pinMode(LED, OUTPUT);
}
 
void loop() {
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);
  delay(1000);
}

The code seems to load fine. Following the output of the IDE:

esptool.py v2.8
Serial port COM4
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: ec:fa:bc:2c:6b:06
.....
Compressed 260464 bytes to 190655...

Writing at 0x00000000... (8 %)
....
Writing at 0x0002c000... (100 %)
Wrote 260464 bytes (190655 compressed) at 0x00000000 in 16.9 seconds (effective 123.2 kbit/s)...
Hash of data verified.

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

The attached led doesn’t flash. I also tried it on a couple of other pins (of course changing the code). I figured out which pin is which exactly (one of the two pins labeled GPIO02 on the board is in fact GPIO00), figuring that I have to use the GPIO number instead of the digital pin number (Dx).

If I add Serial.println (“Hello World”) to the sketch I don’t get output on the serial monitor. COM4 seems to be connected. I installed the drivers for the CH340.

The same code works on the ATmega328P of the same board (of course different switch settings) and on a NodeMCU, also with ESP 8266.

Anyone a suggestion? I have been busy with this for days. Do I maybe need to reflash the ESP8266 firmware?

Thanks.


System:
Windows 10
Board: UNO+WiFi R3 ATmega328P+ESP8266, 32Mb flash, USB-TTL CH340G, Micro-USB
Board: Arduino IDE 1.8.12
Dip switch setting: OFF, OFF, OFF, OFF, ON, ON, ON, – (for the ESP8266)
Arduino IDE Board setting: Generic ESP8266 module, standard settings.
Baud rate 9600.

the LED is on io 14

I connected an external led. It doesn't work.

RabanePaco:
I connected an external led. It doesn't work.

io 12 of esp8266 is not exposed. how did you connect a led to it? you connected it to pin 12 of Uno?

No, I connected it to the GPIO12 pin on the board. Pins are at the far end of the USB connector. See the picture of UNO WiFi R3 ATmega328P ESP8266, 32Mb flash, USB-TTL CH340G Pinout specs under documents tab.

The slightly modified standard led example for the buildin led ("2" according to the board specs for generic Arduino)

void setup() {
  Serial.begin(9600);
  delay (1000);
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
  // but actually the LED is on; this is because
  // it is active low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(1000);                      // Wait for a seconds (to demonstrate the active low LED)
  Serial.println ("Hello World");
  Serial.print ("LED_BUILTIN: "); Serial.println  (LED_BUILTIN);
}

doesn't do anything either.
There is a small led next to the ESP reset button. This is constantly on. Pin GPIO2 is constantly high. No blinking.
While loading the sketch the TX and RX led keep flashing.
No output on the Serial Monitor.

A similar sketch for the ATmega does work: blinking building led and text output (with correct dip switch setting).

Thanks for helping me!

sorry I mised io 12 on the header.
according to schematics the built in LED is on io 14.
io 2 has pull-up for boot configuration.

Solved?

After I set the dip switch setting to OFF, OFF, OFF, OFF, ON, ON, OFF (changed from on) , –
that means no USB <-> ESP8266 (Update firmware or sketch), but USB <-> ESP8266 (communication),
the external led on pin GPIO2 blinks. Maybe there is no build-in led; the led that was on before I don’t see anymore. And I have output on the Serial Monitor!

So it looks like you need to change dip switches between downloading & running sketches. Complicated! Hard for development.

GPIO14 works indeed for the build-in led. But is not rightly defined. GPIO14 is not exposed.

The ESP reset button doesn't seem enough to restart the sketch after changing the dip switches. Power cycling does.

I'm glad I got a (very simple) sketch working on both processors! I was afraid I had bought a lemon.

Juraj, thanks for helping me!

the board is the same as if you had an Uno and a esp8266 module. only instead of rewiring for upload to esp8266 over the USB chip of Uno, you flip the DIP switches. but, to use SoftwareSerial you have to patch some Uno pins to RX and TX on the esp8266 header.
the DIP switches can't take too much switching so it is better to upload a firmware to esp8266 and leave it there. or if you want to upload esp8266 sketches, use OTA support in the sketch and upload over WiFi.

Thank you, Juraj. I have to study the IPC (interprocess communication). I might come back to this forum with more questions, also about other problems.

hi i am facing same problem

#define ledpin 5

void setup() {
// put your setup code here, to run once:
pinMode(ledpin, OUTPUT);

Serial.begin(9600);
WiFi.begin(“robo”, “somshilp123”);
while(WiFi.status() != WL_CONNECTED)
{
Serial.print("…");
delay(200);
}
Serial.println();
Serial.println(“NodeMCU is Connected!”);
Serial.println(WiFi.localIP());

}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(ledpin, LOW); // Turn the LED on (Note that LOW is the voltage level
delay(1000); // Wait for a second
digitalWrite(ledpin, HIGH); // Turn the LED off by making the voltage HIGH
delay(2000);
}

in serial print it is showing nodemcu is connected
but led dont blink
need help

i am using Uno+WiFi R3 AtMega328p+NodeMSU ESP8266 8mb Memory USB-TTL CH340G Compatible for Arduino UNO board

no pin GPO14 is on board