1

I'm currently working with a "WEMOS D1 R2 & mini" and am trying to call the time from an NTP server and display it onto an OLED display. I've been stuck on an error code that I can't seem to work around and was hoping for some pointers in the right direction. I've used an exception decoder to try an understand it but it's not really helping.

The error in the exception decoder:

Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
PC: 0x4020d032
EXCVADDR: 0x00000000

Decoding stack results
0x40202d64: ESP8266WiFiSTAClass::status() at C:\Users\XXX\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 563
0x4020292e: digitalClockDisplayOled() at C:\Users\XXX\Documents\Arduino\possible_fixed_clock/possible_fixed_clock.ino line 40
0x40202970: loop() at C:\Users\XXX\Documents\Arduino\possible_fixed_clock/possible_fixed_clock.ino line 35
0x4020512c: loop_wrapper() at C:\Users\XXX\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266\core_esp8266_main.cpp line 125

The code I'm using:

#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET -1
#define OLED_SCREEN_I2C_ADDRESS 0x3C
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Defining constants
const char *ssid     = "XXX";
const char *password = "XXX";
const long offset = 3600;
// Background stuff
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", offset);
void setup() {
  Serial.begin(115200);

  WiFi.begin(ssid, password);

  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }

  timeClient.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalClockDisplayOled();
}

void digitalClockDisplayOled() {
  display.clearDisplay();
  display.setCursor(0,0);
  display.print(timeClient.getHours());
  printDigitsOled(timeClient.getMinutes());
  printDigitsOled(timeClient.getSeconds());
  display.display();
}

void printDigitsOled(int digits){
  display.print(":");
  if(digits < 10)
    display.print('0');
  display.print(digits);
}

What is this error code actually telling me, and what kind of implementation could I use to fix it?

1
  • 2
    That error is an access violation. The fact that it happens inside a system function indicates that you probably have some memory corruption. Try removing code (e.g. remove the display output) until it works.
    – PMF
    Nov 24, 2021 at 11:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.