ESP8266 SPI boot error

A LoRa module is connected to ESP8266 via SPI (not the flash SPI but: MOSI GPIO13, MISO GPIO12, SCK GPIO14) to an `ESP8266.
Scenario 1: When the ESP8266 is started up without the LoRa module on the SPI bus, then initialisation occurs, waiting for the LoRa module to be plugged in. When that is done, the program is further initialised and data reception occurs as normal.
Scenario 2: However, when startup occrus with the LoRa module in place, then even setup is not performed.

A logic analyser shows proper data transfers in the first scenario.
In scenario 2 errors are shown: "Settings mismatch" and "The initial (idle) state of the CLK line does not match the settings".

Power is not the issue: a 3.3V 1A line powers the LoRa module separately, grounds connected.

EDIT: led on pin 14 interferes with SPI SCK. Moving to LED_BUILTIN (GPIO16) does not solve the issue.

EDIT #2: solved. ESP8266 GPIO0 is used for interrupt attach. However GPIO0 also is used to set the ESP in flash mode. Solution: connect LoRa interrupt output to the only remaining useable ESP8266 GPIO pin which is GPIO16.

See attachment: logic analyser output.


#include <SPI.h>
#include <LoRa.h>
#define led 14
const int csPin = 15;         // LoRa chip select   GPIO15(D8)->SS or chip select
const int resetPin = 2;       // LoRa reset         GPIO2(D4)->RESET OF Lora module
const int DIO0Pin = 0;         // LoRa IRQ (Callback)      GPIO0 (D3) -> IRQ or "Callback"
volatile bool doRead = false; // Flag set by callback to perform read process hand interrupt main loop

void setup() {
  LoRa.setPins(csPin, resetPin, DIO0Pin); // set CS, reset, IRQ pin. Override the default CS, reset, and IRQ pins (optional)
  while (!Serial);
  Serial.println("LoRa Receiver IRQ");
  while (!LoRa.begin(868E6)) {

  // LoRa.setSyncWord(0xF3); // syncword default or private: 0x12; LoRaWAN/TTN: 0x34
  // LoRa.setTxPower(20);

  Serial.println("LoRa Initializing OK!");
  // trigger interrupt on pin 2 (INT0) (Arduino) or GPIO0 (D3) on ESP8266 (NodeMCU) from DIO0
  // register the receive callback
  // put the radio into receive mode

void loop() {

  while (!doRead) {
    digitalWrite(led, HIGH);
    digitalWrite(led, LOW);
    // wait for a second

  // yield();

void onReceive(int packetSize) {

  if (packetSize == 0) {
  doRead = true;
  //  incomingPacketSize = packetSize;
  // Read 2 bytes into a
  uint16_t a;
  char LoRaStringA[12];
  for (int i = 0; i < sizeof(a); i++) {
    *(((uint8_t*)&a) + i) = (uint8_t);
    //     LoRaString = a+(char);
    // itoa(a, LoRaStringA, 12);
  char a1 = a;

  // Read 2 bytes into b
  uint16_t b;
  char LoRaStringB[12];
  for (int i = 0; i < sizeof(a); i++) {
    *(((uint8_t*)&b) + i) = (uint8_t);
    //     LoRaString = b+(char);
    // itoa(b, LoRaStringB, 12);
  char b1 = b;

  // Read 2 bytes into counter
  uint16_t counter;
  for (int i = 0; i < sizeof(counter); i++) {
    *(((uint8_t*)&counter) + i) = (uint8_t);
  // Read 4 bytes into x
  float x;
  for (int i = 0; i < sizeof(x); i++) {
    *(((uint8_t*)&x) + i) = (uint8_t);
  // Read 4 bytes into z
  float z;
  for (int i = 0; i < sizeof(z); i++) {
    *(((uint8_t*)&z) + i) = (uint8_t);
  // Display read values
  Serial.print("Received: ");
  Serial.print("a = ");
  Serial.print("  b = ");

  Serial.print("  counter = ");

  Serial.print("  x = ");
  Serial.print("  z = ");
  Serial.print("  with RSSI ");
  doRead = false;    // Set flag back to false so next read will happen only after next ISR event

SPI LoRa ESP8266 errors.pdf (216.2 KB)

  • List item

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