Predictible random number nodemcu 1.5.1
Posted: Mon Jun 27, 2016 1:37 am
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:
and this is the output i get:
and again
what´s wrong with this behaviour?
Try by yourself
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 all
function 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 all
SENT: 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 all
SENT: 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