Hello everyone,
Long story short, I'm working on an epaper display connected to an Adafruit Huzzah Feather to pull data from Google Calendar and display the entries for next week.
I basically have two functional scripts at this point, one that displays data to the epaper (Waveshare 7.5 inch BWR) and another script that pulls the data from gCal and prints it out to serial.
I tried integrating both scripts but I end up with a stack error on my serial.
This is the script for the ePaper:
#include <GxEPD.h>
#include <GxGDEW075T8/GxGDEW075T8.cpp>
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp>
#include <GxIO/GxIO.cpp>
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
WiFiManager wifiManager;
const char* ssid = "";
const char* password = "";
GxIO_Class io(SPI, SS, 0, 2);
GxEPD_Class display(io);
void setup()
{
Serial.begin(115200);
display.init(115200);
wifiManager.autoConnect("ePaper Wifi");
Serial.println("Connected to Wifi!");
display.drawPaged(normal);
}
void normal()
{
const char* name = "Testing output on display!";
display.setRotation(0);
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setCursor(10, 10);
display.setTextSize(5);
display.println(name);
}
void loop()
{
}
This is the code for the gCal data:
#include <ESP8266WiFi.h>
#include <WiFiClientSecureRedirect.h>
// replace with your network credentials
char const * const ssid = ""; // ** UPDATE ME **
char const * const passwd = ""; // ** UPDATE ME **
// fetch events from Google Calendar
char const * const dstHost = "script.google.com";
char const * const dstPath = "/macros/s/link/exec"; // ** UPDATE ME **
int const dstPort = 443;
int32_t const timeout = 5000;
// On a Linux system with OpenSSL installed, get the SHA1 fingerprint for the destination and redirect hosts:
// echo -n | openssl s_client -connect script.google.com:443 2>/dev/null | openssl x509 -noout -fingerprint | cut -f2 -d'='
// echo -n | openssl s_client -connect script.googleusercontent.com:443 2>/dev/null | openssl x509 -noout -fingerprint | cut -f2 -d'='
char const * const dstFingerprint = "C7:4A:32:BC:A0:30:E6:A5:63:D1:8B:F4:2E:AC:19:89:81:20:96:BB";
char const * const redirFingerprint = "E6:88:19:5A:3B:53:09:43:DB:15:56:81:7C:43:30:6D:3E:9D:2F:DE";
#define DEBUG
#ifdef DEBUG
#define DPRINT(...) Serial.print(__VA_ARGS__)
#define DPRINTLN(...) Serial.println(__VA_ARGS__)
#else
#define DPRINT(...) //now defines a blank line
#define DPRINTLN(...) //now defines a blank line
#endif
void setup() {
Serial.begin(115200); delay(500);
DPRINT("\n\nWifi ");
WiFi.begin(ssid, passwd);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
DPRINT(".");
}
DPRINTLN(" done");
}
void loop() {
DPRINT("Free heap .. "); DPRINTLN(ESP.getFreeHeap());
bool error = true;
WiFiClientSecureRedirect client;
DPRINT("Alarm sync ");
do {
DPRINT(".");
if (client.connect(dstHost, dstPort) != 1) { // send connect request
break;
}
DPRINT(".");
while (!client.connected()) { // wait until connected
client.tick();
}
DPRINT(".");
if (client.request(dstPath, dstHost, 2000, dstFingerprint, redirFingerprint) != 0) { // send alarm request
break;
}
DPRINT(".");
while (!client.response()) { // wait until host responded
client.tick();
}
DPRINT(".\n<RESPONSE>\n");
while (client.available()) { // read and print until end of data
String line = client.readStringUntil('\n');
Serial.println(line);
}
DPRINT("</RESPONSE>");
client.stop();
error = false;
} while (0);
DPRINTLN(error ? " error" : " done");
}
And this is both of them combined (only the includes are added) which ends up with a stack error.
#include <GxEPD.h>
#include <GxGDEW075T8/GxGDEW075T8.cpp>
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp>
#include <GxIO/GxIO.cpp>
#include <ESP8266WiFi.h>
#include <WiFiClientSecureRedirect.h>
// replace with your network credentials
char const * const ssid = ""; // ** UPDATE ME **
char const * const passwd = ""; // ** UPDATE ME **
GxIO_Class io(SPI, SS, 0, 2);
GxEPD_Class display(io);
// fetch events from Google Calendar
char const * const dstHost = "script.google.com";
char const * const dstPath = "/macros/s/link/exec"; // ** UPDATE ME **
int const dstPort = 443;
int32_t const timeout = 5000;
// On a Linux system with OpenSSL installed, get the SHA1 fingerprint for the destination and redirect hosts:
// echo -n | openssl s_client -connect script.google.com:443 2>/dev/null | openssl x509 -noout -fingerprint | cut -f2 -d'='
// echo -n | openssl s_client -connect script.googleusercontent.com:443 2>/dev/null | openssl x509 -noout -fingerprint | cut -f2 -d'='
char const * const dstFingerprint = "C7:4A:32:BC:A0:30:E6:A5:63:D1:8B:F4:2E:AC:19:89:81:20:96:BB";
char const * const redirFingerprint = "E6:88:19:5A:3B:53:09:43:DB:15:56:81:7C:43:30:6D:3E:9D:2F:DE";
#define DEBUG
#ifdef DEBUG
#define DPRINT(...) Serial.print(__VA_ARGS__)
#define DPRINTLN(...) Serial.println(__VA_ARGS__)
#else
#define DPRINT(...) //now defines a blank line
#define DPRINTLN(...) //now defines a blank line
#endif
void setup() {
Serial.begin(115200); delay(500);
display.init(115200); // enable diagnostic output on Serial
DPRINT("\n\nWifi ");
WiFi.begin(ssid, passwd);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
DPRINT(".");
}
DPRINTLN(" done");
}
void loop() {
DPRINT("Free heap .. "); DPRINTLN(ESP.getFreeHeap());
bool error = true;
WiFiClientSecureRedirect client;
DPRINT("Alarm sync ");
do {
DPRINT(".");
if (client.connect(dstHost, dstPort) != 1) { // send connect request
break;
}
DPRINT(".");
while (!client.connected()) { // wait until connected
client.tick();
}
DPRINT(".");
if (client.request(dstPath, dstHost, 2000, dstFingerprint, redirFingerprint) != 0) { // send alarm request
break;
}
DPRINT(".");
while (!client.response()) { // wait until host responded
client.tick();
}
DPRINT(".\n<RESPONSE>\n");
while (client.available()) { // read and print until end of data
String line = client.readStringUntil('\n');
Serial.println(line);
}
DPRINT("</RESPONSE>");
client.stop();
error = false;
} while (0);
DPRINTLN(error ? " error" : " done");
}
And this is the stack debug:
Decoding stack results
0x4021b022: more_comps at crypto/bigint.c line 1072
0x4021bfb4: bi_set_mod at crypto/bigint.c line 590
0x4021b0c8: trim at crypto/bigint.c line 1197
0x4021d1a1: RSA_pub_key_new at crypto/rsa.c line 96
0x40220e15: asn1_get_big_int at ssl/asn1.c line 169
0x402212b1: asn1_public_key at ssl/asn1.c line 556
0x4022113d: asn1_name at ssl/asn1.c line 470
0x40220fde: asn1_validity at ssl/asn1.c line 410
0x40219256: x509_new at ssl/x509.c line 128
0x40104456: glue2esp_linkoutput at glue-esp/lwip-esp.c line 292
0x40104456: glue2esp_linkoutput at glue-esp/lwip-esp.c line 292
0x4021e6aa: SHA256_Process at crypto/sha256.c line 157
0x402202a8: SHA256_Update at crypto/sha256.c line 231
0x40216ec9: process_certificate at ssl/tls1.c line 2181
0x40218506: do_clnt_handshake at ssl/tls1_clnt.c line 107
0x402063b8: __yield() at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/cores/esp8266/core_esp8266_main.cpp line 96
0x40217f50: basic_read at ssl/tls1.c line 1607
0x4021832c: do_client_connect at ssl/tls1_clnt.c line 168
0x401004d8: malloc at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/cores/esp8266/umm_malloc/umm_malloc.c line 1668
0x402180b8: ssl_read at ssl/tls1.c line 314
0x40205418: WiFiClientSecure::_connectSSL(char const*) at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp line 132
0x4020492a: WiFiClient::connect(IPAddress, unsigned short) at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/libraries/ESP8266WiFi/src/include/ClientContext.h line 121
0x4020557d: WiFiClientSecure::connect(char const*, unsigned short) at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp line 455
0x4020595b: WiFiClientSecureRedirect::tick() at /Users/Omran/Documents/Arduino/libraries/esp8266-WiFiClientSecureRedirect-master/WiFiClientSecureRedirect.cpp line 220
0x4020310d: loop() at /Users/Omran/Desktop/esp8266-WiFiClientSecureRedirect-master 2/examples/GoogleCalendar-sync/GoogleCalendar-sync.ino line 60
0x402201bb: SHA256_Process at crypto/sha256.c line 196
0x402042a0: ESP8266WiFiSTAClass::status() at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 483
0x40204401: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 170
0x402043dd: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 160
0x40204407: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 170
0x40206dac: Print::write(unsigned char const*, unsigned int) at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/cores/esp8266/Print.cpp line 38
0x40205c5d: Print::write(char const*) at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/cores/esp8266/Print.h line 60
0x40205cd4: Print::println(char const*) at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/cores/esp8266/Print.cpp line 175
0x4020301a: setup() at /Users/Omran/Desktop/esp8266-WiFiClientSecureRedirect-master 2/examples/GoogleCalendar-sync/GoogleCalendar-sync.ino line 46
0x4020638c: loop_wrapper() at /Users/Omran/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/cores/esp8266/core_esp8266_main.cpp line 124
Any ideas?
I'm not that familiar with the ESP8266, but I'd say you are short of RAM.
The stack trace doesn't look legit to me, it is likely corrupt. If one can believe the last few lines, then the crash occurred during a diagnostic print to serial in setup(), so presumably loop() hasn't even begun.
The actual amount of memory available on the ESP8266 for user applications seems to be a bit of a moving target, but I'll reference this thread (esp8266.com) to give an indication of how little it may be. Your GxGDEW075T8 library usage will incur a buffer allocation of 30k for the screen content, which is a sizeable chunk in itself.
Others may have additional suggestions, but I reckon you could look into the following options where possible:
- use of external RAM
- removing any core OS features you don't need
- editing library to reduce resolution of screen; ie. reduce buffer and scale up pixels
- researching other space saving possibilities...
Hey, hishamomran,
I am trying to get this library to work with a huzzah feather as well, but I am think I am stuck with the wiring. Do you have an image of what you used?
Thanks!