Bodmer / DarkSkyWeather

Arduino ESP32 and ESP8266 compatible library to read weather forecast from Dark Sky API
Other
81 stars 16 forks source link

ssl library #2

Closed glown closed 6 years ago

glown commented 6 years ago

Is the BearSSL code provided by the ArduinoBearSSL library?

It's probably obvious, but wanted to be sure. I had the wrong JsonStreamingParser installed :-)

Bodmer commented 6 years ago

The BearSSL is built into the ESP8266 Arduino core.

Yes, sorry about the json library conflict, I am migrating it to a different name so Daniel's original can co-exist.

glown commented 6 years ago

Oh! I'll go back and look at my compile error again; I had the impression it the bearssl was referring to undefined code.

And np on the json library. You're code is well documented so it was easy to spot the conflict.

Bodmer commented 6 years ago

I am not sure when BearSSL was added to the ESP8266 library so maybe you have an earlier version of the ESP8266 core.

There is a #define switch to use the original AXTLS library that is still in the ESP8266 core for the https security negotiation, in the latest version on Github this is here.

In a previous version the switch was in the main DarkSkyWeather.cpp file, at around line 28

If you are having problems then post back as you are lucky enough to be one of the first users of this library! Later today I will be uploading changes to use the JSON_Decoder library, this will then avoid the problem of having to swap out Daniel Eichhorn's library (which may previously have been loaded via the Arduino IDE's library manager.)

glown commented 6 years ago

I'm using Arduino IDE version 1.8.5 ( which should have up to date core), but compile throws:

C:\Users\winusr\Documents\Arduino\libraries\DarkSkyWeather\DarkSkyWeather.cpp: In member function 'bool DS_Weather::parseRequest(String)': C:\Users\winusr\Documents\Arduino\libraries\DarkSkyWeather\DarkSkyWeather.cpp:205:5: error: 'BearSSL' has not been declared BearSSL::WiFiClientSecure client;

Using the AXTLS define everything compiles.

It just occurred to me that I need to verify the ESP8266 core … I'll check that today.

Bodmer commented 6 years ago

I see BearSSL was added to the WiFi library in August 2018, it is in the latest 2.4.2 version of the board package and can be loaded via the Arduino IDE's boards manager. I will see if I can add a check for the presence of BearSSL. BearSSL promises to be more memory efficient hence the choice.

glown commented 6 years ago

That's it exactly. Using the boards manager to update esp8266 from 2.4.1 to 2.4.1 resolves the BearSSL issue (successfully compiles with AXTLS commented).

I'm using a wemos d1 mini and compiling caught a couple of other compile issues. I'm checking if changing the following helps or not: change #include to

ifdef ESP8266

include

include

else // ESP32

include

endif

in TFT_eSPI_weather-v3 and NTP_Time.h

glown commented 6 years ago

Two last comments about TFT_eSPI_weather_v3: 1) Did I break TIME by commenting WiFi.h? Time seems wrong and getting messages like "No NTP reply, trying again in 1 minute..." so I was wondering if the NTP_Time.h code is working. WiFiUDP.h is stll being included.

2) I looked for a comment but did not find anything telling us to load the /data directory to the SPIFFS manually. Screen was barren, had no support files, saw no downloading code, then spotted the resources in /data. Downloaded /data and it works like a charm.

Bodmer commented 6 years ago

I suspect the time server cannot be reached for some reason, I did add a short timeout of 300ms but typically response times I get are less that 30ms. I would expect and error if the udp library did not load.

Ah, I added the ESP8266/32 WiFi library selection in the library, I forgot about the sketch. I will update it.

I have been making some changes to the library and this will be uploaded soon.

Bodmer commented 6 years ago

It would be worth trying the stock NTPClient example in the IDE's ESP8266WiFi example folder to see if that works and perhaps copy across the NTP server name/settings to the weather sketch.

Unfortunately I need to do a PC spring clean as I am getting very silly error reports from the IDE at the moment for any sketches using an ESP8266.

glown commented 6 years ago

I did that and everything is working. Thank you for the new library!

Bodmer commented 6 years ago

Thanks for letting me know, I will copy across the settings too, then at least the server used will be consistent with the ESP8266 example.

I hope to make a multi-page display version at some point with graphs of the temperature, rain, pressure and wind forecast for the next 24hrs and for the next week.

glown commented 6 years ago

a multi-page display would be great .. something I'll look forward to in the future!

Is it feasible to think about driving 2 physical screens with an esp8266? The esp8266 is great, but it has to have limitations .. and 1 screen may be the esp8266's sweet spot and it might be too much to expect more.

Bodmer commented 6 years ago

I have run 2 screens, of course you can only update one at a time. The way I did this was to use two instances of the tft library e.g.:

TFT_eSPI tft_1 = TFT_eSPI(); // Invoke custom library

TFT_eSPI tft_2 = TFT_eSPI(); // Invoke custom library

With the TFT_CS not defined in the setup:

define TFT_CS // Not defined

Then drive the correct CS pin LOW and HIGH in the sketch: digitalWrite(TFT1_PIN, LOW); draw something on tft1 digitalWrite(TFT1_PIN, HIGH);

digitalWrite(TFT2_PIN, LOW); draw something on tft2 digitalWrite(TFT2_PIN, HIGH);

I have not tried this recently though, so you will need to experiment.