• LoPy4 random number method (solved)

    LoPy lopy4 random examplecode forum
    6
    0 Votes
    6 Posts
    1k Views
    P
    @robert-hh Thanks What I want here is to simulate some users doing 1 of 3 things, so: >>> print(uos.urandom(1)[0] %3) 0 >>> print(uos.urandom(1)[0] %3) 0 >>> print(uos.urandom(1)[0] %3) 1 >>> >>> print(uos.urandom(1)[0] %3) 2 >>> print(uos.urandom(1)[0] %3) 2 simplifies my code and will be OK. Regarding Micropython, I've 'hacked' a bit of other code at times and this is the first time I'm having to find the functions I need, so little things like 'dir(os)' are gems. Dave
  • [SOLVED] How to get random number in a range

    LoPy random rng urandom
    6
    0 Votes
    6 Posts
    3k Views
    A
    @robert-hh @livius thank you so much!
  • Random number generator

    Moved MicroPython random lopy
    4
    0 Votes
    4 Posts
    2k Views
    T
    @livius Thanks I tried it and it works. I had another question if you could give some suggestion. I have been trying to take the last four bytes of the mac address as source and destination address to send data from one Lopy to a second LoPy. I created a package header as the following: _LORA_PKG_FORMAT = "LL%ds" _LORA_ACK_FORMAT = "LLB" SRC_MAC_ADDR = ubinascii.hexlify(lora.mac().strip()[-4:]) Destination address DEST_MAC_ADDR = b'9cc15603' ** pkg = struct.pack(_LORA_PKG_FORMAT, DEST_MAC_ADDR, SRC_MAC_ADDR, msg) But when I try running it complains saying ValueError: unsupported format for the line with **. what do you think I am doing wrong?
  • Connect to BLE device using random adddress type

    LoPy ble connect random
    4
    0 Votes
    4 Posts
    2k Views
    S
    @jmarcelino Just checking if this is resolved. I am still not able to connect to BLE device when using Bluetooth.RANDOM_ADDR.