Post topics, source code that relate to the Arduino Platform

User avatar
By Max Pickle
#94782 I have an AZDelivery Node MCU ESP8266 [1] linked via SPI to a Adafruit BME280 Temperature, Humidity and Pressure Sensor [2] that when the data connections are made it prevents the ESP from booting and communicating with the IDE. The error from Visual Code Studio is:

Code: Select all    Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Generic ESP8266 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, dtr (aka nodemcu), 26 MHz, 40MHz,
    DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory,     
    Disabled, None, Only Sketch, 115200"

    Executable segment sizes:
    ICACHE : 32768           - flash instruction cache
    IROM   : 231724          - code in flash         (default or ICACHE_FLASH_ATTR)
    IRAM   : 26793   / 32768 - code in IRAM          (IRAM_ATTR, ISRs...)
    DATA   : 1496  )         - initialized variables (global, static) in RAM/HEAP
    RODATA : 876   ) / 81920 - constants             (global, static) in RAM/HEAP
    BSS    : 25608 )         - zeroed variables      (global, static) in RAM/HEAP

    Sketch uses 260889 bytes (27%) of program storage space. Maximum is 958448 bytes.
    Global variables use 27980 bytes (34%) of dynamic memory, leaving 53940 bytes for local
    variables. Maximum is 81920 bytes.

    esptool.py v3.0
    Serial port COM11
    Connecting........_____....._____....._____....._____....._____....._____....._____
    Traceback (most recent call last):
   
    File "..packages\esp8266\hardware\esp8266\3.0.2/tools/upload.py", line 66, in <module> esptool.main(cmdline)

    File "..packages/esp8266/hardware/esp8266/3.0.2/tools/esptool\esptool.py", line 3552, in main
    esp.connect(args.before, args.connect_attempts)
   
    File "../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


I have:

    - Tried the board, circuit and code in the Arduino IDE and same error so I do not believe it to be a Visual Code Studio specific problem.
    - Tried a different board - same error so I do not believe the board to be faulty.
    - Tried a different sensor - same error so I do not believe the sensor to be faulty
    - Disconnected the data lines - board boots, sensor shows power and correctly the node reports that the board cannot be found. So this would be the expected behaviour.
    - Uploaded the basic block sketch to the ESP and it works correctly.
    - Tried circuit and sensor with an Arduino Uno and it works.

The code is taken from the BME280test [3] example with appropriate changes made to the pin numbers and line 31 commented out to disable i2c with either 31/32 uncommented to enable SPI. Below is the circuit I am using with the following pinout:

    - 3v3/Vin N/A Red Vin
    - GND N/A Black GND
    - D5 HSPI SCK White SCK (GPIO 14)
    - D6 HSPI MISO Green SDO (GPIO 12)
    - D7 HSPI MOSI Blue SDI (GPIO 13)
    - D8 HSPI CS Yellow CS (GPIO 15)

Image

So, it seems to be an error with the ESP8266 and BME280 that blocks any sort of communication with the board but I have nothing to go on. I'm going to try a ESP32 and see if it gives a different response. If anyone has any idea or has experienced something similar I would welcome some insights.

Apologies for the duplication with https://electronics.stackexchange.com/q ... ts-booting. I'm keen to get and answer but struggled to decide on the best home for the question.

[1]: https://www.az-delivery.de/en/products/nodemcu
[2]: https://learn.adafruit.com/adafruit-bme ... t/overview
[3]: https://github.com/adafruit/Adafruit_BM ... 80test.ino
User avatar
By Max Pickle
#94811 Hi,

Thanks for the response. I'm guessing you missed "Tried circuit and sensor with an Arduino Uno and it works." from my problem description above. Easily done.

I know the sensor is working and have them working on my desk now with an ESP32 - same circuit. Just seemed to be something about the ESP8266.
User avatar
By AcmeUK
#94816 From what you have said you have uncommented the line to enable SPI mode.

To enter SPI mode the CS pin needs to be pulled down.

However the CS input pin has an internal pull-up resistor.

Hence to put the chip into SPI mode the CS pin needs to be connected to 0v and not to D8.

At least that is my reading of the BME280 data sheet.