Chat here is you are connecting ESP-xx type modules to existing AVR based Arduino

Moderator: igrr

User avatar
By watson44
#94035 Hello. I am trying to connect my NodeMCU to my laptop using TCP/IP. After connecting, the laptop issues some address values. The NodeMCU reads the corresponding byte in flash memory and prints it.
Here is the code:

Code: Select all#include <SPI.h>
#include <ESP8266WiFi.h>

byte ledPin = 2;
char ssid[] = "******";           // SSID of your home WiFi
char pass[] = "*******";            // password of your home WiFi
const char* host = "<ip>";  // IP serveur - Server IP
const int   port = 4000;            // Port serveur - Server Port
const int   watchdog = 500;        // Fréquence du watchdog - Watchdog frequency
unsigned long previousMillis = millis();
unsigned long askTimer = 0;

void setup() {
  Serial.begin(115200);               // only for debug
  WiFi.begin(ssid, pass);             // connects to the WiFi router
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("Connected to wifi");
  pinMode(ledPin, OUTPUT);
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop () {
  digitalWrite(ledPin, LOW);    // to show the communication only (inverted logic)
  unsigned long currentMillis = millis();
  WiFiClient client;
//  WiFiClient client;
  if (!client.connect(host, port)){
      Serial.println("connection failed");
      client.stop();
      return;
    }
// Watch dog to keep some time gap
  if ( currentMillis - previousMillis > watchdog ){
    previousMillis = currentMillis;
    while (client.available() == 0){
      Serial.println("Here test");
    }

    while(client.available()){
      String line = client.readStringUntil('\r');
      line.trim();
      long tmp = line.toInt();
      uint32_t incomingValue = (uint32_t)tmp;
      Serial.println(incomingValue);
      uint32_t data;
      ESP.flashRead(incomingValue, &data, 1);
      String x = String(data, HEX);
      Serial.println(x.substring(x.length()-2, x.length()));
    }
  }
  digitalWrite(ledPin, HIGH);
  delay(2000);
}


After a connection is established, and about 60-100 rounds of communication between the server and NodeMCU, the NodeMCU throws a LoadProhibited Exception (Exception 28). On decoding the error stack message, I found the error is in the line if(!client.connect(host, port)). The addresses being issued by the server are well within flash memory limit, so we can safely ignore that. Can anyone tell me what the issue might be?

Here is the exception stack:

Exception (28):
epc1=0x401013a2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3ffef870 end: 3ffefb40 offset: 01a0

>>>stack>>>
3ffefa10: 3ffe84db 00000000 00000000 402037c4
3ffefa20: 3fff2360 40206ac6 3fff1e30 0000005a
3ffefa30: 402021e0 00000000 3ffe84d1 4020651e
3ffefa40: b303a8c1 3fff1d74 00000006 40202a9c
3ffefa50: 00000001 00000002 3fff1e30 40209031
3ffefa60: 00000000 3ffefa90 3fff1e30 40207b6c
3ffefa70: 00000fa0 00000fa0 3ffefae0 3ffeeb14
3ffefa80: 00000fa0 3fff1e30 3ffefae0 402025eb
3ffefa90: b303a8c1 00000000 3fff1d70 40100f1e
3ffefaa0: 3fffdc20 00000fa0 3ffefae0 4020256d
3ffefab0: 3ffe8548 b303a8c1 3ffe8548 b303a8c1
3ffefac0: 3ffe84d1 000249f4 3ffeea50 40202823
3ffefad0: 3ffe835b 0004d66a 3ffe835b 402020ef
3ffefae0: 3ffe84e8 00000000 000003e8 0004cab1
3ffefaf0: 00000000 00000000 3fff11e0 0000000f
3ffefb00: 00000000 00000000 00000016 40101941
3ffefb10: 40203441 0000000f 00000006 fffffffc
3ffefb20: 3fffdc20 00000000 3ffeeb0d 40203469
3ffefb30: 00000000 00000000 3ffeeb20 40100114
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(1,6)


ets Jan 8 2013,rst cause:4, boot mode:(1,6)

wdt reset

Please help me.