0 votes
in ESPaper by (170 points)

In loadConfig(), the program tries to load "/espaper.txt" using SPIFFS.open. It fails. In fact, I can't see how that file ever gets there, so of course it is going to fail. In fact, there are no files in the SPIFFS at all.

I added some debugging and it is clear that nothing is in the SPIFFS root.

String str = "loadConfig:\r\n";
    Dir dir = SPIFFS.openDir("/");
    while (dir.next()) {
        str += dir.fileName();
        str += " / ";
        str += dir.fileSize();
        str += "\r\n";
    File f = SPIFFS.open("/espaper.txt", "r");
    if (!f)
        Serial.println("Failed to open config file for reading");
        return false;

Where do I go from here?

1 Answer

0 votes
by (18.2k points)

The file is (meaning: should be) written at https://github.com/ThingPulse/espaper-weatherstation/blob/master/configportal.h#L139 in saveConfig(). Can you verify that function is executed?

by (9.6k points)
To add information to Marcel's answer, the process is as follows:
1) Check if espaper.txt is available on the file system. If it is, load configuration values from there. If it is not, start configuration portal (access point mode, webserver) and display this on screen
2) Now the user has to connect by WiFi to the ESPaper access point and open the browser at the given (IP) address
3) The user enters the credentials for WiFi and wunderground and saves the configuration. Now the espaper.txt file exists on the drive
-> Restart the device and the code will load the settings from espaper.txt
by (170 points)
Silly me. I didn't run through the configuration. Apparently that's where it's created. Now I have a file with the guid and secret, but I'm not getting anything back from the server. It's failing with a -1:
[HTTP] GET... failed, error: connection refused
I try it with my local server and the test server. Putting the headers in Postman doesn't work either, returning a 404.

I'm stumped again.
by (9.6k points)
Can you explain what you mean with local and test server? I didn't know that wunderground offers local servers for testing? Or are you just providing a JSON file?
Or are you actually using the espaper-client code?
by (170 points)
I'm using the espaper-server-php application locally. I assume this is the same application that is run at https://test.espaper.com for test and https://www.espaper.com for production.
by (9.6k points)
Hi baxter. Your assumption is not correct. The espaper-server-php is a php script and is very simplistic compared to what is running on espaper.com. There we have a Java server which also requires some security features to be present in the request. So if you want to connect to espaper.com then please follow the setup instructions on https://github.com/ThingPulse/espaper-client#setup. What might be missing for you is the device id and secret which you can configure on the same web portal provided by the ESP where you set the SSID and password for your WiFi network.
by (170 points)
Yes, I've got the guid and secret in the espaper.txt file. I know tyey are being passed in the X-ESPAPER headers. Here's the output:

[HTTP] GET... code: -1
[HTTP] GET... failed, error: connection refused

I use https://test.espaper.com with fingerprint 3E 65 97 60 54 30 D7 D0 CF A3 05 27 09 9E 8D FB 71 F4 4A D9
by (9.6k points)
I just checked the database: you registered your user on www.espaper.com but are calling the test.espaper.com service. Please call https://www.espaper.com from the device. The test instance is a unstable version and should not be used externally.
by (170 points)
Well, that fixed it. I didn't want to burden the production server until my testing was done, but I guess that's OK.

Now I wonder why it doesn't work when I send it to my PHP application?

Welcome to ThingPulse Q&A, where you can ask questions and receive answers from other members of the community.