Programming ESP8266-12e issues

So, I ordered an ESP8266 12e AI-thinker bare chip, and am trying to program it to use for a bike speedometer. I am using a standard USB to TTL programmer.

My problem is that the code is not uploading. In board options, I have it set to NodeMCU 1.0 . I am using the first circuit option in this article (the most basic one). I am getting the following error messages:

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Executable segment sizes:

ICACHE : 32768           - flash instruction cache 

IROM   : 248108          - code in flash         (default or ICACHE_FLASH_ATTR) 

IRAM   : 27497   / 32768 - code in IRAM          (IRAM_ATTR, ISRs...) 

DATA   : 1504  )         - initialized variables (global, static) in RAM/HEAP 

RODATA : 948   ) / 81920 - constants             (global, static) in RAM/HEAP 

BSS    : 26256 )         - zeroed variables      (global, static) in RAM/HEAP 

Sketch uses 278057 bytes (26%) of program storage space. Maximum is 1044464 bytes.

Global variables use 28708 bytes (35%) of dynamic memory, leaving 53212 bytes for local variables. Maximum is 81920 bytes.

esptool.py v3.0

Serial port COM9

Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):

  File "C:\Users\User\Mirror\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.0.2/tools/upload.py", line 66, in <module>

    esptool.main(cmdline)

  File "C:/Users/User/Mirror/Documents/ArduinoData/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool\esptool.py", line 3552, in main

    esp.connect(args.before, args.connect_attempts)

  File "C:/Users/User/Mirror/Documents/ArduinoData/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool\esptool.py", line 529, in connect

_

    raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))

esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header





This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

My code is this:

#include <ESP8266WiFi.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

const int freq = 1000; //Display refresh frequency
const int sensPin = 14; //Sensor pin #
const double pi = 3.14159265359; //Declaration of pi as a constant number
const int mags = 2; //Number of magnets on the bike ***CHANGE***
const double R = 0.34; //Radius of the bike whell ***CHANGE***

double u = 0; //Velocity
double T = 0; //Interval between two reads
long double prevTime = 0; //Previous time

int trig = 0;
int dist1 = 0;

void setup() {
  WiFi.mode( WIFI_OFF );
  WiFi.forceSleepBegin();
  delay(1);
  pinMode(sensPin, INPUT);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    for (;;);
  }
  digitalWrite(LED_BUILTIN, HIGH);
  display.clearDisplay();
  display.setTextSize(1.5);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  display.display();
}

void loop() {
  if (digitalRead(sensPin)) {
    T = mags * (millis() - prevTime);
    prevTime = millis();
    u = ((2 * pi * R) / T) * 3600;
    while (digitalRead(sensPin)) disp(u);
  }
  if (digitalRead(sensPin) == HIGH && trig == 2) {
    dist1 += 2 * R * pi;
    trig = 0;
  } else if (digitalRead(sensPin) == HIGH) {
    trig ++;
  }
  if (millis() - prevTime > 4000 / mags) u = 0;
  disp(u);
}

void disp(double U) {
  display.clearDisplay();
  display.setCursor(0, 10);
  display.print("Speed: ");
  display.print(U);
  display.println(" km/h");
  display.print("Distance: ");
  display.print(dist1);
  display.println(" m");
  display.setCursor(0, 10);
  display.display();
}

(I have the WiFi turned off as I am not using it)

My programmer is set on the 3.3v level.

Can anyone tell me what I am doing wrong?

If you are using the NodeMCU 1.0 (ESP8266 - 12E Module) of Fig-1, then upload the following sketch to do the basic functional check of the Board by blinking the indicated LED1.


Figure-1:

#define ledpin D0  //I am using built-in LED1 of Node

void setup()                                                                                                                  
{
  pinMode(ledpin, OUTPUT);
  Serial.begin(115200);
}

void loop()
{
  digitalWrite(ledpin, HIGH);
  delay(1000);
  digitalWrite(ledpin, LOW);
  delay(1000);
}

Does your ESP8266-board look like this one
image

Why do you try to upload your code by using such a USB-to-TTL-converter?
image

The "USB-to-TTL-converter is on board. Simply connect a USB-cable to the ESP8266 board and it should work.

If it still doesn't work by connecting your computer to the USB-socket of the ESP8266-board

In most cases this problem can be solved by adding a 1µF capacitor connected between EN and ground.

The capacitaor enables automatic upload.
Without such a capacitor you can press the buttons after you see the line

Connecting........_____..

and then it should upload

best regards Stefan

@GolamMostafa @StefanL38 Sorry that I was not clear in the original post, I am using the bare esp12e chip, like shown in the article I had linked before. I had it set on NodeMCU setting as the article linked said that was what worked the easiest.

If you are learning Microcontroller, then procure either the NodeMCU Board or the UNO Board. The advanced learners play with the bare IC.

I have been doing ESP8266 for around 1 year now, and arduino for around 5. I have chosen to use the bare ESP chip for its small size, as I have a fair understanding of how the WiFi works on ESP8266. Do you have a circuit diagram to program the ESP12-e? All the ones I have tried so far do not work.

As it is the same ESP8266-chip the rules of how to flash a ESP8266-01 still apply

There is a certain sequence of connection specific IO-pins to ground or 3.3V in a specific order to bring the ESP8266-chip into flash-mode

If this shall be done automatically you have to connect DTR or DTS too and you have to make sure that switching these signal lines is activated in the arduino-IDE

For some reason, I've had similar upload problems on a clone of a D1 Mini, the upload tends to work once or twice, then stops working with results like yours. Once the problems starts, nothing can upload correctly, regardless of upload baud rate or OS of the computer running the IDE (tried Windows 10 and Ubuntu both). Only way I've been able to get the board to operate correctly is to upload a sketch using an older ESP8266 boards package (version 2.5), after which the latest boards package can upload again for a few times.

You have a circuit like this ?

image26

https://alselectro.wordpress.com/2016/11/07/esp8266-upload-code-from-arduino-ide-no-arduino-board-required/

No, I had GPIO2 connected to VCC and I had not connected GPIO15. I will try this circuit!

The blue LED on the ESP-12 module is connected to GPIO2.

Thank you so much! This worked perfectly!

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