Access LoPy mac address without using atom.

  • Hi.

    I want to create a python scripts that returns the mac address of the connected LoPy.
    I am connected to the LoPy via. USB using a USB To TTL Serial Converter Adapter.

    With this, is it possible to send the following commands down to the LoPy:
    import ubinascii, network

    and then return the value of ubinascii.hexlify(network.LoRa().mac()), is it possible?

    As of now, I have to manually write
    import ubinascii, network
    print (ubinascii.hexlify(network.LoRa().mac()))
    in the atom REPL and copy the print result, I wish to automate this process.


    Best regards

  • @hobbypy any programming language with a serial library should work. simply open a serial connect to the board via your preffered language / framework. and send the code as a string over it. The response will come back over serial just like the REPL does.

  • Thanks.

    Yes, I am aware that I can put the commands in any python script located at the LoPy.

    Basically, I want to create a python function/script that returns the mac address, which I can then use for futher use (register device on ttn using their python-SDK for example).

    But looking at the pyserial library, I think what I want is harder to implement than what I previously thought so I will have to see if I can figure out something.

  • @hobbypy With the risk of stating the obvious, you can put these two statements in any Python file that is executed on the LoPy, e.g.
    If you do not want to do that, any program on your PC which is able to communicate over the serial interface can send these two commands and get the answer back. Atom is just one of plenty.

Pycom on Twitter