I am using and ESP32 with WiFi to connect a mesh of ESP8266 to my ArduinoIOTCloud.
But it constantly throws the following error:
[E][esp32-hal-adc.c:135] __analogRead(): GPIO0: ESP_ERR_TIMEOUT: ADC2 is in use by Wi-Fi.
Which was very confusing as I am not doing any analogRead() anywhere!
It is well documented that there is the issue of not being able to read the ADC2 pins whilst using WiFi in ESP32. I note that ESP32 is a relatively recent addition to ArduinoIOTCloud and it may be a latent bug.
The issue clouds other logs and was a mystery.
I have spent significant time tracking down the issue and I have found that the origin of the issue is in the
... \ArduinoIoTCloud\src\utility\time\NTPUtils.cpp code where there is the function to getRandomPort
int NTPUtils::getRandomPort(int const min_port, int const max_port)
{
#ifdef BOARD_HAS_ECCX08
return ECCX08.random(min_port, max_port);
#else
randomSeed(analogRead(0));
return random(min_port, max_port);
#endif
}
#endif /* #ifndef HAS_LORA */
I have commented out the randomSeed(analogRead(0)); line and this stops the error messages with no identified issues (so far!)
I can see that reading the analog channel would give a random seed if the pins were electrically floating.
BUT it seems to be an expense in this use AND why does NTP even offer to get a random port?