Closed GekoCH closed 5 years ago
Hi @GekoCH
Hmmm. Response -1 indicates that either there maybe no network connection?! Without debugging it's hard to tell. Are you using Arduino IDE?
I had the same problem. For me the reason was that there seems to be no support for HTTPS. So I added a subdomain to my nextcloud server which works without encryption only for this purpose. This worked.
As explained in sensorlogger/issues/102
I had to configure https on my side for which I am using the WiFiClientBearSSL library on ESP8266 / ESP32 from Earle F. Philhower, III.
There are various ways to verify the certificate chain of your Let's Encrypt certificate chain too. I verified Fingerprint, Certificate, Chain Cert, Root Cert and will probably stick with both the Cert and Chain Cert in the end. However I recall that setting the clock via the NTP code (port 13) above did not work for me right out-of-the-box, hence I used the time returned via a simple HEAD request to my server instead.
Here is the routine I use from Earle's library https://github.com/earlephilhower/bearssl-esp8266
Note that having the time set correctly is a pre-requisite for having SSL certs checked / verified.
#include <time.h> // Set time via NTP, as required for x.509 validation void setClock() { configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov"); Serial.print("Waiting for NTP time sync: "); time_t now = time(nullptr); while (now < 8 * 3600 * 2) { delay(500); Serial.print("."); now = time(nullptr); } Serial.println(""); struct tm timeinfo; gmtime_r(&now, &timeinfo); Serial.print("Current time: "); Serial.print(asctime(&timeinfo)); }
You may need or want to adjust for the timezone setting depending on your location and the ntp servers used.
Hy
I looked for an Arduino sketch to send data to my Nextcloud DB. With the sensordata.py form my Pi it works great. However the code for the Arduino NodeMCU v2 does not work. The HTTP respond is -1
Andy