Left here for archival purposes.
User avatar
By Yomero
#49849 Hello everyone,

i have a nodemecu 0.9 dev (ESP-12) board with nodemcu 1.5.1 firmware and i noticed when i try to generate a random number every so often, always get the same values, here my code:

Code: Select allfunction datos()
   print(math.random(0,10))
end
datos()
tmr.alarm(1, 5000, 1, function() datos() end)


and this is the output i get:

Code: Select allSENT: node.restart()
node.restart()
>
 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 27528, room 16
tail 8
chksum 0x2d
load 0x3ffe8000, len 2184, room 0
tail 8
chksum 0x9a
load 0x3ffe8888, len 8, room 0
tail 8
chksum 0xc1
csum 0xc1
don't use rtc mem data
sd???

NodeMCU 1.5.1 build unspecified powered by Lua 5.1.4 on SDK 1.5.1(e67da894)
10
> 10
7
9
7
3
1
9
8
2
5
6
2
4
7
7
5
9
6
8


and again

Code: Select allSENT: node.restart()
node.restart()
>
 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 27528, room 16
tail 8
chksum 0x2d
load 0x3ffe8000, len 2184, room 0
tail 8
chksum 0x9a
load 0x3ffe8888, len 8, room 0
tail 8
chksum 0xc1
csum 0xc1
don't use rtc mem data
sd???

NodeMCU 1.5.1 build unspecified powered by Lua 5.1.4 on SDK 1.5.1(e67da894)
10
> 10
7
9
7
3
1
9
8
2
5
6
2
4
7
7
5
9
6
8


what´s wrong with this behaviour?

Try by yourself
User avatar
By Yomero
#49867
martinayotte wrote:Thanks for the info !
I've tried out and works nicely !



Did you mean that works in your test? the values are not the same?

Thats wierd, because in 0.9.6 firmware the function works very well, something changes in the firmware since 1.4.0 or 1.5.1 for me

any sugestion?