[SOLVED] I can't load a new sketch in my ESP8266

I use esp8266-12E alone without Arduino.
I Loaded the sketch below.
The sckecht works well, but no lines 43 and 47
When trying to reload the corrected skecht, it is impossible.
I have done with another module and the same result.
1.6.6 Arduino after compiling answers:
warning: failed espcomm_sync
error: failed especom_open
Is there any solution?
I’m sorry, my english is bad,
Thank you


1. #define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
2. #include <ESP8266WiFi.h>
3. #include <BlynkSimpleEsp8266.h>
4. #include <SimpleTimer.h>

5. // You should get Auth Token in the Blynk App.
6. // Go to the Project Settings (nut icon).

7. char auth[] = "e60da47a17b14d5c8xxxxxxxxxxxxxxx";
8. WidgetLED led1(V1);
9. WidgetLED led2(V2);
10. int val = 0; // variable que guardará el estado del gpio4
11. int PinPuerta = 4; //GPIO4
12. int correo = 0; //variable para que no se envíe más que un correo
13. int Analog=A0; //variable del pin analógico


14. SimpleTimer timer;

15. void puertaWidget()
16. {
17.  val = digitalRead(PinPuerta); // iluminamos_apagamos el led en Blynk
18.  if (val == 1)
19.  {
20.     led1.on();
21.     BLYNK_LOG("LED1: on");
22.  
23.   }
24.   if (val == 0)
25.   {
26.     led1.off();
27.     BLYNK_LOG("LED1: off");
28.    }
29. }

30. void setup()
31. {
32.   Serial.begin(115200);
33.   Blynk.begin(auth, "my ssid", "my pasword");
34.   pinMode(PinPuerta, INPUT);
35.   pinMode(Analog,INPUT);
36.   timer.setInterval(1000L, puertaWidget);
37. }

38. void loop()
39. {
40.     int AnalogVal=analogRead(Analog);

41. if(AnalogVal<100)
42. {
43. **Blynk.virtualWrite(5, HIGH);**
44. led2.on();
45. }
46. else {   
47.       **Blynk.virtualWrite(5, LOW);**
48.       led2.off();
49.       }

50.   Blynk.run();
51.   timer.run();

52.   if ((correo == 0) && (val == 1))
53.   {
54.     Blynk.email("profeactii@gmail.com", "Aviso Blynk", "Pin GPIO 4 a positivo");
55.     correo = 1; //para que no se vuelva a mandar el mensaje
56.   }
57.   
58. }

failed espcom is usually about bad wiring. How do you upload your sketch? Do you use a usb-to-serial convertor? Does the standard Blink example upload?

The lines you both mentioned should work fine. You can try with a value instead of LOW or HIGH, but I’m pretty sure this would work.

make sure to connect tx to rx and rx to tx.
when i get this error i simply unplug and replug(dont really know if this is a word :slight_smile: ) the power just before uploading the scetch (so when it is still compiling).

hope this works :smile:

Bas Peter

Thanks for your quick response

My big problem is not being able to upload new sketch.
Wiring is revised previously have been doing multiple tests successfully (only sketch with IDE 1.6.7 without using Blynk).
The USB to serial converter works well, I tried another and have obtained the same results.
I think my ESP8266 are useless.
I do not know if the problem is in the code.
May enter a loop and does not let other requests.

does the blue light blink when you connect the power?
The ESP’s use quite alot of power. I use the USB2Serial board to flash the ESP and I use an UNO to power (3.3v) the ESP. both the UNO’s and the USB2Serial’s GND connected to the ESP.

BasPeter
The TX and RX connections are correct, and proven to work at 3.3 volt.
connect and disconnect power before compiling, I’ve also tested.
Thank you.

The blue LED flashes once when power is connected.
Back, when work well, fast twice flashes.
And now the module not outputs the AI-THINKER wifi leading configured by default.
In addition, the power module is independent of the USB, the GND of the power and USB are connected.
I think they are definitely spoiled. Why? I do not know.
Thank you very much for taking my problem so quickly

If you have nice usb-to-serial you can use this guide: http://reflowster.com/blog/2015/05/11/esp8266.html to setup automated programming. Are you sure you are entering the programming mode? If it doesn’t output AT commands anymore it could be broken.

I always order a couple ESP’s because one out of ten seems to be not ok. The above guide is basically the only one I use by the way, it’s really good. The espcom_sync failed is definitly not a coding issue. It is 99% sure something with your hardware.

Have you tried another ESP since all other functions like Arduino and USB to serial seem to work fine?

Hi. I have never actually had an esp12 fail on me yet, and have about 30 units here and there. I always start by putting surface mount pullups and a pulldown on the back.
10 or 12K pullups on Reset, En, 00, and a pulldown on 15.(required). Some already have these in place but I just do it for peace of mind. A 0.1 cap between vcc and gnd.
I stick with Arduino 1.6.5 because it works, and does not give my any issues, unlike updates. Maybe a bit anal, but I get fed up trying to sort other issues rather than the stuff I am working on.

I use manual switches for reset and programming, so I know the esp is in prog mode before any write attempts are made.
The AT command type output will not appear after re flashing, only a stream of gibberish due to the lower baud rate.
I’ve had failed attempts at the point of opening the port, but usually because the port has got locked at some point. I just close the serial monitor, and unplug the FDTI usb. Plug back in and upload.
Flashing is at 115K, so maybe best to double check that the port is set for that.

What do you see on the serial monitor when you do a reset? (not in prog mode). Output will be at around 76K from memory, (76800?) on some modules 9600 on others. That might let you know if it’s dead or still alive.
Maybe something in the above that helps?

Sorry Sorry
It was a connection problem in the supply of 5 volt above the 3.33 volt converter module.
All works.

thanks

@Lichtsignaal, Thanks for the link to reflowster. Great information.

A post was split to a new topic: Error in upload using Arduino Mega 2560