skaarj1989/mWebSockets

randomSeed calls always start at 0 on esp32

Closed this issue · 2 comments

Describe the bug
On a Feather esp32s3, calling analogRead(0) results in an error and returns zero. That call is used for random seeds in the code.

Environment info

  • mWebSockets version/branch: 1.6.0/master
  • IDE w/version: Arduino IDE 2.3.2
  • Platform/Board: Adafruit ESP32-S3 Feather with 4MB Flash 2MB PSRAM
  • Network controller (shield or module): PoE Featherwing (W5500)

Expected behavior
A valid random value is required.

Failure log

[esp32-hal-adc.c:158] __analogReadRaw(): Pin 0 is not ADC pin!

Additional context

Thank you for reporting the issue.

You can work around this problem by heading into:

randomSeed(analogRead(0));

and replacing 0 with a correct ADC pin.

I don't have a Feather esp32s3 board to test this. Could you check something like A0...A5?

Thanks. I can confirm that using A0 works. I changed the same setting in WebSocketClient.cpp too.