Random generator seed still not being initialized v0.5.3


As far back as Nov 2015 @Forged noted an issue with the seed of the random generator not being
updated by the Particle Cloud as stated in the documentation. A few months later @vwegert faced the same problem.

Today and running firmware 0.5.3 the issue persists. I discovered it after unsuccessfully try to
randomly delay the start of a controlled load in a fleet of Photons. The entry:


always returned the same sequence in each device and each run:
53, 63, 62, 89, 60, 108…

I’m now using the workaround provided by @mdma:

uint32_t seed = HAL_RNG_GetRandomNumber();

however it will great to have it fixed in the firmware and thus avoid to release undocumented
code to production.

Thank you!

random_seed_from_cloud - Not Working?

Random number generator not initialized?

See also

Maybe that’s a reason why this won’t get too much attention anymore

You can also use something like

  randomSeed(analogRead(A0) + micros());

where A0 is a floating analog pin - works best after some unknown WiFi reconnect time.

Not as random as the HAL call, but at least not undocumented :wink:

1 Like

Thank you @ScruffR for your message.

1 Like