mathworks / thingspeak-arduino

ThingSpeak Communication Library for Arduino, ESP8266 and ESP32
https://thingspeak.com
431 stars 231 forks source link

Doesn't seem to work with Wificonfig() #69

Closed Wakewatcher closed 3 years ago

Wakewatcher commented 4 years ago

Everything working fine until I try to set a dedicated ip address for my ESP8266. I've got several client 8266s sending data to an aggregator ESP8266 which then packages it up and uploads it to ThingSpeak. However when I attempt to assign an ip address to the aggregator, such that the clients know where it is, then I get a -301 response back. Typically the router assigns the same IP address to it and everything works with that IP address but if I use that same IP address in an Wificonfig() call it fails. I looked in ThingSpeak.h and must be above my pay grade. Nothing jumped out at me. Some are surprised it works at all given the aggregator is acting as a server of sorts and a client at the same time. But it works great unless I include WiFi config() then when writeFields() calls connectThingSpeak() it fails on client->connect(const_cast<char *>(THINGSPEAK_URL), this->port); generating a dreaded -301.

For example. IPAddress ip(192, 168, 10, 148); // IP address of the server IPAddress gateway(192, 168, 10, 1); // gateway of your network IPAddress subnet(255, 255, 255, 0); . . Setup() { WiFi.config(ip, gateway, subnet);

v-c commented 3 years ago

It appears when you call WiFi.config(), you're changing the topology of the network losing connectivity to Thingspeak. I'm not sure this is an issue with the library.